Docs/APIs/Short Code Generator

Short Code Generator

Generate short alphanumeric codes

OperationalCredits 1 per callp50 115msData GenerationStar

Overview

Each character of each code is picked independently with Node's `crypto.randomInt`, a cryptographically secure source, from the set named by `charset`. The sets are fixed: `alphanumeric` (the default) uses A-Z, a-z and 0-9, 62 characters; `alpha` uses A-Z and a-z, 52; `numeric` uses 0-9; `hex` uses 0-9 and lowercase a-f; and `base58` uses 58 characters that omit 0, O, uppercase I and lowercase l, so codes can be read aloud or typed from print with fewer mistakes. `charset` is case-insensitive.

`length` sets characters per code, from 4 to 32 with a default of 8. `count` sets how many codes are returned, from 1 to 100 with a default of 1.

The number of possible codes is the size of the set raised to the power of the length. An 8-character alphanumeric code has 62^8 possibilities while a 6-digit numeric code has only 10^6, so choose the set and length with the size of your campaign in mind. Codes within a batch are not deduplicated against each other or against earlier requests; collisions are unlikely at reasonable lengths but possible, especially with short numeric codes, so check new codes against the ones you have already issued.

The response echoes `length`, `charset` and `count`, the actual number of entries in `codes`. `url_safe` is true for all five sets, because none of them contains a character that needs escaping in a URL path or query string.

Live Test Short Code Generator API →

Endpoint

One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.

GEThttps://api.apiverve.com/v1/shortcodegenerator
curl "https://api.apiverve.com/v1/shortcodegenerator?count=5&length=8&charset=alphanumeric" \
  -H "x-api-key: your_api_key_here"

Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.

Authentication

Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.

401 is the only auth verdict

A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.

Parameters

Sent in the query string. Premium parameters are accepted on every plan but only take effect on plans that include them.

ParameterTypeDescription
countOptionalintegerNumber of codes to generate
default 1 · range 1–100
lengthOptionalintegerLength of each code
default 8 · range 4–32
charsetOptionalstringCharacter set
alphanumericalphanumerichexbase58
default alphanumeric

Response

Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.

Sample response
{
  "status": "ok",
  "error": null,
  "data": {
    "codes": [
      "bgiFznFh",
      "jr84hHsG",
      "Q77qABwn",
      "gvMjXxXs",
      "WDPJzCsi"
    ],
    "count": 5,
    "length": 8,
    "charset": "alphanumeric",
    "url_safe": true
  }
}

Response fields

Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.

FieldTypeExampleDescription
codesarray[bgiFznFh, ...]Array of generated short codes
countnumber5Number of codes generated
lengthnumber8Length of each generated code
charsetstring"alphanumeric"Character set used for generation
url_safebooleantrueWhether the generated codes are safe to use in a URL without encoding

Errors

Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.

StatusMeaningWhat to do
400Input was rejectedRead error; it names the parameter.
401Key missing or invalidCheck the header name and the key value.
403Key valid, but not permittedA key restriction or IP allow-list; see key scoping.
429Rate limited, or out of creditsRead error to tell them apart; see rate limits.

Use cases

URL Shortening
Generate short codes for URL shortening services and link tracking
Voucher Systems
Create unique voucher and coupon codes for e-commerce and promotions
Temporary Access
Generate temporary access codes and one-time passwords for authentication
Referral Programs
Create short referral codes for marketing and referral tracking systems

Other ways to use Short Code Generator

Set up Short Code Generator on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them — one key, one balance.

Give it to an AI agentConnect over MCP and your agent calls it as a native tool — Claude, Cursor, ChatGPT.VerveKit →Reference →
Google Sheets or ExcelA =VERVE() formula fills a column — no script, no export, recalculates in place.VerveSheets →Reference →

More in Data Generation:

Was this page helpful?