Storing a network token
A card can be stored as a network token, a token issued by the card scheme in place of the card number. Network tokens are currently supported for Visa and Mastercard cards.
To create a network token vault instrument, set type to network_token and provide a customer.id that identifies your customer. You can then either:
- provide the
carddetails, or - provide the
instrument_idof an existing, activecardvault instrument to create a network token from the card already stored in the vault.
A successful request returns a synchronous response with a pending status while we request the network token from the card scheme:
- Once the network token has been issued, the vault instrument's status becomes
activeand aninstrument_activatedwebhook is sent. The vault instrument can then be used to process payments, as described here. - If the network token cannot be issued, the vault instrument's status becomes
failedand aninstrument_failedwebhook is sent. The webhook and the vault instrument both include anerrorsarray with acodeandreasonexplaining why. The codes are listed under Network tokens.
While a network token vault instrument is pending or failed, it cannot be suspended, reactivated or have its card expiry updated. Deleting a network token vault instrument also deletes its network token.
The card scheme can also change a network token after it has been issued, for example when the card is reported lost or renewed by the issuer. The vault instrument follows these changes: it is suspended, reactivated, updated or deleted, and the usual vault webhooks are sent.
Details on required fields and validation can be found in our Open API specification.
- Production
- Sandbox
POST https://api.paytently.io/instruments
POST https://sandbox.api.paytently.io/instruments
Request:
- Card details
- Existing vault instrument
curl --location 'https://sandbox.api.paytently.io/instruments'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer token_here'
--data-raw '{
"type": "network_token",
"card": {
"number": "5120350100064594",
"expiry_month": "06",
"expiry_year": "28",
"name_on_card": "Bob Bobinson"
},
"customer": {
"id": "customer123"
},
"urls": {
"webhook": "https://example.com/webhooks"
}
}'
curl --location 'https://sandbox.api.paytently.io/instruments'
--header 'Content-Type: application/json'
--header 'Authorization: Bearer token_here'
--data-raw '{
"type": "network_token",
"instrument_id": "ins_12345",
"customer": {
"id": "customer123"
},
"urls": {
"webhook": "https://example.com/webhooks"
}
}'
Response:
- 202
- 422
- 500
{
"id": "ins_67890",
"status": "pending"
}
{
"trace_id": "12345",
"errors": [
{
"property": "instrument_id",
"code": "instrument_suspended",
"reason": "the instrument is suspended",
"docs": "https://docs.v2.paytently.io/api/reference"
}
]
}
{
"title": "Server error",
"status": 500,
"trace_id": "12345"
}
Errors:
| Code | Description |
|---|---|
customer_required | customer must be provided for a network token. |
customer_id_required | customer.id must be provided for a network token. |
customer_id_invalid | customer.id must be between 1 and 64 characters. |
card_required | card must be provided when instrument_id is not. |
card_not_allowed | card cannot be provided with instrument_id. |
scheme_unsupported | The card scheme is not supported for network tokens. |
network_tokens_not_configured | Your account is not set up for network tokens on this card scheme. |
instrument_not_found | The vault instrument in instrument_id could not be found. |
instrument_not_a_card | The vault instrument in instrument_id is not a card vault instrument. |
instrument_suspended | The vault instrument in instrument_id is suspended. |
instrument_expired | The vault instrument in instrument_id has expired. |