Card tokens API
Use this API to inspect and change the card token used by a recurring payment subscription.
Prerequisites
Before using this API you must obtain an access token. Follow the Authentication guide.
Step 1: Obtain access token
Make a POST request to get the access token as described in the Authentication guide.
Retrieve active card token
Returns the card token currently used by a payment subscription.
curl --location 'BASE_URL/api/recurring/tokens/{payment_subscription_id}/active' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access_token>'
Path parameters:
| Field | Required | Description |
|---|---|---|
payment_subscription_id | yes | Payment subscription ID. |
Example successful response:
{
"id": "card-token-123",
"user_id": "customer-123",
"masked_card_number": "444433******1111",
"data": {
"initial_transaction_id": "transaction-123",
"token": "provider-token-123"
}
}
If no active card token is available, the response is an empty JSON object:
{}
List available card tokens
Returns other available card tokens for the subscription customer. The currently active card token is excluded from the response.
curl --location 'BASE_URL/api/recurring/tokens/{payment_subscription_id}' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access_token>'
Path parameters:
| Field | Required | Description |
|---|---|---|
payment_subscription_id | yes | Payment subscription ID. |
Example successful response:
[
{
"id": "card-token-456",
"user_id": "customer-123",
"masked_card_number": "555544******2222",
"data": {
"initial_transaction_id": "transaction-456",
"token": "provider-token-456"
}
}
]
Set active card token
Sets another customer card token as the active token for the subscription. The card token must belong to the same customer as the subscription.
curl --location --request PUT 'BASE_URL/api/recurring/tokens/{payment_subscription_id}' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access_token>' \
--data-raw '{
"id": "card-token-456"
}'
Path parameters:
| Field | Required | Description |
|---|---|---|
payment_subscription_id | yes | Payment subscription ID. |
Request fields:
| Field | Required | Description |
|---|---|---|
id | yes | Customer card token ID to set as active for the subscription. |
The response body contains the card token that was set as active.
Example successful response:
{
"id": "card-token-456",
"user_id": "customer-123",
"masked_card_number": "555544******2222",
"data": {
"initial_transaction_id": "transaction-456",
"token": "provider-token-456"
}
}
Error responses
Unauthorized - when <access_token> is missing or invalid API’s response will be 401 Unauthorized with empty response body.
Not found - when the payment subscription or requested card token does not exist, API’s response will be 404 Not Found.