Skip to main content

Idempotency Keys for Identity Verification API Calls, 2026

Use one idempotency key per logical operation, send a stable vendor identifier, retry 429 and 5xx as documented, handle 409 by reading its code and reloading state, and deduplicate webhooks on the event id.

Idempotency Keys for Identity Verification API Calls, 2026

Contents

In this guide

Jump to the part you need.

Idempotency keys matter when your backend calls the Didit API and a retry must not start a second verification or charge. This guide gives the pattern we document: one key per logical operation, a stable vendor_data, retry 429 and 5xx as documented, handle 409 by reading its code and reloading state, and deduplicate webhooks on event_id. A full KYC check lists at $0.33 and the sandbox is free. Caveat: the docs do not publish a key retention window.

Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.

What a duplicate request can cost on a Didit integration, and the documented control
RiskWhat a blind retry doesDocumented control
Second verification sessionStarts another hosted flow for a person who may already be verifying, and leaves two sessions to reconcileSend a stable vendor_data; the create docs state it is used for duplicate detection across sessions
Second chargeEach completed check is billed from prepaid credit, so a duplicate that completes bills twiceOne key per logical operation, reused on every retry of that operation
Retry stormMore 429 responses and longer waits against the same key-scoped counterRead Retry-After, then back off with jitter and stop after a small ceiling
Duplicate webhookThe same status applied twice, so two notifications or two state writesDeduplicate on the envelope event_id and return 2xx fast
Key reused across operationsThe API answers 409 and your state is unclearA new logical operation gets a new key

Start free in the sandbox at business.didit.me, no sales call. See the User Verification product page for the KYC modules, and read unit prices at didit.me/pricing. Developers who build with an AI assistant can connect Didit through the MCP server.

Two things sit side by side in this guide. The documented behavior is the API contract in our docs: what a status means, which failures are safe to retry, how a 409 is handled, and which fields the create and decision calls return. The design advice is how we recommend wiring your client around that contract, for example generating one key per logical operation and storing it with your own record. Where the docs leave a policy to you, we say so.

What you get from this guide

Two calls define the integration. POST /v3/session/ starts a verification and GET /v3/session/{session_id}/decision/ returns the decision. Everything else is delivery. A retry only becomes dangerous when it can create a second session, a second charge, or a second state change. Idempotency is the property we design for: the same logical operation should not create a second effect, however many times your client retries it. The API contract and your client rules together decide how that is enforced.

By the end you will have:

  • one key per logical operation, generated before the first call and stored with your own record of that operation;
  • the documented create call, carrying a stable vendor_data that binds the session to a user or a business;
  • a decision about which responses to retry, taken from the error contract instead of guesswork;
  • a webhook handler that tolerates the same event arriving twice;
  • a reconciliation step for the case where no webhook arrives at all.

We run this API for 4,000+ companies. The mechanics below come from our public documentation, not from a private integration.

Prerequisites

  • A Didit application and an API key. Keys live under Developers, then API keys in the Business Console. The primary key has full access to the application; create a separate key for each service that calls the API. New keys start with sk_live_ for a live application or sk_test_ for a sandbox application, followed by 43 URL-safe characters.
  • A sandbox key for testing. Sandbox calls are mocked and the sandbox is free on every plan. The API authentication page also shows the programmatic register and verify-email calls that return both keys inline.
  • A workflow UUID. workflow_id is a stable workflow UUID from /v3/workflows/. KYC workflows create user verification sessions and KYB workflows create business verification sessions. There is no separate KYB endpoint.
  • Server-side storage for the API key and the operation record. The API key is a secret. Keep it out of browsers, mobile bundles and public repositories. An idempotency key is an operation identifier, not a credential: store it reliably with your record, but do not treat it as a password.
  • An HTTP client. The examples use curl and plain fetch; any client works.

The steps

  1. Generate one key per logical operation, before the first call. Use a UUID or another strong random string. The same key covers every retry of that operation. A different logical operation, such as the same person starting a fresh verification after leaving, gets a new key. Do not derive the key from the payload: if the payload changes it is a different operation, and it should carry a different key.
  2. Choose a stable vendor_data. The create docs call it strongly recommended, because it binds the session to a User or Business entity and is used for duplicate detection across sessions. Use your own user id or business id, not a value that changes on each attempt. Every response and webhook echoes it back.
  3. Create the session with the documented call.
    curl -X POST https://verification.didit.me/v3/session/ \
    -H "x-api-key: $DIDIT_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"workflow_id":"<WORKFLOW_ID>","vendor_data":"user-42","callback":"https://myapp.com/return"}'

    workflow_id is required. callback is where the hosted flow sends the user when it finishes, and Didit appends ?verificationSessionId={session_id}&status={status}. When the application has allowed domains, an http or https callback must be on one of those origins, otherwise creation fails with 400 on callback. Custom schemes such as app deep links are always accepted.

    The public create example in our docs does not show where an Idempotency-Key header goes. The documented duplicate control for session creation is the stable vendor_data value, so keep that constant across retries and use the key in your own operation record.

  4. Keep the identifiers you get back. session_id is returned by POST /v3/session/ and is what the decision endpoint takes. session_url is the hosted page you send the user to. Store the key, the vendor_data and the session_id together, so a retry or a support question has one record to read.
  5. Retry only what the error contract allows. Read the status code first and the code field when it is present, because message text can change. A 500 may have no JSON body at all, so parse defensively.
    const raw = await response.text();
    let body = {};
    try {
      body = JSON.parse(raw);
    } catch {
      // A 5xx response may not be JSON: rely on response.status.
    }
    const code = body.code ?? null;
    const message = body.detail ?? body.error ?? (Array.isArray(body) ? body[0] : raw);

    Then branch: 429 wait for Retry-After and try again; 500, 502 and 503 retry with backoff; 409 read code and reload the state before doing anything else; 400, 401, 402, 403, 404, 410, 415 and 422 need a fix or a new resource, not another identical send.

  6. Read the decision, and branch on the session kind.
    curl https://verification.didit.me/v3/session/<SESSION_ID>/decision/ \
    -H "x-api-key: <API_KEY>"
    const decision = await (await fetch(url, { headers: { "x-api-key": API_KEY } })).json();
    switch (decision.session_kind) {
    case "user": return handleUserDecision(decision);
    case "business": return handleBusinessDecision(decision);
    }

    Always branch on session_kind. Feature arrays are always plural arrays, and a feature that did not run is absent or null, never a placeholder. Reading the same decision twice is safe by design, so a lost decision response never forces you to create a new session.

  7. Deduplicate webhook deliveries. Verify X-Signature-V2 over the sorted canonical JSON, check that X-Timestamp is within 300 seconds, and compare in constant time against the header and, when present, its -Previous pair. Then deduplicate on the envelope event_id, apply the change once, and return 2xx as fast as you can. If you fall back to X-Signature-Simple, re-fetch the decision from GET /v3/session/{session_id}/decision/ instead of trusting the payload, because that scheme authenticates the envelope only.
  8. Reconcile when no webhook arrives. Delivery is retried a bounded number of times. The decision endpoint is the source of truth, so call it after a session event and whenever your own record shows a session that has not reached a final status. Repeating that read is cheap, and it closes the gap a lost webhook leaves. If a create call timed out before you stored a session id, do not assume a repeated create returns the first response. Reconcile from your operation record and any session id you hold before starting a new logical operation.

Expected output

A good run looks like this. The create call returns a session you can identify, session_id and session_url go into your record next to the key, and the user finishes the hosted flow at session_url. A status.updated webhook arrives with one of the documented statuses: Approved, Declined, In Review, In Progress, Not Started, Expired, Abandoned, Kyc Expired, Resubmitted or Awaiting User. Those strings are exact and case sensitive, and Kyc Expired uses a single capital K.

The decision read returns the full record: session_id, session_kind, status, vendor_data, features, decision_trace, reviews, status_override, linked_records and the feature arrays for the steps your workflow runs. linked_records is where duplicate detection becomes visible, with same_face, earlier_verifications and network summaries, or null when there is nothing to report.

Session overview in the Didit Business Console showing the session status and its warnings
A session overview in the Business Console. A duplicate attempt shows up as a second session for the same person, which is why the create call is the one you make idempotent.

Failure cases and recovery

What each failure means and what to do next
SituationWhat you seeRecovery
Timeout before any responseNo status code and no session idResend with the same key if your operation record says the create is unresolved, but do not assume the API replays the original response. Read any session id you stored and reconcile from your own record before starting a new logical operation.
Reused key on a conflicting request409, sometimes with a codeRead code, reload the current state and stop creating. Do not send an identical create again until you know the current state.
Rate limited429 with X-RateLimit-Scope, Retry-After and a referenceWait at least Retry-After, then back off with jitter (5s, 10s, 20s, 40s plus random). Stop after about five attempts and alert, because sustained 429s usually mean a runaway loop.
Balance too low402 with insufficient_credits on some APIs, 403 on others, a 400 body on session createThe check did not run, so nothing was billed. Top up, then retry once.
Callback rejected400 on callback, saying it must be on one of the application's allowed domainsUse an origin on the allowed domains, or a custom scheme deep link.
Ambiguous wallet address422 with candidate_chainsResend with blockchain set to one of the candidates. Nothing was screened or billed on the failed call.
Session expired410, or status Expired on the decisionCreate a new session with a new key, because a re-verification is a new logical operation.
Duplicate webhookThe same event_id twiceDrop the second delivery once the signature check passes and return 2xx.
Bad signatureSignature mismatch, or a timestamp older than 300 secondsRebuild the canonical JSON from the raw body, compare in constant time, and accept the -Previous header during a secret rotation.

Inputs and outputs

The decision read is where every output lands, including the ones that tell you a retry would have been wrong.

Session detail in the Didit Business Console showing the ID document check and its extracted data
The same session in the Console, feature by feature. Read these outputs from the decision endpoint instead of re-creating a session to see them.
Fields you own on the way in, fields Didit returns
FieldDirectionRequiredWhat it does
workflow_idInYesStable workflow UUID. It decides whether the session is KYC or KYB.
vendor_dataInNo, strongly recommendedYour identifier for the person or business. Used for duplicate detection and echoed back.
callbackInNoWhere the hosted flow sends the user when it finishes, with the session id and status appended.
callback_methodInNoinitiator (default), completer or both. Use both when the callback sometimes fails to fire.
metadataInNoArbitrary JSON echoed in responses and webhooks, never shown to the user.
session_expiration_timeInNoSeconds the link stays valid, between 3600 and 2419200, overriding the workflow setting for this session only.
session_idOutReturnedThe key for the decision read.
session_urlOutReturnedThe hosted page you send the user to.
statusOutReturnedOne of the documented statuses.
session_kindOutReturneduser or business. Always branch on it.
event_idOutReturned in webhooksThe deduplication key for webhook delivery.

Paid steps and review boundaries

Billing is per completed check, from prepaid credit. That is the reason to make the create call idempotent: a duplicate that completes is billed like any other check. The KYC line is documented on the User Verification product page, and the unit prices are on didit.me/pricing. The pricing docs also note that some no-match database lookups and retries are billable, so your retry policy is a cost decision as well as a reliability decision.

Video explaining Didit billing with credits, auto-recharge and volume discounts
Billing runs per completed check from prepaid credit, so a duplicate session shows up as a line on the bill before it shows up as a bug.
Unit prices that a duplicate or a retry can touch
StepPrice (USD)Unit
Full ID check (KYC): ID document, passive liveness, face match 1:1, device and IP$0.33check
ID verification alone$0.15check
Passive liveness$0.10check
Face match 1:1$0.05check
Device and IP analysis$0.03check
AML screening$0.20check
Ongoing AML monitoring$0.07person per year
Business verification (KYB)From $2.00company
Wallet screening$0.15screening

Repeat reads are the cheap part. GET /v3/session/{session_id}/decision/ is governed by the generic GET ceiling of 600 requests a minute per key, so reconciling by reading a decision is a normal operation rather than a costly one.

Review is a different boundary. A session in In Review is held by a person in the Console, and the decision record says so: assignee, waiting_since and sla_due_at are set, reviews lists the manual review activity, and decision_trace.decided_by reads manual, automatic or investigator. When a reviewer changes a status by hand, status_override carries the automatic_status it replaced. A retry must never be used to push a session past a reviewer. If you need the current position, read the decision; if you need to act, act on the status it reports.

Worked cost example

Take 10,000 completed KYC checks a month at list price. 10,000 x $0.33 = $3,300.00. Suppose 2% of your create calls time out and your code retries them with no deduplication, so each retry starts a second session. That is 200 extra sessions, and if they complete, 200 x $0.33 = $66.00. Add AML screening to each KYC at $0.20 and the duplicate run adds 200 x $0.20 = $40.00. The avoidable total is $106.00 a month, plus the time spent reconciling 200 extra sessions.

On the Growth plan every Didit price is 4% lower, so the same duplicates cost 200 x $0.3168 = $63.36 for KYC and 200 x $0.192 = $38.40 for AML, $101.76 in total. The fix costs nothing to run: one key per operation and a stable vendor_data. Build and break it in the sandbox first, which is free and unlimited on every plan. On the Free plan, $10.00 of monthly credit covers about 30 full KYC checks at $0.33 when you switch to live keys.

Sources

Next step: open the sandbox at business.didit.me, create a session with a sk_test_ key, and retry it on purpose. No sales call, no credit spent, and you will see the error contract behave exactly as the table above describes.

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alejandro Rosas

Co-founder and CTO

Alejandro Rosas

Alejandro Rosas

Co-founder and CTO

About Didit

Questions

Frequently asked questions

What is an idempotency key in an API call?

An idempotency key is a unique identifier you send with a request so the server can distinguish a retry from a new operation. Your client generates it once per logical operation and reuses it on every retry of that operation. The Didit docs document a 409 conflict when a reused Idempotency-Key collides, so a conflict is a signal to read the code and reload state, not a promise that the original response will be replayed.

Does the Didit API support idempotency keys?

Yes. The Didit error reference documents a 409 conflict when a reused Idempotency-Key collides, alongside the case where a step already ran. For session creation specifically, the documented duplicate control is a stable vendor_data, which the create docs say binds the session to a User or Business entity and is used for duplicate detection across sessions. Use both: the key identifies the operation in your own retry logic, and vendor_data makes a duplicate visible on the session itself.

How do I stop a retry from creating a second verification session?

Generate the key before the first call and resend that same key on every retry, with the same workflow_id and the same vendor_data. Do not create a fresh session to check what happened after a timeout; read the decision for a session id you already hold. The docs do not document replay of the original response, so if you lost the id, reconcile from your own operation record before creating anything new.

Which Didit status codes are safe to retry?

Retry 429 after waiting for Retry-After, and retry 500, 502 and 503 with backoff. Do not retry 400, 401, 402, 403, 404, 410, 415 or 422 until you fix what the body names. A 409 depends on its code: read it and reload the state before deciding.

How long is a Didit idempotency key valid?

The Didit error reference does not publish a retention window for idempotency keys, so treat the window as provider-managed and never as your only record. Keep the key, the vendor_data and the session_id in your own store. Session expiry is a separate setting, session_expiration_time, which accepts 3600 to 2419200 seconds and overrides the workflow default for that session.

Can I reuse one idempotency key for a different request?

No. One key belongs to one logical operation. Creating a session and then updating that session are two operations and need two keys, and a re-verification after a session expires is a third. Reusing a key across operations returns a 409 conflict, and you then have to reload the state to find out what actually happened.

How do I make a Didit webhook handler idempotent?

Verify X-Signature-V2 over the sorted canonical JSON, reject a timestamp more than 300 seconds old, then deduplicate on the envelope event_id before writing any state. Return 2xx as fast as possible so Didit stops retrying, and do the slow work after the response. Accept the -Previous signature header for 24 hours while a destination secret is being rotated.

What does a 409 conflict from Didit mean?

The request conflicts with the current state, for example a reused Idempotency-Key or a step that already ran. Read the code field when it is present and reload the state from the decision endpoint. Retrying the identical request without reading the code will not resolve it.

How much does a duplicate verification cost?

A full KYC check lists at $0.33, made up of ID verification at $0.15, passive liveness at $0.10, face match 1:1 at $0.05 and device and IP analysis at $0.03. AML screening adds $0.20 per check and KYB starts at $2.00 per company. Because billing is per completed check from prepaid credit, every duplicate that completes is billed in full.

Do retries count as billable checks?

A retry that is rejected before any work runs is not billed: a 402, a 403 for missing credits, a 400 on session create or a 422 for an ambiguous wallet address all mean nothing ran. The pricing docs do note that some no-match database lookups and retries are billable, so read the docs pricing page for the endpoints you call. A retry that turns into a second completed session is always billed.

How do I test the retry path without spending money?

Use a sandbox application key, which starts with sk_test_. Sandbox calls are mocked and the sandbox is free and unlimited on every plan, so you can force timeouts and duplicate deliveries safely. Switch the environment variable to the live key only when the retry behaviour is already proven.

What is the vendor identifier used for in Didit?

vendor_data is your stable identifier for the person or business behind a session. The create docs strongly recommend it because it binds the session to that entity and is used for duplicate detection across sessions, and it is echoed in responses and webhooks. It is the field that lets a duplicate session be recognised as a duplicate rather than as a new user.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.