---
title: "Generate NanoIDs or custom-alphabet random IDs with crypto randomness, plus a collision-probability estimate."
method: POST
path: "/api/v1/nanoid"
tags: ["Cryptography & Hashing"]
---

# Generate NanoIDs or custom-alphabet random IDs with crypto randomness, plus a collision-probability estimate.

`POST /api/v1/nanoid`

## Request

- Base URL: `https://programmes.net`
- URL: `https://programmes.net/api/v1/nanoid`
- Auth: none declared

NanoID Generator. Operations: `generate` — Generate one or more random IDs (default: 21-char URL-safe NanoID). `collision` — Estimate how long until a 1% collision chance for an alphabet size, ID length and rate.

## Request body

- union
  - NanoidGenerate: Generate one or more random IDs (default: 21-char URL-safe NanoID).
    - `operation` 'generate', required
    - `input` string: A custom alphabet, or empty for the default URL-safe NanoID alphabet.
    - `options` object
      - `size` integer: Characters per ID.
      - `count` integer: How many IDs.
  - NanoidCollision: Estimate how long until a 1% collision chance for an alphabet size, ID length and rate.
    - `operation` 'collision', required
    - `input` string: The alphabet (its unique character count is used), or empty for the default.
    - `options` object
      - `size` number: Characters per ID.
      - `perHour` number: IDs generated per hour.

## Response `200`

The operation ran.

- object
  - `ok` unknown, required
  - `tool` 'nanoid', required
  - `operation` 'generate' | 'collision', required
  - `result` unknown, required

## Other responses

- `400`: The request is not valid (https://programmes.net/api#invalid-request); The tool has no such operation (https://programmes.net/api#unknown-operation)
- `404`: No such tool (https://programmes.net/api#unknown-tool)
- `413`: The request or its input is too large (https://programmes.net/api#content-too-large)
- `415`: The body must be JSON (https://programmes.net/api#unsupported-media-type)
- `422`: An option is missing, of the wrong type or out of range (https://programmes.net/api#invalid-options); This call needs more CPU than one API call may use (https://programmes.net/api#refused); The operation could not process the input (https://programmes.net/api#tool-error)
- `429`: Too many requests (https://programmes.net/api#rate-limited)
- `500`: Internal error (https://programmes.net/api#internal-error)

---

[API](https://skmtc.dev/programmes/apis/programmes-net-api.md) · [All operations](https://skmtc.dev/programmes/apis/programmes-net-api/llms.txt) · [OpenAPI document](https://skmtc.dev/programmes/apis/programmes-net-api/revisions/aa939784a2e6?raw)
