Preparing the proof request
Create a request for a proof generation on the backend
Quickstart
This is the simplest version of creating a proof request.
Import the library
Setup a request on the backend
- You can get the
APP_IDandAPP_SECRETusing this guide - The
PROVIDER_IDis the proof you want the user to generate. You can see all the available providers here.
Send back the proof request object to the frontend
Sample implementation in Next.js
Advance Options
We recommend most, if not all of the following to be set for most production usecases :
Set Context
Set Address & Message as context
You can set context to the proof request that helps identify the request when you receive it back in the callback once the proof is generated.
address: this is usually a unique identifier for the user. This could be an email address, a wallet address, or just a session id generated on your systemmessage: this is an open field where you can add any other information that you want passed around from the build request to the callback endpoint. You can stringify jsons here for convenience.
Set JSON Context
A JSON serializable object can also be set as context. For doing this, use setJsonContext method.
[!WARNING] Both setContext and setJsonContext overwrite each other. Each call replaces the existing context.
Set Callback URLs
Success Callback
Set a backend callback URL where Reclaim Protocol will send proofs directly after verification. In this case proofs are sent only to the custom URL instead of the Reclaim backend. This enables secure backend proof processing without relying on your frontend to upload the proof.
This verification session's id will also be present in X-Reclaim-Session-Id header of the request.
By default, proofs are sent as HTTP POST with Content-Type as application/x-www-form-urlencoded. Pass function argument jsonProofResponse as true to send proofs with Content-Type as application/json.
You can see the data structure of the proofs you will receive here.
[!Note] If you are using
reclaimProofRequest.startSessionafter setting a custom success callback URL, then the proofs will be sent to the custom URL instead of the Reclaim backend. Because of this, the startSessiononSuccesscallback will be invoked with an empty array ([]) instead of the proof data, as the proof is not available to the SDK in this flow.
Cancel Callback
The easiest way to handle cancellations by user is to set up a cancel callback. This allows your application to react immediately when a user's verification session terminates.
If the user cancels the session midway or after error, Reclaim will send a POST request to you on the cancel callback URL with details. This verification session's id will be present in X-Reclaim-Session-Id header of the request.
Following is the data format which is sent as an HTTP POST request to the url with Content-Type: application/json:
What triggers cancel callback?
Following are some exceptions that happen when user presses a button to cancel in UI or provider custom injection script causes a cancellation by calling Reclaim.reportProviderError in browser.
Exception Name (type field) | Description |
|---|---|
ReclaimVerificationAbortedException | User cancelled the verification (e.g., tapped on cancel or verify another way button). |
ReclaimVerificationProviderScriptException | The provider script encountered an error (e.g., login failed, invalid account used). |
Other errors (such as network timeouts or internal exceptions) may also trigger this callback if auto submit is enabled. In any case, you can always find the complete list of errors by fetching analytics events for the session.
[!TIP] Best Practice: When using
setAppCallbackUrland/orsetCancelCallbackUrl, your backend receives the proof or cancellation details directly. We recommend your backend notifies the frontend (e.g. via WebSockets, SSE, or polling) to stop the verification process and handle the appropriate success/failure action. Do not rely completely onstartSessioncallbacks on the frontend when using these backend callbacks.
Redirect after proof generation or cancellation
Success Redirect URL
If you want to redirect the user after generating the proof to a specific webpage or app, you can do so using setRedirectUrl.
When you should use this:
- User is on a desktop, scans QR code to generate the proof. After the proof generation is complete you want to show a custom success message on their mobile device instead of the Reclaim Protocol's default success message. You can redirect them to a webpage.
- User is on a mobile, taps a button to generate the proof. After the proof generation is complete, you typically want to redirect the user to the page that must be shown after the proof generation is complete. If you are using
onSuccess, the user will have to close the proof generation success banner and go back to the browser to continue. We recommend using a redirect url to take the user to the next step in the business logic. On this step, render a page depending on whether the proof was correctly verified.
Redirection with body:
- url: The URL where users should be redirected after successful proof generation.
- method (optional): The redirection method to use. Allowed options:
GET(default) andPOST. Note:POSTform redirection is only supported in In-Browser SDK. - body (optional): List of name-value pairs to be sent as the body of the form request.
- When
methodisPOST,bodyis sent withapplication/x-www-form-urlencodedcontent type. - When
methodisGET, ifbodyis set, it is sent as query parameters. Note: Sendingbodyon redirection is only supported in In-Browser SDK.
- When
Redirection happens after success callback is invoked by reclaim.
Cancel Redirect Url
Set a custom URL to redirect users when their verification process is cancelled. This allows your application to react immediately when a user's verification session terminates.
Redirection with body:
- url: The URL where users should be redirected after an error which aborts the verification process.
- method (optional): The redirection method to use. Allowed options:
GET(default) andPOST. Note:POSTform redirection is only supported in In-Browser SDK. - body (optional): List of name-value pairs to be sent as the body of the form request.
- When
methodisPOST,bodyis sent withapplication/x-www-form-urlencodedcontent type. - When
methodisGET, ifbodyis set, it is sent as query parameters. Note: Sendingbodyon redirection is only supported in In-Browser SDK.
- When
Redirection happens after cancel callback is invoked by reclaim. See What triggers a Cancel Callback for more details.
Set Parameters
If you already know what the value of the extracted parameter is supposed to be, you can set that using setParams.
For example, if you know that the user's name before hand - and you want them to prove something from a website and you need the name to match exactly, you should use set the name in the params. Be sure to use the same key as the parameter name on the Provider you are using.
If the extracted parameter doesn't match the set parameter, the proof generation will fail.
Add additional metadata for verification client
Additional metadata to pass to the verification client. This can be used to customize the client experience, such as customizing themes or UI by passing context-specific information. The keys and values must be strings. For most clients, this is not required and goes unused.
Set preferred locale for verification client
You can change the language for the UI seen by User during verification by setting the preferredLocale parameter in the initialization options.
This is used to select a user's language and formatting preferences in the verification journey.
The value of this field must be a Unicode Language Identifier (i.e. without Locale extensions), except variants are not supported.
Locale values are expected to be canonicalized according to the "preferred value" entries in the IANA Language Subtag Registry.
For example, he, and iw are equal and both have the languageCode he, because iw is a deprecated language subtag that was replaced by the subtag he.
Defaults to the browser's locale if available, otherwise English (en).
Using the in-browser SDK
In-Browser SDK use is available only for users on a premium enterprise plan. Please contact support for more details.
If you don't want to use the in-browser SDK, the users will be asked to install the Reclaim Protocol App/Appclip. You can disable by removing this configuration from the above snipped :