- sessionKey: raw 32-character hex string (16 random bytes). Save this on every request. You need it to decrypt
encryptedPin,encryptedPan, orencryptedCvcfrom API responses. The API never returns it. - encryptedSessionId: RSA-OAEP (SHA-1) encryption of the session key; send this as the
SessionIdrequest header. Do not usesessionKeyas the header value.
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 newsessionKey for each PIN or secrets request. Before you call the API:
- Generate
sessionKey(32-character hex). - Derive
encryptedSessionIdfrom that key (RSA encrypt with your business public key). - Store
sessionKeyin memory (or your secure client state) until you have finished decrypting the response.
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:
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
POST /cards/CARD_ID/pin
Decrypt the PIN when retrieved
Generate a newsessionKey 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