Skip to main content
Your backend is the bridge between the widget and the Kravata Stack API. It does three things:
  1. Gives your app a widget session when the user opens the widget.
  2. Receives the user.accepted_terms webhook.
  3. Registers the user with their KYC data.
Steps 2 and 3 call the Stack API with an access token. Get it with your apiKey and secretKey as described in Authentication.

1. Issue a widget session

Expose an endpoint in your backend that your app calls right before opening the widget. It returns the sharedKey and clientId from your environment variables and a new nonce.
Node.js (Express)
Python (FastAPI)
The nonce protects against replay attacks. Generate it on your server for every widget session and never reuse it. Protect this endpoint with your own user authentication so only logged-in users can open the widget.

2. Receive the terms acceptance webhook

When the user accepts the Terms and Conditions inside the widget, Kravata calls your webhook with the user.accepted_terms event. Use it as the signal to register the user (step 3).
In production, Kravata registers this webhook for you during onboarding. In test you can register it yourself with Register Webhook Endpoint. You only need to do it once per environment.

Payload

Handle the event

Node.js (Express)
Answer 2xx quickly and do the registration asynchronously. Deliveries can be retried, so make the handler idempotent. See Best practices.

3. Register the user

Call User Registration with the user’s KYC data, the x-integration-register header, and the same ID you passed to the SDK as external_user_id.
The body field that carries your user ID depends on the field mapping of your integration: external_user_id by default. If Kravata configured your integration with another name, such as user_id, send it under that name. Either way, Kravata stores it as EXTERNAL_USER_ID.
The user_id in the response is Kravata’s internal ID for the user, not yours. Store it next to your own ID: the Stack API uses it in every user endpoint (accounts, wallets, operations). See Users for the full field list, statuses and the KYC review.

4. Follow the user’s status

After registration the user is reviewed automatically. Subscribe to user.updated to know the result: The complete list of statuses is in Users.