Skip to main content
Didit adds identity verification (KYC), age verification and AML screening to an app built in Lovable with two server-side functions: one creates a Didit verification session and returns its link, the other receives Didit’s signed webhook and saves the result for that user in your database. You can also connect the Didit MCP server to Lovable’s chat, so Lovable’s agent can create workflows, test sessions and webhook destinations in your Didit account while it builds. This page gives a prompt to paste into Lovable for each step and the code that prompt should produce, so you can check what Lovable wrote.

How it works

Everything that touches your Didit API key runs on the server, in Supabase Edge Functions (the backend of a Lovable Cloud or Supabase-connected project). The browser never sees the key.
  1. A signed-in user clicks Verify my identity. The frontend calls the didit-create-session function.
  2. The function calls POST /v3/session/ with your workflow ID, the user’s ID as vendor_data and a callback URL, and returns the session’s url. If the user’s last session is still unfinished, it returns that session’s link instead.
  3. The frontend sends the user to that url. Didit’s hosted page runs the checks of your workflow, then redirects the user to the callback URL.
  4. Didit sends a status.updated webhook to the didit-webhook function. The function verifies the signature, reads the session’s current decision from Didit and saves its status (Approved, Declined, In Review and so on) and the environment (live or sandbox) in your user_verifications table, and only then answers 200.
  5. Your app reads the status from its own database. It never trusts the status in the redirect URL.

Before you start

1

Create a Didit account and a workflow

Sign up at business.didit.me. Under Workflows, create a workflow from a template and copy its workflow ID. The workflow decides what the user goes through (see Choose what to verify).
2

Copy an API key

Under Developers, then API keys, copy an API key for the application. See API keys to give it only the access it needs.
3

Have users and a backend in your Lovable project

Your project needs sign-in (so each user has an ID) and a backend that runs Edge Functions. Lovable Cloud gives you both; a connected Supabase project works the same way.

Choose what to verify

You pick the checks by picking the workflow. The code on this page does not change; only the workflow ID does. See Workflows for every template and feature, and Pricing for what each check costs.

Part 1: Add Didit to your Lovable app

Step 1: Store your secrets

Add these as secrets of your project (in Lovable, ask it to add a secret, or add it in your backend’s secrets settings). Never put them in frontend code or in a VITE_ variable: anything in the frontend is public. Paste this into Lovable:

Step 2: Create the verification session

Paste this into Lovable:
The function should look like this:
supabase/functions/didit-create-session/index.ts
The button:
The completion page waits for the webhook, because the user can arrive before it does:
While the user’s tracked session is unfinished (Not Started, In Progress, In Review, Resubmitted), the function returns that session’s link and creates no new one, so a user waiting on your team’s review stays on the session being reviewed. It reads the status from Didit, because the webhook may not have arrived yet. It creates a new session only after Declined, Abandoned, Expired, Kyc Expired or a sandbox approval, and answers 409 after a live approval. For a User Verification (KYC) workflow, Didit also returns the existing unfinished session when two calls race, so a double click does not create two sessions; a Business Verification workflow creates a new session on every call. If your application restricts allowed domains, the callback must be on one of them. See Create session.
Prefer to keep the user inside your app? Open the same url in Didit’s JavaScript SDK modal instead of redirecting.

Step 3: Receive the result

Paste this into Lovable:
The function should look like this. It follows the signature verification of the Webhooks page with X-Signature, the HMAC of the exact bytes Didit sent. X-Signature-V2 exists for frameworks that re-encode the body before your code sees it; an Edge Function reads the untouched bytes with req.arrayBuffer(), so it needs no canonical JSON, which would have to reproduce Didit’s own number formatting byte for byte.
supabase/functions/didit-webhook/index.ts
supabase/config.toml
Turning off JWT verification is right only for this function: Didit cannot send a Supabase token, so the HMAC signature is what proves the request came from Didit. Keep JWT verification on for didit-create-session.
What the code protects against:
  • Late or repeated deliveries. Didit does not guarantee delivery order and retries a failed delivery. The function treats each delivery as a signal and saves the session’s current decision from GET /v3/session/{session_id}/decision/, as the Webhooks page recommends, so a late delivery does not bring back the status it carried.
  • Other sessions. The update matches the user’s tracked session_id, so a result of an earlier session never replaces the one the user started last. Starting a new session resets the row to Not Started.
  • Replays. X-Timestamp is not signed itself, so the function also requires the signed body’s timestamp to equal it before it applies the 5-minute window.
  • Lost decisions. The function answers 200 only after the decision is saved. A failed save answers 500, and Didit retries twice over about five minutes; after that, resend the delivery from the destination’s Deliveries tab.
For the full payload, every status value and the other events, see Webhooks.

Step 4: Register the webhook in Didit

  1. In the Business Console, go to Developers, then Webhooks, and add a destination.
  2. Set its URL to your function: https://<your-project-ref>.supabase.co/functions/v1/didit-webhook.
  3. Subscribe it to status.updated.
  4. Copy its signing secret into the DIDIT_WEBHOOK_SECRET secret.
  5. Send a test webhook from the destination. The function answers 200, and because test deliveries carry X-Didit-Test-Webhook: true it writes nothing.
You can also create the destination with POST /v3/webhook/destinations/, or ask Lovable’s agent to do it through the Didit MCP server (Part 2).

Step 5: Test end to end

  1. Use a sandbox application while you build, so no real checks are charged. Its API key, workflow ID and webhook destination secret are the values of your secrets for now.
  2. Sign in to your app, click Verify my identity and finish the hosted flow.
  3. Back on /verification-complete, the page shows Approved, Declined or In Review as soon as the webhook has arrived, labelled as a test result because its environment is sandbox. A session in In Review changes again when your team decides it in the console, and the webhook updates the row again; until then, the user sees that their verification is being reviewed.
  4. Gate the features that need a verified user on status = 'Approved' and environment = 'live', read on the server or through a row-level security policy, not only in the frontend. A sandbox approval never unlocks them.

Step 6: Go live

Sandbox and live are separate applications, each with its own API key, workflows and webhook destinations, so switch all three together:
  1. In your live application, publish the workflow you tested and copy its workflow ID.
  2. Copy an API key of the live application.
  3. Add a webhook destination in the live application with the same didit-webhook URL, subscribed to status.updated, and copy its signing secret.
  4. Replace DIDIT_API_KEY, DIDIT_WORKFLOW_ID and DIDIT_WEBHOOK_SECRET with these three values at the same time, and redeploy both functions. A live key cannot open a session on a sandbox workflow, and a sandbox destination never receives live decisions.
  5. Clear the sandbox results, so a test session left In Review does not keep its user from starting a live one:
    Each user then verifies once more in a live session: a sandbox approval does not count, and the new session starts at Not Started.

Part 2: Use Didit in the Lovable chat

Lovable’s agent can use custom MCP servers; see Lovable’s Custom MCP servers page for who can add one. Add the hosted Didit MCP server and Lovable’s agent can read and change your Didit account while you build: create the workflow, register the webhook destination, start a test session.
An MCP connection gives context to Lovable’s chat only. It is never part of your published app, which talks to Didit through the functions in Part 1.
  1. In Lovable, open Connectors, select Add custom, and choose MCP server. If MCP server is grayed out, a workspace admin has turned off the Custom MCP setting.
  2. Server name: Didit.
  3. Server URL: https://mcp.didit.me/mcp.
  4. Keep OAuth as the authentication option and click Add & authorize.
  5. Complete Log in with Didit in the window that opens and approve the organizations Lovable may use.
The server then appears in your chat connectors. The connection is personal: each teammate who wants it connects it themselves.
No API key needed. With OAuth the server acts as you, in the organizations you approve at sign-in, with your role’s permissions. To connect with an application API key instead, choose Bearer token or API key, paste the key and click Add server: the server accepts it as a bearer token. See Authentication.

Check that it works

In a Lovable chat, ask:
Then put it to work:
  • “Create a sandbox KYC workflow with ID verification, liveness and face match, and give me its workflow ID.”
  • “Register a Didit webhook destination for status.updated pointing at my didit-webhook Edge Function, and tell me where to find its signing secret.”
  • “Create a test session for my user ID and give me the verification link.”
Lovable runs read-only tools without asking and asks for your approval before any tool that changes something.

Troubleshooting

  • Sign-in fails or loops. Log in at business.didit.me in the same browser first, then click Add & authorize again.
  • A tool answers with missing_scope. Your role in that organization lacks the permission. See roles and permissions.
  • The webhook function returns 401. Check that DIDIT_WEBHOOK_SECRET is the secret of the destination that sends the webhook, that the function is deployed with verify_jwt = false, and that it reads the body with req.arrayBuffer() before anything parses or re-encodes it. A 401 on the timestamp check means the delivery is more than five minutes old, or the server clock is off.
  • didit-create-session returns 409. Didit reports the user’s tracked session as approved in live. The page re-reads the row, which the webhook updates.
  • didit-create-session returns 502. Didit could not be reached, or an unfinished session has no link to resume. Nothing new is created; try again.
  • The session request returns 400 on callback. Add your app’s address to the application’s allowed domains, or check APP_URL.

Next steps

Webhooks

Every event, payload field and signature header.

Create session

All request fields, such as expected details and metadata.

MCP tools reference

Everything Lovable’s agent can call, tool by tool.

Pricing

What each check in your workflow costs.
Last modified on December 4, 2026