Prerequisites
Before you begin, ensure that you’ve:- Obtained a Circle Developer API key from the Circle Console.
- Completed the
Build a Wallet App tutorial
with the PIN method, which sets up a user-controlled wallet, stores the user’s
userId, and configures the user’s security questions. - Integrated a user-controlled wallet client-side SDK in your app to walk the user through the recovery challenge: Web SDK, iOS SDK, Android SDK, or React Native SDK.
- Installed the user-controlled wallet server-side SDK in your backend to create the recovery challenge: Node.js or Python.
Steps
Acquire a session token
Request a 60-minute session token for the user. The token authorizes the
recovery challenge later in the flow.
Initialize the recovery challenge
Use the Include an
userToken to create a recovery challenge. The SDK returns a
challengeId that your client-side SDK uses to walk the user through answering
their security questions and setting a new PIN.idempotencyKey (a UUID) on the call to safely retry the request
without creating duplicate challenges. See
Idempotent requests for details on
idempotency key usage.Have the user answer their security questions
Pass the
userToken, encryptionKey, and challengeId to your client-side
SDK. The SDK presents the recovery UI to the user, who:- Answers their pre-set security questions.
- Enters and confirms a new PIN.
Check the challenge status
Confirm the recovery completed. Use webhooks (push) or polling (pull) to detect
when the challenge reaches a terminal status: For a full list of possible statuses, see
Asynchronous States and Statuses.
COMPLETED, FAILED, or
EXPIRED. A COMPLETED status means the account was successfully recovered and
the new PIN is active.- Webhook
- Polling
Subscribe to user challenge notifications and listen for the event matching your
For webhook setup, see Webhook Notifications.
challengeId. The notification includes the challenge status and type
(RESTORE_PIN for account recovery).Webhook notification
Error handling
Handle these common failure cases when integrating account recovery:- Expired session token (error code
155104): TheuserTokenfrom Step 1 expires after 60 minutes. If you get this error, request a new session token and retry. - Incorrect security answers (error code
155115): The user’s answers must match what they set during sign-up. After three incorrect attempts, recovery locks for 30 minutes (155120). - Security questions not set (error code
155111): The user must have set security questions during sign-up to use account recovery. If they haven’t, recovery isn’t available. - Security questions already used: Security questions can be set only once
during sign-up and can’t be reset (
155108). If the user can’t remember their answers, no recovery path exists.