KashuDocs

Card tokens

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

EndpointWhat it does
POST /v1/card_tokensTurn the card form's single-use card into a card token. Kashu.js calls this for you.

The card token object

FieldTypeAbout
idstringAn id that starts tok_.
objectstringAlways "card_token".
usedboolean
livemodeboolean
createdintegerUnix seconds.
expires_atintegerUnix seconds.
{
  "id": "tok_1a2B3c4D5e6F7g8H9i0J1k2L",
  "object": "card_token",
  "used": false,
  "livemode": false,
  "created": 1762473600,
  "expires_at": 1762473600
}

POST /v1/card_tokens

Turn the card form's single-use card into a card token. Kashu.js calls this for you.

Scope
card_tokens:write
Keys
Publishable, for the card form, or secret.
Idempotency-Key
Optional. Without one, Kashu makes one and returns it. See Idempotency.
Answers
201 with the Card token.

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
tokenstringRequiredWhat the card form's tokenizer returned. It is kept sealed and never shown again. Up to 4096 characters.

Errors

Examples

curl https://api.kashupay.com/v1/card_tokens \
  -H "Authorization: Bearer $KASHU_PUBLISHABLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"token":"single-use-card-from-the-form"}'
const cardToken = await kashu("POST", "/v1/card_tokens", {
  "token": "single-use-card-from-the-form"
});
console.log(cardToken.id);