Gravv
/Docs
Search docs or ask a question⌘K
DocsAgent
ChangelogTry sandbox
Guides Cards Manage card PIN

Manage card PIN

Read a card's PIN encrypted to the cardholder's device, and set a new 4-digit PIN.

2 min read

Gravv gives every new card a random 4-digit PIN when it issues the card. This page explains how to show the PIN to the cardholder and how to set a new one.

A money example. Ada wants to pay 9.99 USD at a terminal that asks for a PIN. Your app shows her PIN on her phone, she changes it to 4821, and she pays.

Show the PIN

Get card PIN uses the same encryption as sensitive details:

1.
Send the device's public key in X-Client-Public-Key.
2.
Pass encrypted_key, nonce and ciphertext from the response to the device.
3.
Decrypt them on the device. The plaintext is {"pin":"4821"}.
get the PIN, encrypted to the device's key
curl --request GET \
--url https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b/pin \
--header 'Api-Key: <API_KEY>' \
--header 'X-Client-Public-Key: <base64 of the PEM public key>'

Set a PIN

Update card PIN is a PUT. Send 4 digits as a string. The API refuses repeated or sequential digits (1111, 1234).

set a new PIN
curl --request PUT \
--url https://api.gravv.xyz/v1/cards/a14ec356-f33d-4384-ba68-4d9bfa19765b/pin \
--header 'Api-Key: <API_KEY>' \
--header 'Content-Type: application/json' \
--data '
{
"card_pin": "4821"
}
'
answer
{
"data": "card pin updated successfully",
"error": null
}

What can go wrong

ResponseWhyFix
400 card pin update failedThe PIN is weak or invalid, or the card program returned an errorChoose another 4-digit PIN
400 json: cannot unmarshal number into Go struct field Body.card_pin of type stringYou sent the PIN as a numberSend "4821"
400 this card has no PIN set: set one with PUT /v1/cards/{card_id}/pin, or reissue — cards issued now are given a PIN at creationThe card is an older card with no PINSet a PIN
400 failed to get card pin from providerThe API cannot reveal the PIN right nowRetry later
400 card does not existThe card id is wrong. The API checks the id before the key headerCheck the id

Never ask a cardholder to type their PIN into a chat or a support form, and never log it.

Was this page helpful? Yes No