# POST /v1/client-tokens Mint a short-lived token that lets a browser act for one consumer. | Access | | | --- | --- | | Keys | secret only | | Plan | every plan | | Environment | live and sandbox | | Acts for | the account | | While the account is suspended | works | | During a data stop | works | ## Body | Field | Type | Description | | --- | --- | --- | | `clientId` | string | Your own opaque ID for the consumer: 1 to 64 characters of letters, digits, _ and -. Never an email address or a phone number. | | `expiresInMinutes` | integer | (optional) How long the token lasts. 15 when left out; at most 60. | ```json { "clientId": "u_8f2k", "expiresInMinutes": 15 } ``` ## Answers ### 201: The token, and when it stops working The answer is `{ data, meta }`; `meta` holds `requestId` and `environment`. `data`: | Field | Type | Description | | --- | --- | --- | | `token` | string | Send it as the X-Client-Token header, with your publishable key. | | `expiresAt` | string | Mint a new one before this. | ```json { "data": { "token": "eyJ…", "expiresAt": "2026-11-02T12:15:00.000Z" }, "meta": { "requestId": "req_7Hk2mT1xKp7Zc2Nf5Rb9Wd", "environment": "test" } } ``` ## Errors | Status | Codes | | --- | --- | | 400 | [`client_id_must_be_opaque`](../../errors/client_id_must_be_opaque.md), [`validation_failed`](../../errors/validation_failed.md) | | 401 | [`invalid_api_key`](../../errors/invalid_api_key.md), [`key_revoked`](../../errors/key_revoked.md), [`missing_api_key`](../../errors/missing_api_key.md) | | 403 | [`account_pending`](../../errors/account_pending.md), [`origin_not_allowed`](../../errors/origin_not_allowed.md), [`secret_key_in_browser`](../../errors/secret_key_in_browser.md), [`secret_key_required`](../../errors/secret_key_required.md) | | 429 | [`rate_limited`](../../errors/rate_limited.md) | | 500 | [`internal_error`](../../errors/internal_error.md), [`temporarily_unavailable`](../../errors/temporarily_unavailable.md) | Every error has the same body, and says how to fix it ([responses and errors](../../concepts/responses-and-errors.md)). ## More Call it from your server. It mints a short-lived token that lets your website act for one consumer with your `pk_` key. Request: ```json { "clientId": "u_8f2k", "expiresInMinutes": 15 } ``` - `clientId`: required; your opaque ID for the consumer, 1–64 characters of `A-Z a-z 0-9 _ -`. Missing is `400 validation_failed`. An email address, a phone number or other characters get `400 client_id_must_be_opaque`. - `expiresInMinutes`: optional, default 15, at most 60. A larger value is `400 validation_failed`, never silently shortened. Works while the account is suspended, so your consumers can still read and delete what they saved. Response `201`: ```json { "data": { "token": "eyJ…", "expiresAt": "2026-11-02T12:15:00.000Z" }, "meta": { "requestId": "req_…", "environment": "test" } } ``` The browser then sends `Authorization: Bearer pk_…` and `X-Client-Token: eyJ…`. The token is bound to your account and environment; it is `401 client_token_account_mismatch` with another account's `pk_` key and `401 client_token_invalid` across environments. Mint a new one when it expires (`401 client_token_expired`). _This page is made from the route's own declaration by `npm run openapi`. To change it, change the declaration or its explanation, never this file._