Skip to main content
Card PIN endpoints never accept or return plaintext digits. Each request uses a session key you generate locally:
  • sessionKey: raw 32-character hex string (16 random bytes). Save this on every request. You need it to decrypt encryptedPin, encryptedPan, or encryptedCvc from API responses. The API never returns it.
  • encryptedSessionId: RSA-OAEP (SHA-1) encryption of the session key; send this as the SessionId request header. Do not use sessionKey as the header value.
Fetch your business RSA public key (PEM file) from GET /business/pin-crypto-key before your first PIN operation.

Generate a session key and ID

generate-session.js

Save the session key

Generate a new sessionKey for each PIN or secrets request. Before you call the API:
  1. Generate sessionKey (32-character hex).
  2. Derive encryptedSessionId from that key (RSA encrypt with your business public key).
  3. Store sessionKey in memory (or your secure client state) until you have finished decrypting the response.
The SessionId header alone is not enough to decrypt responses unless you hold the matching business private key and reverse the RSA step. In normal integrations, keep the same sessionKey you generated for that request and pass it to your AES decrypt step. If you use the repo helper scripts:
Save both sessionKey and sessionId from the output. For set PIN, run yarn card-crypto:encrypt-pin (it returns the same fields plus iv and data for the request body).

Encrypt the PIN before submission

The API accepts 4-digit PINs on set. Format the PIN as a 16-character block before AES encryption - for example, “6784” becomes “246784FFFFFFFFFF”.
encryptPin.js
Submit with the SessionId header:
POST /cards/CARD_ID/pin

Decrypt the PIN when retrieved

Generate a new sessionKey and encryptedSessionId for each GET request. Decrypt with the sessionKey from that same request, not the SessionId header string, and not a key from a different encrypt run. The response encryptedPin.iv and encryptedPin.data are encrypted with the session key whose RSA-wrapped form you sent as SessionId.
GET /cards/CARD_ID/pin
Get PIN response
decryptPin.js