KashuDocs

API keys

The API keys endpoints of the Kashu API, with their parameters, objects, errors and examples. The guide explains how they fit together.

EndpointWhat it does
GET /v1/api_keysList the API keys of the calling key's mode, newest first.
POST /v1/api_keysCreate an API key in the calling key's mode. The response is the only place a secret key's token appears.
GET /v1/api_keys/{id}Retrieve an API key.
POST /v1/api_keys/{id}/rollReplace an API key with a new one of the same access. The old key ends now, or after expires_in seconds.
POST /v1/api_keys/{id}/revokeRevoke an API key at once. Revoking a revoked key returns it unchanged.

The API key object

FieldTypeAbout
idstringAn id that starts key_.
objectstringAlways "api_key".
typeenumOne of secret, restricted, publishable.
livemodeboolean
labelstring or null
displaystring
tokenstring
scopesarray of string or null
allowed_originsarray of string or nullWhere a publishable key's card form may be embedded. null for every other kind of key.
statusenumOne of active, expiring, revoked.
api_versionenumOne of 2026-11-06.
expires_atinteger or nullUnix seconds.
revoked_atinteger or nullUnix seconds.
createdintegerUnix seconds.
{
  "id": "key_1a2B3c4D5e6F7g8H9i0J1k2L",
  "object": "api_key",
  "type": "secret",
  "livemode": false,
  "label": "Order server",
  "display": "kashu_sk_test_4eC3...0aaa",
  "scopes": [
    "payments:read"
  ],
  "allowed_origins": [
    "https://shop.example.com"
  ],
  "status": "active",
  "api_version": "2026-11-06",
  "expires_at": null,
  "revoked_at": null,
  "created": 1762473600
}

GET /v1/api_keys

List the API keys of the calling key's mode, newest first.

Scope
api_keys:read
Keys
Secret, or restricted with the scope below.
Idempotency-Key
Not used. A read changes nothing.
Answers
200 with a list of API key, newest first.

Parameters

NameInTypeRequiredAbout
limitqueryintegerOptionalAt least 1. Up to 100. Defaults to 10.
cursorquerystringOptional
Kashu-VersionheaderstringOptionalThe API version to answer in. Defaults to the key's pinned version.

Errors

Examples

curl "https://api.kashupay.com/v1/api_keys?limit=3" \
  -H "Authorization: Bearer $KASHU_SECRET_KEY"
const list = await kashu("GET", "/v1/api_keys?limit=3");
console.log(list.has_more);

POST /v1/api_keys

Create an API key in the calling key's mode. The response is the only place a secret key's token appears.

Scope
api_keys:write
Keys
Secret, or restricted with the scope below.
Idempotency-Key
Optional. Without one, Kashu makes one and returns it. See Idempotency.
Answers
201 with the API key.

Parameters

NameInTypeRequiredAbout
Idempotency-KeyheaderstringOptionalOptional. When absent, Kashu mints one and returns it. Up to 255 characters.
Kashu-VersionheaderstringOptionalThe API version to answer in. Defaults to the key's pinned version.

Request body

FieldTypeRequiredAbout
typeenumRequiredOne of secret, restricted, publishable.
scopesarray of stringOptionalUp to 50 items.
allowed_originsarray of stringOptionalPublishable keys only: the origins (https://shop.example.com) the card form may be embedded on. A test key may also name http://localhost or http://127.0.0.1, with a port. Without any, the card form refuses to load. Up to 20 items.
labelstringOptionalUp to 100 characters.

Errors

Examples

curl https://api.kashupay.com/v1/api_keys \
  -H "Authorization: Bearer $KASHU_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type":"secret","label":"Order server"}'
const apiKey = await kashu("POST", "/v1/api_keys", {
  "type": "secret",
  "label": "Order server"
});
console.log(apiKey.status);

GET /v1/api_keys/{id}

Retrieve an API key.

Scope
api_keys:read
Keys
Secret, or restricted with the scope below.
Idempotency-Key
Not used. A read changes nothing.
Answers
200 with the API key.

Parameters

NameInTypeRequiredAbout
idpathstringRequiredAn id that starts key_.
Kashu-VersionheaderstringOptionalThe API version to answer in. Defaults to the key's pinned version.

Errors

Examples

curl https://api.kashupay.com/v1/api_keys/key_1a2B3c4D5e6F7g8H9i0J1k2L \
  -H "Authorization: Bearer $KASHU_SECRET_KEY"
const apiKey = await kashu("GET", "/v1/api_keys/key_1a2B3c4D5e6F7g8H9i0J1k2L");
console.log(apiKey.status);

POST /v1/api_keys/{id}/roll

Replace an API key with a new one of the same access. The old key ends now, or after expires_in seconds.

Scope
api_keys:write
Keys
Secret, or restricted with the scope below.
Idempotency-Key
Optional. Without one, Kashu makes one and returns it. See Idempotency.
Answers
200 with the API key.

Parameters

NameInTypeRequiredAbout
idpathstringRequiredAn id that starts key_.
Idempotency-KeyheaderstringOptionalOptional. When absent, Kashu mints one and returns it. Up to 255 characters.
Kashu-VersionheaderstringOptionalThe API version to answer in. Defaults to the key's pinned version.

Request body

FieldTypeRequiredAbout
expires_inintegerOptionalUp to 604800.

Errors

Examples

curl https://api.kashupay.com/v1/api_keys/key_1a2B3c4D5e6F7g8H9i0J1k2L/roll \
  -H "Authorization: Bearer $KASHU_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expires_in":86400}'
const apiKey = await kashu("POST", "/v1/api_keys/key_1a2B3c4D5e6F7g8H9i0J1k2L/roll", {
  "expires_in": 86400
});
console.log(apiKey.status);

POST /v1/api_keys/{id}/revoke

Revoke an API key at once. Revoking a revoked key returns it unchanged.

Scope
api_keys:write
Keys
Secret, or restricted with the scope below.
Idempotency-Key
Optional. Without one, Kashu makes one and returns it. See Idempotency.
Answers
200 with the API key.

Parameters

NameInTypeRequiredAbout
idpathstringRequiredAn id that starts key_.
Idempotency-KeyheaderstringOptionalOptional. When absent, Kashu mints one and returns it. Up to 255 characters.
Kashu-VersionheaderstringOptionalThe API version to answer in. Defaults to the key's pinned version.

Request body

Send no body, or an empty JSON object.

Errors

Examples

curl https://api.kashupay.com/v1/api_keys/key_1a2B3c4D5e6F7g8H9i0J1k2L/revoke \
  -X POST \
  -H "Authorization: Bearer $KASHU_SECRET_KEY"
const apiKey = await kashu("POST", "/v1/api_keys/key_1a2B3c4D5e6F7g8H9i0J1k2L/revoke");
console.log(apiKey.status);