Before you call the API
The Direct Vault API differs from the rest of the Payrails API in two ways. Check both before you send your first request.
To get access:
- Ask your Payrails account manager to enable the capability on your workspace. Enablement follows a confirmed PCI AOC and a compliance review.
- Configure mTLS. The Direct Vault API uses the same client certificates as the Payrails API, so you obtain and rotate no second certificate. See mTLS configuration.
Get a Vault access token
Exchange your Payrails access token once for a Vault access token, then reuse that token until it expires. Call Request a Vault access token on the Payrails API host. The request body is empty. Your Payrails access token goes in theAuthorization header and must carry the vault scopes vaultaccesstokens:create:tokenize, vaultaccesstokens:create:detokenize, or both.
expires_in is the lifetime in seconds. Store the token and reuse it for that long instead of requesting a new one per call. Request a new one when it expires, or when a call returns 401.
The Vault access token grants only what your Payrails token permitted, and only the Vault host accepts it. If your credentials allow tokenization but not detokenization, a call to /records/detokenize returns 403.
Tokenize records
Tokenize records stores one or more records and returns an alias for every field it stored. Send it to the Vault host with the Vault access token. A record has atype and a fields object keyed by field type:
Each field is an object with a
value, not a bare string.
id and the alias values. They are how you address the data later, and neither is sensitive.
The vault stores
securityCode and cryptogram as volatile fields. They expire according to your vault configuration, which a request can’t override. Under PCI DSS 3.3.1, you must delete the security code yourself once authorization completes. See Records, Aliases and Instruments.Detokenize records and aliases
Detokenize records and aliases reveals stored data in clear text. Send it to the Vault host with the Vault access token. Each item carries exactly one key, and one request mixes all three:Match results by their keys, not by position. Unlike tokenization, detokenized items can come back in a different order than you sent them. Every result, including a failed one, echoes the key you addressed it by.
Batch limits
Both operations accept at most 50 items per request. The API refuses a request over the limit with413 before it stores or reveals anything. The API applies nothing partially, so split the batch and send it again. Retrying the same oversized request doesn’t help. The body size limit is a second, independent check and also returns 413.
Errors
A batch isn’t a transaction. One item failing doesn’t fail the others. The call returns200, successful entries carry their data, and failed entries carry an error object instead. For tokenization, the vault stores the records that succeeded.
200 as “everything worked.” Walk the array and check each entry for error. The API reference lists the per-item codes for each operation: Tokenize records and Detokenize records and aliases.
Some conditions fail the whole call. The body then carries an errors array and no records or items:
Every error carries an
id. Quote it when you contact support. It identifies the exact failure in the Payrails logs. The shape is the standard Payrails error object.
Examples
The examples assumeVAULT_TOKEN holds a Vault access token from POST /token/auth, and VAULT_HOST holds your Payrails Vault host, which Payrails issues after confirming your PCI AOC. They don’t use the Payrails API host.
- Single round trip
- Batch
- Batch with a failing item
- All three addressing modes
Store one card, then read it back by its record id.