> ## Documentation Index
> Fetch the complete documentation index at: https://docs.didit.me/llms.txt
> Use this file to discover all available pages before exploring further.

# Add KYC to your Lovable app with Didit

> Add Didit KYC, age verification or AML screening to a Lovable app with two Supabase Edge Functions and copy-paste prompts, and use Didit MCP in Lovable chat.

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/`](https://docs.didit.me/sessions-api/create-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](https://docs.didit.me/integration/webhooks.md) 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](https://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](#choose-what-to-verify)).

**2. Copy an API key**

Under **Developers**, then **API keys**, copy an API key for the application. See [API keys](https://docs.didit.me/console/api-keys.md) 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.

| You need | Workflow | What the user does |
| - | - | - |
| Full KYC | **KYC** template with [ID verification](https://docs.didit.me/core-technology/id-verification/overview.md), [liveness](https://docs.didit.me/core-technology/liveness/overview.md) and [face match](https://docs.didit.me/core-technology/face-match/overview.md) | Scans an ID document and takes a live selfie that is matched to the document photo |
| Age verification | **Adaptive Age Verification** template ([age estimation](https://docs.didit.me/core-technology/age-estimation/overview.md)) | Takes a selfie; only users near your age threshold are asked for an ID document |
| KYC with AML | **KYC** template with [AML screening](https://docs.didit.me/core-technology/aml-screening/overview.md) added | Same as full KYC; Didit also screens the person against sanctions, PEP and adverse media lists |

See [Workflows](https://docs.didit.me/console/workflows.md) for every template and feature, and [Pricing](https://docs.didit.me/getting-started/pricing.md) 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.

| Secret | Value |
| - | - |
| `DIDIT_API_KEY` | The API key from **Developers > API keys**. Both functions use it |
| `DIDIT_WORKFLOW_ID` | The workflow ID from **Workflows** |
| `DIDIT_WEBHOOK_SECRET` | The signing secret of your webhook destination (you create it in [Step 4](#step-4-register-the-webhook-in-didit)) |
| `APP_URL` | Your app's public address, for example `https://your-app.lovable.app` |

Paste this into Lovable:

```text theme={null}
Add four backend secrets to this project: DIDIT_API_KEY, DIDIT_WORKFLOW_ID, DIDIT_WEBHOOK_SECRET and APP_URL. Ask me for their values. They must only ever be read inside Edge Functions with Deno.env.get, never in frontend code.
```

### Step 2: Create the verification session

Paste this into Lovable:

````text theme={null}
Add identity verification with Didit.

1. Database: run this SQL migration exactly as written.

```sql
-- One row per user who started a verification. Users read their own row; only the two functions below write it.
create table public.user_verifications (
  user_id uuid primary key references auth.users (id) on delete cascade,
  session_id text not null,        -- the Didit session this user started last
  status text not null default 'Not Started',
  environment text,                -- 'live' or 'sandbox', as Didit reports it
  updated_at timestamptz not null default now()
);
alter table public.user_verifications enable row level security;
create policy "Users read their own verification" on public.user_verifications
  for select to authenticated using ((select auth.uid()) = user_id);
-- Data API access: the signed-in user reads their row, the Edge Functions write it with the service role.
grant select on public.user_verifications to authenticated;
grant select, insert, update on public.user_verifications to service_role;
```

2. Create a Supabase Edge Function named didit-create-session that:
   - handles CORS (including OPTIONS) so the frontend can call it with supabase.functions.invoke;
   - reads the signed-in user from the Authorization header with supabase.auth.getUser(); returns 401 if there is none;
   - reads the user's row with the service role key (returns 500 if that read fails);
   - when the row has a session_id, reads GET https://verification.didit.me/v3/session/{session_id}/decision/ with
     the header x-api-key: DIDIT_API_KEY, and decides from Didit's answer, not from the row:
     - status 'Approved' with environment 'live': returns 409 with { status, environment };
     - status 'Declined', 'Abandoned', 'Expired' or 'Kyc Expired', a sandbox 'Approved', or a 404: goes on to create
       a new session;
     - any other status (Not Started, In Progress, In Review, Resubmitted and so on): returns { "url": <its
       session_url> } and never creates a new session; returns 502 if it has no session_url;
     - any other error: returns 502;
   - to create a session, calls POST https://verification.didit.me/v3/session/ with the header x-api-key: DIDIT_API_KEY
     and the JSON body { "workflow_id": DIDIT_WORKFLOW_ID, "vendor_data": <the user's id>,
     "callback": APP_URL + "/verification-complete" };
   - upserts the user's row with the new session_id, status 'Not Started' and environment null; returns 500 without
     the link if that write fails;
   - returns { "url": <the url field of Didit's response> }. The field is called url, not verification_url.
   Never accept the user id from the request body, and never send DIDIT_API_KEY to the browser.

3. Frontend: on the account page, read the user's row from user_verifications. The user is verified only when
   status = 'Approved' AND environment = 'live'. When environment is 'sandbox', show the status labelled "Test result".
   When status is 'In Review', show "Your verification is being reviewed" and no button.
   Otherwise, if the user is not verified, show a "Verify my identity" button that calls didit-create-session and
   then does window.location.href = url. On a 409 answer, re-read the user's row and show its status.
   Add a /verification-complete page that says "Thanks, we're checking your verification" and re-reads the user's
   status and environment every 3 seconds until status is 'Approved', 'Declined' or 'In Review', for up to 2 minutes;
   if it is still pending after that, show a "Refresh" button. If a read fails, stop and show "Try again" (or
   "Sign in" when the user is signed out), not the pending message. Do not trust the status query parameter Didit
   adds to that URL.
````

The function should look like this:

```typescript supabase/functions/didit-create-session/index.ts theme={null}
import { createClient } from "npm:@supabase/supabase-js@2";

const corsHeaders = {
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type",
};

// Sessions that allow a new attempt. A sandbox approval does too; a live approval does not.
const CAN_RETRY = ["Declined", "Abandoned", "Expired", "Kyc Expired"];

function json(body: unknown, status = 200) {
  return new Response(JSON.stringify(body), {
    status,
    headers: { ...corsHeaders, "Content-Type": "application/json" },
  });
}

Deno.serve(async (req) => {
  if (req.method === "OPTIONS") return new Response("ok", { headers: corsHeaders });

  // Who is asking: the signed-in user, from their own session token.
  const supabase = createClient(
    Deno.env.get("SUPABASE_URL")!,
    Deno.env.get("SUPABASE_ANON_KEY")!,
    { global: { headers: { Authorization: req.headers.get("Authorization") ?? "" } } },
  );
  const { data: { user } } = await supabase.auth.getUser();
  if (!user) return json({ error: "Not signed in" }, 401);

  const admin = createClient(
    Deno.env.get("SUPABASE_URL")!,
    Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!,
  );
  const didit = { "x-api-key": Deno.env.get("DIDIT_API_KEY")!, "Content-Type": "application/json" };

  const { data: current, error: readError } = await admin
    .from("user_verifications")
    .select("session_id")
    .eq("user_id", user.id)
    .maybeSingle();
  if (readError) return json({ error: "Could not start verification" }, 500);

  // Ask Didit how the tracked session stands: its webhook may not have arrived yet.
  if (current) {
    const check = await fetch(
      `https://verification.didit.me/v3/session/${encodeURIComponent(current.session_id)}/decision/`,
      { headers: didit },
    );
    if (check.ok) {
      const tracked = await check.json();
      if (tracked.status === "Approved" && tracked.environment === "live") {
        return json({ error: "Already verified", status: tracked.status, environment: tracked.environment }, 409);
      }
      // Unfinished (Not Started, In Progress, In Review, Resubmitted): resume it, never start a second one.
      if (!CAN_RETRY.includes(tracked.status) && tracked.status !== "Approved") {
        return tracked.session_url
          ? json({ url: tracked.session_url })
          : json({ error: "Could not resume verification" }, 502);
      }
    } else if (check.status !== 404) {
      // 404: the session no longer exists, so a new one is fine. Anything else: do not guess.
      return json({ error: "Could not start verification" }, 502);
    }
  }

  const response = await fetch("https://verification.didit.me/v3/session/", {
    method: "POST",
    headers: didit,
    body: JSON.stringify({
      workflow_id: Deno.env.get("DIDIT_WORKFLOW_ID"),
      vendor_data: user.id,
      callback: `${Deno.env.get("APP_URL")}/verification-complete`,
    }),
  });
  const session = await response.json();
  if (!response.ok) {
    console.error("Didit session error", response.status, session);
    return json({ error: "Could not start verification" }, 502);
  }

  // Track the new session before handing out its link: the webhook saves results for this session only.
  const { error } = await admin.from("user_verifications").upsert({
    user_id: user.id,
    session_id: session.session_id,
    status: "Not Started",
    environment: null,
    updated_at: new Date().toISOString(),
  });
  if (error) return json({ error: "Could not start verification" }, 500);

  return json({ url: session.url });
});
```

The button:

```typescript theme={null}
const { data, error } = await supabase.functions.invoke("didit-create-session");
if (data?.url) window.location.href = data.url;
else if (error?.context?.status === 409) await loadVerification(); // Re-read the user's row and show its status.
else showError();
```

The completion page waits for the webhook, because the user can arrive before it does:

```typescript theme={null}
// Re-read the user's own row every 3 seconds, for up to 2 minutes.
const SETTLED = ["Approved", "Declined", "In Review"];
type Decision = { status: string; environment: string | null };
async function waitForDecision(userId: string): Promise<Decision | "pending" | "error"> {
  for (let attempt = 0; attempt < 40; attempt++) {
    const { data, error } = await supabase
      .from("user_verifications")
      .select("status, environment")
      .eq("user_id", userId)
      .maybeSingle();
    // A failed read is not a pending decision: show "Try again", or "Sign in" when the user is signed out.
    if (error) return "error";
    // environment 'sandbox' is labelled "Test result".
    if (data && SETTLED.includes(data.status)) return data;
    await new Promise((resolve) => setTimeout(resolve, 3000));
  }
  return "pending"; // Still pending: show a Refresh button.
}
```

> [!NOTE]
>
> 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](https://docs.didit.me/sessions-api/create-session.md).

Prefer to keep the user inside your app? Open the same `url` in Didit's [JavaScript SDK](https://docs.didit.me/integration/web-sdks/javascript-sdk.md) modal instead of redirecting.

### Step 3: Receive the result

Paste this into Lovable:

```text theme={null}
Create a Supabase Edge Function named didit-webhook that receives Didit webhooks. It is called by Didit, not by a
signed-in user, so deploy it without JWT verification (verify_jwt = false for this function in supabase/config.toml).

For each POST request:
1. Read the body as raw bytes with req.arrayBuffer(). Do not call req.json() and do not re-serialize the body
   before the signature check. Parse it with JSON.parse only to read its fields.
2. Signature: compute HMAC-SHA256 with DIDIT_WEBHOOK_SECRET, hex encoded, over the raw bytes, and compare it in
   constant time (timingSafeEqual from node:crypto, on TextEncoder bytes; Deno has no global Buffer) with the
   X-Signature header and, when present, X-Signature-Previous. Return 401 if neither matches. Parse the body only
   after this check.
3. Timestamp: return 401 unless X-Timestamp is an integer, the body's timestamp field equals it, and
   abs(now_in_seconds - X-Timestamp) <= 300.
4. Return 200 without writing anything when the header X-Didit-Test-Webhook is "true" or webhook_type is not
   "status.updated", or when vendor_data is not a user id (a UUID).
5. Do not save the status from the body: deliveries can arrive late or out of order. Read the session's current
   decision with GET https://verification.didit.me/v3/session/{session_id}/decision/ and the header
   x-api-key: DIDIT_API_KEY. Return 200 on a 404 (the session no longer exists) and 500 on any other error.
6. With the service role key, update user_verifications set status and environment from that decision, and
   updated_at = now(), where user_id = vendor_data from the body and session_id = session_id from the body.
   No ordering logic: the decision Didit returns is the current one.
7. Return 200 only after the update succeeds. If it fails, return 500 so Didit retries the delivery.
```

The function should look like this. It follows the [signature verification](https://docs.didit.me/integration/webhooks.md#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.

```typescript supabase/functions/didit-webhook/index.ts theme={null}
import { createHmac, timingSafeEqual } from "node:crypto";
import { createClient } from "npm:@supabase/supabase-js@2";

const SECRET = Deno.env.get("DIDIT_WEBHOOK_SECRET")!;
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
const encoder = new TextEncoder();

// Constant-time comparison of two hex digests, as bytes.
function sameDigest(expected: string, received: string | null): boolean {
  if (!received) return false;
  const a = encoder.encode(expected);
  const b = encoder.encode(received);
  return a.length === b.length && timingSafeEqual(a, b);
}

const ok = () => Response.json({ ok: true });
const reject = (message: string) => new Response(message, { status: 401 });
const retry = (message: string) => new Response(message, { status: 500 });

Deno.serve(async (req) => {
  if (req.method !== "POST") return new Response("Method not allowed", { status: 405 });

  // 1. The exact bytes Didit sent.
  const raw = new Uint8Array(await req.arrayBuffer());

  // 2. Signature over those bytes. X-Signature-Previous is sent for 24 hours after you rotate the signing secret.
  const digest = createHmac("sha256", SECRET).update(raw).digest("hex");
  if (
    !sameDigest(digest, req.headers.get("X-Signature")) &&
    !sameDigest(digest, req.headers.get("X-Signature-Previous"))
  ) {
    return reject("Invalid signature");
  }
  const body = JSON.parse(new TextDecoder().decode(raw));

  // 3. Freshness, from the signed body: its timestamp must match X-Timestamp and be under 5 minutes old.
  const timestamp = Number(req.headers.get("X-Timestamp"));
  if (
    !Number.isInteger(timestamp) ||
    body.timestamp !== timestamp ||
    Math.abs(Date.now() / 1000 - timestamp) > 300
  ) {
    return reject("Stale or mismatched timestamp");
  }

  // 4. Test deliveries carry sample data, and this app stores session results only.
  if (req.headers.get("X-Didit-Test-Webhook") === "true") return ok();
  if (body.webhook_type !== "status.updated") return ok();
  if (!UUID.test(String(body.vendor_data ?? ""))) {
    console.warn("status.updated without an app user id", body.session_id);
    return ok();
  }

  // 5. Didit is the source of truth: read the session's current decision, not the event's status.
  const check = await fetch(
    `https://verification.didit.me/v3/session/${encodeURIComponent(body.session_id)}/decision/`,
    { headers: { "x-api-key": Deno.env.get("DIDIT_API_KEY")! } },
  );
  if (check.status === 404) return ok();
  if (!check.ok) return retry("Could not read the decision");
  const decision = await check.json();

  // 6. Save it on the user's row, only for the session the user started last.
  const admin = createClient(
    Deno.env.get("SUPABASE_URL")!,
    Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!,
  );
  const { error } = await admin
    .from("user_verifications")
    .update({ status: decision.status, environment: decision.environment, updated_at: new Date().toISOString() })
    .eq("user_id", body.vendor_data)
    .eq("session_id", body.session_id);

  // 7. Acknowledge only what is saved: a 500 makes Didit retry the delivery.
  if (error) {
    console.error("Could not save the Didit decision", body.event_id, error);
    return retry("Could not save");
  }
  return ok();
});
```

```toml supabase/config.toml theme={null}
[functions.didit-webhook]
verify_jwt = false
```

> [!WARNING]
>
> 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](https://docs.didit.me/integration/webhooks.md#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/`](https://docs.didit.me/sessions-api/retrieve-session), 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](https://docs.didit.me/integration/webhooks.md#retry-policy) 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](https://docs.didit.me/integration/webhooks.md).

### 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/`](https://docs.didit.me/integration/webhooks), or ask Lovable's agent to do it through the Didit MCP server ([Part 2](#part-2-use-didit-in-the-lovable-chat)).

### Step 5: Test end to end

1. Use a [sandbox application](https://docs.didit.me/integration/sandbox-testing.md) 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:

   ```sql theme={null}
   delete from public.user_verifications where environment = 'sandbox';
   ```

   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](https://docs.lovable.dev/integrations/custom-mcp) 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.

> [!NOTE]
>
> 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](#part-1-add-didit-to-your-lovable-app).

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.

> [!NOTE]
>
> **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](https://docs.didit.me/integration/mcp/authentication.md).

### Check that it works

In a Lovable chat, ask:

```text theme={null}
Use the Didit MCP server to call didit_context_get and list my organizations and applications.
```

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](https://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](https://docs.didit.me/integration/mcp/authentication.md#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

> [card] [Webhooks](https://docs.didit.me/integration/webhooks.md)
>
> Every event, payload field and signature header.

> [card] [Create session](https://docs.didit.me/sessions-api/create-session.md)
>
> All request fields, such as expected details and metadata.

> [card] [MCP tools reference](https://docs.didit.me/integration/mcp/tools.md)
>
> Everything Lovable's agent can call, tool by tool.

> [card] [Pricing](https://docs.didit.me/getting-started/pricing.md)
>
> What each check in your workflow costs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.