> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reap.global/llms.txt
> Use this file to discover all available pages before exploring further.

# Encrypted Retrieval

> Retrieve card PAN, CVV, and expiry as an encrypted payload for PCI-compliant partners.

Retrieve the full card details (PAN, CVV, expiry date) as an encrypted payload that only you can decrypt. You generate the RSA key pair and register the public half with Reap; the details are encrypted with it and you decrypt them with the private half on your backend.

> [!WARNING]
>
> **Approval required.** This capability is enabled per program by Reap. Your system handles raw card data after decryption, so **your environment must be PCI DSS compliant**, and Reap enables it only after reviewing your compliance status. Projects without it receive `403 FEATURE_NOT_ENABLED`.
>
> You are responsible for the decrypted values: never store, log, cache, or transmit them beyond the immediate use.

Most integrations do not need this. To show card details to the cardholder, use [Secure Display](https://docs.reap.global/cards/card-details/secure-display.md) instead - see [Choosing an approach](https://docs.reap.global/cards/card-details/overview.md#choosing-an-approach).

***

## Prerequisites

* The capability is enabled for your project by Reap. Talk to your account manager to request it; Reap reviews your PCI DSS compliance status before enabling. Calls from projects without it receive `403 FEATURE_NOT_ENABLED`.
* You hold the RSA private key:
  * **Production**: you generate the key pair (RSA, 2048 bits or larger) and send **only the public key** to your implementation manager, who registers it against your program. The private key never leaves your systems and Reap never holds a copy.
  * **Sandbox**: a single, publicly documented key pair is shared by all sandbox programs (see [Sandbox keys](#sandbox-keys)). It provides no confidentiality, sandbox cards are test cards.

***

## Request

See [Reveal PAN](https://docs.reap.global/api-reference/cards/reveal-pan.md) for the full endpoint reference.

```bash theme={null}
curl -X POST https://sg.sandbox.api.reap.global/cards/{cardId}/reveal-pan \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Reap-Version: 2025-02-14"
```

No request body. The card must exist, must not be in a terminal or inactive status, and its account must be active.

***

## Response

```json theme={null}
{
	"encryptedData": "hEJ2X8QeZ...base64...",
	"encryption": "RSA_OAEP_SHA256"
}
```

| Field | Description |
| - | - |
| `encryptedData` | Base64-encoded ciphertext of the card details JSON. |
| `encryption` | Encryption scheme of `encryptedData`. Dispatch your decryption on this value; new schemes may be added later. |

`encryption` is one of:

| Value | Meaning |
| - | - |
| `RSA_OAEP_SHA256` | RSA-OAEP with SHA-256. Used for new keys. |
| `RSA_OAEP_SHA1` | RSA-OAEP with SHA-1. |

The scheme is a property of the public key registered for your program, so it stays fixed until that key is replaced. Read it from every response rather than hardcoding it, so a key rotation cannot break your decryption.

Decrypting `encryptedData` yields a JSON document:

```json theme={null}
{
	"pan": "5200000000001005",
	"cvv": "123",
	"expiryDate": "12/28"
}
```

***

## Decryption

Base64-decode `encryptedData`, then decrypt with your RSA private key using OAEP padding and the hash named by `encryption`: SHA-256 for `RSA_OAEP_SHA256`, SHA-1 for `RSA_OAEP_SHA1`.

> [tab] OpenSSL
>
> ```bash theme={null}
> # Use rsa_oaep_md:sha1 when encryption is RSA_OAEP_SHA1
> echo "$ENCRYPTED_DATA" | base64 -d > /tmp/blob.bin
> openssl pkeyutl -decrypt -inkey private-key.pem -in /tmp/blob.bin \
>   -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256
> ```

> [tab] Node.js
>
> ```javascript theme={null}
> import { privateDecrypt, constants } from 'node:crypto';
>
> // `response` is the parsed JSON body of POST /cards/{cardId}/reveal-pan,
> // `privateKeyPem` the private half of the key registered with Reap.
> const { encryptedData, encryption } = response;
>
> const OAEP_HASH_BY_SCHEME = {
> 	RSA_OAEP_SHA256: 'sha256',
> 	RSA_OAEP_SHA1: 'sha1',
> };
>
> const cardDetails = JSON.parse(
> 	privateDecrypt(
> 		{
> 			key: privateKeyPem,
> 			padding: constants.RSA_PKCS1_OAEP_PADDING,
> 			oaepHash: OAEP_HASH_BY_SCHEME[encryption],
> 		},
> 		Buffer.from(encryptedData, 'base64')
> 	).toString('utf8')
> );
> ```

> [!WARNING]
>
> Always decrypt on your backend. Never ship the private key to a browser or mobile client, and never proxy the decrypted details through systems outside your PCI scope.

***

## Errors

| Status | Code | Meaning |
| - | - | - |
| 403 | `FEATURE_NOT_ENABLED` | The capability is not enabled for your project. |
| 404 | `CARD_NOT_FOUND` | The card does not exist or has been deleted. |
| 400 | `CARD_OPERATION_NOT_ALLOWED` | The card status does not permit revealing its details. |
| 400 | `ACCOUNT_NOT_ACTIVE` | The account the card belongs to is not active. |

***

## Sandbox keys

All sandbox programs share one RSA key pair. Use this private key to decrypt sandbox responses:

```
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAzn88MgWItkxYeUt5jWeRBYIiQEUFxstgYJx8tYblZ55psnYd
HwhsyoPDwG6eq0r60WFSEeP2QFqV1qceYuDNM2RziIaMMGYgYlCPjgYaiMda3wlX
0w6pMv/5VaJA6N0jcb2m5xBC3I7XqKkP3l9AfL5xCtWN71wmVA/WXVZQ755pC3YE
A4IMoOcXs/+143HWZarX7wULhK55c8uAeA1q3ZmL7boLkzBZdMQM6Qlv9DDVcgUH
dahk4MiibmOubXrOk12KAyEXZlLH8Sc3qTDQnYP60ZOz95Ffly2c5/6/vLEBP99y
J9baXwgoBpQ7amA2o+X7v+eomV5CUItJITR0FwIDAQABAoIBAQDJvT529DcjOqU5
I0aGoobpJcEGnyhMlkb7PAcOZdLbj8Vdp809k0KN+3sUFj6HxMIUKws+FUNwjc9T
nYOvQEbZjard1+1AH5ZF1sTZERd9R558xij6NpmRDMlwIwtdNSa6qXlUxus7hYYl
7b1mGBLtjDTuS8LV9WYwvCRGndyGq6489o5OHzkHrCSabPXhBWai9LLgYkjrF1v4
mo4LCCqJEjaLAdqOlUXLiM1DrDWYlGUqJhdqYmcdl85BBQjisfOrQoET5yKb+afP
r8ZNyY3AFKhwmSl5wHNcu1aY7E8UCzLYBboXd1vaWsXzo28UrUEk6jAQFW3otd3r
bUM+RhqBAoGBAP1r8fhSTh/DBaCU3CGPX6p3tRNhfWbpMt6nYVvuDVVWb46BvSmJ
W2BHK4Me8W+Bx6TKFGFI9eBsa6mevAT1R4283c1ji2pMe6W9uuojAe2ei3nRIYIi
eHrmMGLv/3EVO8ctn9OyevQuBXjEIcaNoxkTNwgln4mKonVwJctkDIlXAoGBANCZ
EkO840ZRQV8rYjEYJrE7W6hP+7FdTc/O62Gx5g6Kv11M7WY0dGJ0V/deio5sgmmV
+Hi4SYQEzG30VZS8QIzaXFOO3etuIbobf7HW7wP3sCsY0kYZpxGiu30luO3OOnvs
MLZ6wkdaArxAn1CPpmC3VngPy09cUVjAmun4mPNBAoGADP0eXsrhJDGbtTpL+hBe
J9+Q0Vh60+554/2SOOL/nfMbLqOprVpT66BaM5M/bqapM+IDn2Tc7U7BSeVP37Uu
oK4gdCl4+M7Iu5r43I1EyQgKQAke/YuEv0/TBQ8l+YbMFI5bFb+dG6zMLP9od8PE
q0FX3bwH7EXFw90mosES/2sCgYBKlcDTGZHGDb2rEq8MUM9c5ZVzTA35sBvnZtwA
1YQlxPSBnsTvm2fV4DWnzFUMcb37lNUADRy0KKcT1Z5YDSujcVw7wESXLoy+p6Bz
7R8PMxv5fOmKiReUlbQmHjvOQ8PjlWMhjCk1K/j4aL7OJl7eDA/N5A/U83ReoJeD
exDtQQKBgQD51uzxVgwUZNLkJbXCp64TNqUXdvy8+PlhqD9zU9QSpdsf2F0xM4gX
eF2r3FU8Ps9WD6SijD715A4o4/xVV7vUXKn11nVqeEkaEkn3KIZpFQiEdWQR2J9e
vErFndT9x8gfBgnKj4o6XvqHHPOPoqAC2piaXkLMhQGupqF922bj+Q==
-----END RSA PRIVATE KEY-----
```

***

## Security obligations

* Decrypt only on PCI DSS compliant backend systems.
* Never log, persist, or cache the decrypted PAN, CVV, or expiry date.
* Never expose the private key or decrypted details to client-side code.
* Every retrieval is audited by Reap.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.