Skip to main content
Detokenization is in early access and available to selected merchant accounts. To request access, contact your Gr4vy account manager.
Detokenization returns the card number and expiration date of a card stored in the Gr4vy vault. Gr4vy encrypts the card details to a public key that you provide. Only a system that holds the matching private key can read them. Use detokenization when your own PCI-compliant systems need the card details of a stored card. If you only need to send card data to a third-party endpoint, use Vault Forwarding instead. Vault Forwarding sends the card data to the endpoint directly, so it never reaches your systems.

Prerequisites

Gr4vy enables detokenization for each merchant account. To get started, contact your Gr4vy account manager and provide the following:
  • Attestation of Compliance: A current PCI DSS Attestation of Compliance (AoC) for the environment that decrypts the card data.
  • Public key: An RSA public key in PEM format. The key must be at least 2048 bits, and 3072 bits is recommended. Elliptic curve (EC) keys aren’t supported.
You and Gr4vy also agree on a key ID. Gr4vy sets it as the kid header of every encrypted payload, so you can select the matching private key. Gr4vy records an expiry date for your AoC and for your public key. After either date passes, requests fail with a 403 error. Send Gr4vy a renewed AoC or a new public key before the current one expires. You can’t upload or replace the public key through the API.

Grant access to an API key

The endpoint requires the payment-methods.detokenization.read scope. Assign the Detokenization role to the API key that calls it. This role grants that scope and nothing else. For more information, see The Detokenization role. Only API keys can detokenize a card. Requests from a dashboard session are refused, even for an Administrator.

Request

Send a POST request with no body. Set the X-Gr4vy-Merchant-Account-Id header to the merchant account that stores the payment method.
The private key in these examples is the key of your Gr4vy API key pair, which signs the request. It isn’t the private key that decrypts the payload.

Response

A successful request returns the card details as an encrypted payload.

Decrypt the payload

The protected header of the JWE contains these values. Decrypt the payload with the private key that matches your public key. Accept only the RSA-OAEP-256 and A256GCM algorithms. The iat header isn’t a registered JWE header, so some libraries reject it unless you allow it.
The decrypted payload is a JSON object.
Check that merchant_account_id and payment_method_id match the request before you use the card details.

Errors

Rate limits

Gr4vy limits detokenization requests for each merchant account over a moving 60-second window. The default limit is 300 requests in each window. Gr4vy can set a different limit for your merchant account. When you reach the limit, the API returns a 429 error with a Retry-After header of 60. Wait that number of seconds before you retry. Refused requests also count toward the limit, for example 400 and 404 errors. Requests that return a 429 error don’t count.

Security

  • One card for each request: Each request returns one card. There is no bulk endpoint.
  • No security code: The payload never contains the card security code (CVV).
  • No network tokens: The payload contains the card number only, never a network token or cryptogram.
  • Keep the private key in your PCI environment: Gr4vy only holds your public key. Store the private key in the environment that your AoC covers, and decrypt the payload only there.
  • Use a dedicated API key: Give the Detokenization role to a key that only your PCI-compliant systems use. This lets you revoke card access without affecting your other integrations.

API reference

Detokenize a payment method