Idempotency Keys for APIs: A Developer's Guide (2026)
Use one key per intended operation. On Didit, keep the entity identifier stable and inspect a conflict before deciding whether to retry.

Contents
In this guide
Jump to the part you need.
This guide is for developers who retry API calls and need a retry to never start a second verification. It covers how idempotency keys work, what Didit documents for duplicate detection, and a full ID check at $0.33 per completed check. The caveat: our Create Session documentation does not establish request-level replay protection for POST /v3/session/, so reconcile before you send another create.
Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.
Idempotency on the Didit API at a glance
| Question | Answer |
|---|---|
| Session entity identifier | vendor_data links sessions to a person or business and supports duplicate detection across sessions. It is not a documented request replay key for POST /v3/session/. |
| Reused request key | A 409 signals a conflict. One listed cause is a reused Idempotency-Key. Inspect code, reload the state, and reuse an existing result only after confirming it belongs to the same operation. |
| Price of one full ID check | $0.33 per completed check |
| Safe to retry | For a Didit middleware throttle, wait at least the time in Retry-After, then back off with jitter. For other 429 responses, follow the endpoint-specific recovery instructions. For 5xx, inspect code when present. Use backoff when the endpoint's retry contract makes the operation safe to repeat. If a create may already have succeeded and replay protection is unconfirmed, reconcile before sending another create. |
| Do not retry | 400, 401, 402, 403, 404, 410, 415 until you change something |
| Cost to test retries | $0 in the sandbox on every plan, checks are mocked |
| Plan discounts, current | Growth 4% off, Scale 10% off every Didit price |
Start free in the sandbox at business.didit.me, no sales call. For developers, connect Didit to an AI assistant through the MCP server. See published module prices and country-dependent rates on the Didit pricing page.
Retry decisions in four cases
| Situation | What you have | Action |
|---|---|---|
| Successful create with a session ID | A session_id and a hosted flow | Store the session_id against your operation key and send the person to the flow once. Do not send another create for the same intended verification. |
| Timeout without an ID | No session_id | The outcome is unknown. If you cannot identify a known session, do not automatically send another create. Reconcile with your records first. |
HTTP 409 | A conflict response, possibly with code | Inspect code if present and reload the relevant state. Reuse an existing result only after confirming it belongs to the same operation. Follow the recovery documented for that conflict. |
| Repeated webhook | An event_id you have seen | Deduplicate by event_id only after verifying it with X-Signature-V2 or X-Signature. If you verified with X-Signature-Simple, fetch the decision first and apply it idempotently using the authenticated session_id and the retrieved decision. Return 2xx after successful handling. |

session_id and need to check what happened.The outcome, and the method we recommend
An API call is idempotent when sending it twice has the same effect as sending it once. For a verification API the effect that matters is a billable check. Two sessions can produce two billable checks if both checks complete. Didit generally bills completed checks from prepaid credit. The pricing docs list exceptions, including some billable retries and no-match database lookups.
Our recommendation has two parts. First, keep the subject identifier stable: send vendor_data with the id you already use for the person or business. The docs describe it as the field that binds a session to a user or business entity and is used for duplicate detection across sessions. Second, assign a fresh request key to each intended verification, including a new verification for the same subject and workflow. Reuse that key only for attempts to complete the original operation. Keep the subject identifier stable across those verifications.
The request key belongs to the operation, not to the HTTP attempt. Assign it once per intended operation and reuse it only for attempts to complete that same operation.
Didit's error reference lists HTTP 409 with a reused Idempotency-Key as one possible cause of a conflict. Our Create Session documentation does not establish replay protection for POST /v3/session/. Read the code field from the body, reload your record, and return what you already have only after confirming it belongs to the same operation. A conflict is information, not a failure to work around.
Endpoint-contract checklist
- Documented idempotency support: Didit's API error reference lists a reused
Idempotency-Keyas one possible cause of409. Our Create Session documentation does not establish request-level replay protection forPOST /v3/session/. - Key scope: for a client-generated operation key, scope it in your own system to one intended verification. The Didit create docs do not define a request-key scope for this endpoint.
- Changed payloads: our Create Session documentation does not state how a changed payload under the same key is treated on this endpoint.
- Concurrent requests: our Create Session documentation does not state how two concurrent creates with the same key are handled on this endpoint.
- Expiry: Didit's
session_expiration_timecontrols the hosted link. Our Create Session documentation does not document request-key retention.
Prerequisites
- An Application in the Didit Business Console. API keys are scoped to an Application, and each Application holds its own workflows.
- An API key. New keys start with
sk_test_for a sandbox application orsk_live_for a live one, followed by 43 URL-safe characters. Treat it as a server-side secret. - The
workflow_idUUID of the workflow you want to run. A KYC workflow creates a user session and a KYB workflow creates a business session, on the same endpoint. - A webhook destination with its signing secret if you want events pushed to you. We recommend it: it is how you learn about a status change without polling.
- If the application has allowed domains configured, an HTTP or HTTPS
callbackmust match an allowed origin by scheme, host and port. An origin mismatch returns400. - A place in your application to keep your operation key next to any
session_idyou receive. That store is yours, not ours.
Create a Didit session and handle uncertain retries
Decide what one operation is before you write retry code. Assign a fresh request key to each intended verification, including a new verification for the same subject and workflow. Reuse that key only for attempts to complete the original operation. Keep the subject identifier stable across those verifications.
Create or copy an API key in the Didit Business Console under Developers, then API keys. New keys start with
sk_test_orsk_live_, followed by 43 URL-safe characters. Treat the key as a server-side secret.Create the session with the stable subject identifier.
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"}'metadatais echoed back in responses and webhooks for correlation and is not shown to the user.tagsare returned on create and support filtering in the console, with up to 10 tags of up to 50 characters each.Record the outcome before you use the response. If you have a
session_id, use the documented decision endpoint to read that session. If the response was lost before you obtained the ID, the outcome is unknown. Our Create Session documentation does not establish a way to recover it using your request key orvendor_data, so avoid automatically sending another create.Read before you write. When you are not sure whether a create landed, read the decision of the session you already have.
curl "https://verification.didit.me/v3/session/${SESSION_ID}/decision/" \ -H "x-api-key: $DIDIT_API_KEY"Set
SESSION_IDto the ID returned by the create call. The key must hold theread:sessionsprivilege.Reading a decision cannot start a second session, so it cannot produce a second completed check. Call it eagerly after a create, and again whenever a webhook reports a status change.
A
409signals a conflict. Inspectcodeif present and reload the relevant state. Reuse an existing result only after confirming it belongs to the same operation. Follow the recovery documented for that conflict.Verify and deduplicate the webhook before you trust it. Delivery is retried, so the same event can arrive twice. The checks are listed in order further down this page.
In the sandbox, create one session with
sandbox_scenarioset to a slug fromGET /v1/sandbox/scenarios/. Save itssession_id, repeat the decision read and confirm it refers to that session. Use the scenario for a documented verification outcome and test your application's ambiguous-create handling without issuing another create. Sandbox checks are mocked and free on every plan.
One example: first create, network retry, later reverification
| Event | Subject identifier | Operation key | What changes |
|---|---|---|---|
| First verification | vendor_data user-42 | op-2026-11-26-001 | Create the session and store the session_id. |
| Network retry | vendor_data user-42, unchanged | op-2026-11-26-001, unchanged | If the session_id is known, read the decision. If it was lost, reconcile and do not automatically create. |
| Later reverification | vendor_data user-42, unchanged | op-2027-05-01-001, new | Treat it as a new intended verification. |
Expected output
The create call returns session_id, and the tags you sent come back with it. The decision response includes session_url for the hosted flow. The callback appends ?verificationSessionId={session_id}&status={status}, so a person who returns from the flow maps back to the same session.
The decision response is the record to key your own state on. It includes session_id, session_kind, session_number, session_url, status, vendor_data, metadata, created_at, expires_at, decision_trace, reviews, status_override and linked_records. Branch on session_kind, because one endpoint serves both kinds.
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);
}
The response can return Approved, Declined, In Review, In Progress, Not Started, Expired, Abandoned, Kyc Expired, Resubmitted or Awaiting User. Compare those strings exactly and case-sensitively.

Inputs and outputs
| Field | Direction | Why it matters for idempotency |
|---|---|---|
x-api-key | Request header | Authenticates every call to verification.didit.me. A wrong or revoked key returns 401, a missing one 403. A retry does not fix a bad key. |
workflow_id | Request body, UUID | The workflow that runs. A KYC workflow creates a user session, a KYB workflow creates a business session. |
vendor_data | Request body, string | Your stable id for the person or business. It links the session to an entity and supports duplicate detection across sessions. Keep it stable across verifications for the same subject. |
metadata | Request body, object | Arbitrary JSON, echoed back in responses and webhooks. Use it for correlation. The supplied docs do not define it as a replay key. |
tags | Request body, array | Up to 10 names, 50 characters each, returned on create and filterable in the console. |
callback | Request body, URL | Redirect after the flow. If the application has allowed domains configured, an HTTP or HTTPS URL must match an allowed origin by scheme, host and port. An origin mismatch returns 400. |
session_id | Response | The handle you store against your operation key and the path parameter for the decision. |
session_url | Decision response | The hosted flow. Send the person there once. |
status | Response | The current session state. Compare the documented status strings exactly. |
Failure cases and recovery
| Status | What happened | Retry | Recovery |
|---|---|---|---|
400 | Validation failed, or the balance cannot cover session creation | After fixing it | Read the response body. Fix the validation error or top up if the body reports insufficient credit |
401 | The key is wrong, malformed, revoked or expired | After fixing it | Check DIDIT_API_KEY or create a new key |
402 | The check could not be paid for, so it did not run | After topping up | Top up the balance, then retry |
403 | No key sent, no access to the resource, request outside the key's IP list, or the balance cannot cover the call | After fixing it | Read the body and the API key error table |
404 | The resource does not exist, or the session is outside the key's workflow or status limits | No | Check the id and the key's limits |
409 | Conflict with the current state. One listed cause is a reused Idempotency-Key. | Depends on code | Inspect code and reload state. Reuse an existing result only after confirming the same operation. |
410 | The resource expired | No | Create a new one |
415 | The body is not JSON | After fixing it | Send Content-Type: application/json |
429 | A middleware throttle or a quota was reached | Yes after Retry-After for a middleware throttle. Endpoint-specific caps keep their own contract. | Wait, then back off with jitter |
500 | An unexpected error on our side | Only when the endpoint's retry contract makes the operation safe to repeat | Inspect code when present. If a create may have succeeded and replay protection is unconfirmed, reconcile before another create. |
502 | A service we depend on returned an error | Only when the endpoint's retry contract makes the operation safe to repeat | Inspect code. Use backoff only when safe. Reconcile uncertain creates. |
503 | A service we depend on is unavailable, or the request timed out | Only when the endpoint's retry contract makes the operation safe to repeat | Inspect code. Use backoff only when safe. Reconcile uncertain creates. |
For 5xx, inspect the error code when present. Use backoff when the endpoint's retry contract makes the operation safe to repeat. If a create may already have succeeded and replay protection is unconfirmed, reconcile before sending another create.
A middleware throttle returns 429 with Retry-After in seconds, rounded up so that waiting it lands in the next window. The same response can carry X-RateLimit-Scope, X-RateLimit-Limit, X-RateLimit-Reset and a reference to quote to support. Endpoint-specific caps, resubmission cooldowns and idempotency conflicts keep their own error contracts, so do not assume this shape for every 429. Use Retry-After as the floor, then layer exponential backoff with jitter and stop after about five attempts.
Fixing and resubmitting an invalid request is not a retry of the same request. It is a new request after a change. A 500 may have no JSON body at all, so parse defensively before you read code.
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);
Make the webhook side idempotent
- Read the raw request body before you parse JSON.
- Verify
X-Signature-V2with constant-time comparison. It is HMAC-SHA256 over the sorted, Unicode-preserved canonical JSON.X-Signatureworks only if your stack does not re-encode the body. Check thatX-Timestampis within 300 seconds. For a webhook destination, accept a valid previous-secret signature during the 24 hours after rotation. Legacy application webhooks do not send previous-secret headers. - If you verified with the deprecated
X-Signature-Simple, retrieve the decision fromGET /v3/session/{session_id}/decision/before you apply any decision-dependent update, instead of trusting the payload, because that signature authenticates the envelope only. - Deduplicate by
event_idonly after verifying it withX-Signature-V2orX-Signature. If you verified withX-Signature-Simple, fetch the decision first and apply it idempotently using the authenticatedsession_idand the retrieved decision. Return2xxafter successful handling.
Per-target idempotency keys and deterministic uploader telemetry
A per-target key is scoped to the destination of the operation, not to the payload. The same payload sent to two different targets is two operations. Two different payloads can still describe one intended verification, and an identical payload can describe a later reverification.
In a verification flow the target is the subject. Assign a fresh request key to each intended verification, including a new verification for the same subject and workflow. Reuse that key only for attempts to complete the original operation. Keep the subject identifier stable across those verifications. On a KYB workflow the business goes in vendor_data, and the officers and owners are checked inside that session, with person AML and linked KYC billed per person when run.
Keep the operation key and correlation metadata fixed across attempts. Record the attempt number, latency and timestamp separately for each attempt. The create response and session webhooks carry session_id. If the create response is lost, match the operation using metadata authenticated by X-Signature-V2 or X-Signature, or retrieve the decision for the authenticated session ID and match its metadata. Use metadata only for correlation.
Two rules keep it deterministic. Never derive the key from a timestamp or from a random value generated inside the retry loop. Assign the operation key once when you start an intended verification. Preserve it across attempts. Assign a new key for a later verification, even when the subject, workflow and payload are identical.
Paid steps and review boundaries
Two sessions can produce two billable checks if both checks complete. Didit generally bills completed checks from prepaid credit. The pricing docs list exceptions, including some billable retries and no-match database lookups. Sandbox checks are mocked and cost nothing on every plan. See Didit pricing for the live list.
- A full ID check is $0.33 per completed check: ID document verification $0.15, passive liveness $0.10, face match 1:1 $0.05, device and IP analysis $0.03, at Didit pricing. The Create Session API starts that User Verification check.
- AML screening is $0.20 per check. Ongoing AML monitoring is $0.07 per person a year.
- Business verification starts at $2.00 per company. Registry retrieval varies by country and data tier. Company AML screening is $0.20 per check, person AML is $0.20 per UBO or officer, and linked KYC is billed per person when run.
- Reusable KYC, the workflow orchestrator and the MCP server are free.
If the decision returns In Review, read that session for updates. The decision response exposes assignee, waiting_since and sla_due_at for review state. When a reviewer overrides a status, status_override records the override and decision_trace describes how the status was reached.

Worked cost example
Assume 10,000 intended verifications, each with one original create and one completed full ID check. At list price, 10,000 multiplied by $0.33 is $3,300.00.
If 2% each generate one retry, there are 200 retries. If 100 of those retries create an extra session and all 100 extra checks complete, the additional list-price charge is 100 × $0.33 = $33, or $396 over 12 identical months.
The Growth and Scale figures below are usage charges before plan fees or included credit. On Growth, 10,000 multiplied by $0.3168 is $3,168.00. On Scale, 10,000 multiplied by $0.297 is $2,970.00. This example estimates the usage cost of extra completed checks. If a create has an unknown outcome, reconcile it before issuing another create for the same operation.
Sources
- Didit docs: API authentication
- Didit docs: Create Session API
- Didit docs: Retrieve Session API
- Didit docs: API errors, status codes and retry rules
- Didit docs: API rate limiting
- Didit docs: Webhooks and HMAC signing
- Didit docs: Sandbox test data
- Didit User Verification product page, read November 26, 2026
- Didit pricing page for the full ID check (User Verification) price and pricing in the docs, read November 26, 2026
- Didit MCP server
Next step: start free in the sandbox at https://business.didit.me/, no sales call. Create one session, save its session_id, repeat the decision read and confirm it refers to that session. Test ambiguous-create handling without issuing another create.
Try it
Try this in the sandbox
Run the check this guide describes, free.
The product this post is about, taken from its topic. Run it free in the sandbox.
Author
Alejandro Rosas
Co-founder and CTO

Questions
Frequently asked questions
What is an API idempotency key?
An API idempotency key is a value a client sends with a write request so the server can recognise a repeat of the same operation. One common implementation is for the server to store the key with the outcome, so a later request with that key returns the stored outcome instead of running the operation again. APIs differ on whether they return the original response, report an in-progress operation or reject a conflicting reuse.
Does Didit support idempotency keys on its API?
Didit's API error reference lists a reused Idempotency-Key as one possible cause of 409. Our Create Session documentation does not establish request-level replay protection for POST /v3/session/. vendor_data links sessions to a person or business and supports duplicate detection across sessions. Keep your own operation key for retry bookkeeping and do not assume a create replays a prior response.
What does HTTP 409 mean when I reuse an idempotency key on Didit?
A 409 signals a conflict. Inspect code if present and reload the relevant state. Reuse an existing result only after confirming it belongs to the same operation. Follow the recovery documented for that conflict.
Does vendor_data prevent duplicate Didit sessions?
vendor_data identifies the person or business and supports duplicate detection across sessions. The supplied Create Session docs do not say that repeating it prevents a second session from being created. Keep the value stable across verifications for the same subject and do not treat it as a request replay key.
What are per-target idempotency keys?
A per-target key is scoped to the destination of the operation rather than to the payload. The same payload sent to two targets is two operations. In a verification flow the target is the subject, but assign a fresh key to each intended verification, including a new verification for the same subject and workflow. Reuse the key only for attempts to complete the original operation.
How does deterministic uploader telemetry work with retries?
Keep the operation key and correlation metadata fixed across attempts. Record the attempt number, latency and timestamp separately for each attempt. The create response and session webhooks carry session_id. If the create response is lost, match the operation using metadata authenticated by X-Signature-V2 or X-Signature, or retrieve the decision for the authenticated session ID and match its metadata. Use metadata only for correlation.
Which Didit API errors are safe to retry?
For a Didit middleware throttle, wait at least the time in Retry-After, then back off with jitter. For other 429 responses, follow the endpoint-specific recovery instructions. For 5xx, inspect code when present and use backoff when the endpoint's retry contract makes the operation safe to repeat. A 409 depends on code, so inspect it and reload state. If a create may already have succeeded and replay protection is unconfirmed, reconcile before sending another create.
How do I deduplicate Didit webhooks?
Verify the signature with constant-time comparison and check that X-Timestamp is within 300 seconds. For a webhook destination, accept a valid previous-secret signature during the 24 hours after rotation; legacy application webhooks do not send previous-secret headers. If you use the deprecated simple signature, retrieve the decision before you apply any decision-dependent update instead of trusting the payload. Deduplicate by event_id only after verifying it with X-Signature-V2 or X-Signature. If you verified with X-Signature-Simple, fetch the decision first and apply it idempotently using the authenticated session_id and the retrieved decision. Return 2xx after successful handling.
Does a retried call cost me another check?
Two sessions can produce two billable checks if both checks complete. Didit generally bills completed checks from prepaid credit, and the pricing docs list exceptions, including some billable retries and no-match database lookups. Use one key per intended operation and read the decision of the session you already have instead of creating another. Sandbox checks are mocked and free.
How long should I keep an idempotency key?
Retain an application-generated operation key throughout your retry and reconciliation window. For a server-supported key, check that endpoint's retention policy before replaying. Didit's session_expiration_time controls the hosted link and does not document a request-key retention period.
Can I test idempotent retries without paying?
Yes. Every plan includes a sandbox application, and sandbox checks are mocked and free. Create one session, save its session_id, repeat the decision read and confirm it refers to that session. Use sandbox_scenario for a documented verification outcome and test ambiguous-create handling without issuing another create.
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.
Your obligations · 3 regions
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.
- 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.
Didit Academy


