API keys API
API keys: secret, restricted and publishable, in test or live mode.
The same operations are in the interactive API reference, and the whole contract is in the OpenAPI document.
GET/v1/keys
List keys
Lists every API key of the organization, test and live, active and revoked, newest first. limit is 1 to 100 (default 50, out of range values are clamped) and cursor is the next_cursor of the previous page. The cursor is opaque and never built by the client; a cursor this API did not return is a 400. has_more is true while another page exists. There is no total. The list never contains a secret, only the first characters (token_prefix) so that keys can be told apart, and when each was last used.
Who may call it: a person with settings or developer-management rights, or a secret key. A restricted or publishable key is refused with 403 even if it has keys:read.
The same keys appear grouped by app under /v1/apps/{id}/keys. Read only and safe to repeat.
Scope keys:read. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
limit | query | integer | No | How many items to return. Default 50, at most 100. |
cursor | query | string | No | The `next_cursor` of the previous page. Opaque; never built by the client. |
POST/v1/keys
Create a key
Makes an API key and returns it with its secret. The secret is shown once, in this response; only a hash is stored, so it cannot be read back or recovered. If it is lost, roll or replace the key.
kind is secret (the whole organization, for your server), restricted (only the scopes listed, such as calls:read or knowledge:*) or publishable (opens widget sessions from the allowed_origins listed, nothing else). mode is test (simulated, nothing is dialled or charged) or live (real numbers, paid from credit).
Live keys are held to a higher bar. The caller must be an admin or use a secret key, and a signed-in person must have entered their password again in the last five minutes, otherwise 403 reauthentication_required. Test keys only need the ordinary key permission. A key made with a bad kind, mode or unknown api_version is refused with 400.
Idempotency. Send Idempotency-Key when calling with an API key: a retry returns the first response, including the same secret, instead of making a second key. The same key with a different body is refused, and a retry while the first is still running answers 409 idempotency_in_progress. Personal tokens and console sessions are not covered, so do not blindly retry those.
A key made here has no app; the console moves it into the first app. To make a key inside a given app, use POST /v1/apps/{id}/keys.
Scope keys:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Makes a POST safe to repeat: the same key returns the first result for 24 hours. The same key with a different body is refused with `422 idempotency_key_reused`; while the first request still runs, `409 idempotency_in_progress`. |
DELETE/v1/keys/{id}
Revoke a key
Revokes a key so that it stops working. Revoking is permanent: a revoked key cannot be reinstated, make a new one. Calls already in progress finish; every later call with it answers 401.
The caller must hold the key permission (a secret key, or a person with settings or developer-management rights). Revoking a live key also needs an admin or a secret key, and a signed-in person must have entered their password again in the last five minutes (403 reauthentication_required).
Be careful not to revoke the key you are calling with unless you mean to; the response arrives, but the next call will not. When replacing a key in use, prefer rolling it (POST /v1/keys/{id}/roll), which keeps the old key working for a grace period.
The id is a key's id from the list, not its prefix. A 404 means no key with that id in this organization, or one that is already revoked, so repeating the call answers 404. Returns 204 with no body.
Scope keys:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
POST/v1/keys/{id}/roll
Roll a key
Replaces a key with a new one of the same kind, mode, scopes and origins, and returns the new key with its secret (shown once). The old key keeps working for a grace period so you can deploy the new one without downtime, then stops by itself.
grace_hours sets the period: the default is 24, 0 stops the old key now, and the most allowed is 168 (seven days); larger values are cut to 168. grace_seconds is the same in seconds, rounded up to whole hours, for the console's form. If both are sent, grace_hours wins. The body may be left out entirely to take the default.
During the grace period the old key shows status expiring in lists. The new key stays in the old key's app.
Permissions as for revoking: rolling a live key needs an admin or a secret key, and a signed-in person must have entered their password again in the last five minutes.
Idempotency. Send Idempotency-Key with an API key. A retry then returns the first response and its secret instead of rolling twice and leaving a second new key. Without one, repeating the call rolls again.
Scope keys:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
Idempotency-Key | header | string | No | Makes a POST safe to repeat: the same key returns the first result for 24 hours. The same key with a different body is refused with `422 idempotency_key_reused`; while the first request still runs, `409 idempotency_in_progress`. |