Idempotency Keys for Resilient API Integrations: How-To Guide
A reused idempotency key is one documented cause of HTTP 409. This guide shows how to read the response, look for the original session when the ID is missing, and avoid a duplicate verification. Full KYC costs $0.33.

Contents
In this guide
Jump to the part you need.
This guide is for developers who need to avoid duplicate verification sessions after a failed or ambiguous request. It shows how to use an idempotency key where an endpoint documents support, how to read our 409 response, and how to look for the original session when the response and the session ID are both missing. A full KYC check costs $0.33. The caveat: we do not document idempotency support for every endpoint.
Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.
| What you observe | What to do next | Where it comes from |
|---|---|---|
| Request succeeded and you have a session ID | Store the ID, then read GET /v3/session/{id}/decision/ | Sessions API overview |
HTTP 409 with an error code | Inspect the code. If you already have the session ID, reload the state | API errors |
HTTP 409 without an error code | If you have no session ID, treat the outcome as unresolved | API errors |
Middleware HTTP 429 | Wait at least Retry-After, then use capped backoff with jitter | Rate limiting |
Timeout or 5xx and no session ID | The write outcome is unknown. Do not create another session until you confirm it | API errors |
| Published verification prices | Full KYC $0.33 per completed check. KYB from $2.00 per company | Live price feed, November 26, 2026 |
Start free in the sandbox at business.didit.me (no sales call). For developers, connect the Didit MCP server to an AI assistant through didit.me/developers/mcp. The technical entry point is the Sessions API overview, the matching product page is User Verification, and every unit price is on didit.me/pricing.
What an idempotency key does, and what Didit documents
An idempotency key identifies one logical operation. When an endpoint documents support, the client sends the same key with every attempt, so the server can tell a retry from a new request. We list a reused Idempotency-Key as one documented example of HTTP 409 in our API errors reference. That is a cause of a conflict, not proof that every endpoint accepts the header.
Use same-key retries only where the endpoint explicitly documents support. For session creation, status updates, uploads, batch endpoints and other writes, check the endpoint reference first. If support is not documented, do not present the header as a Didit guarantee.
What the key does not do:
- It does not validate a payload. A
400for a missingworkflow_idis still a400on the next attempt. - It does not merge two different keys. Changing the key removes the retry association provided by the original key. Other endpoint constraints may still reject the write.
- It does not replace webhook deduplication. Key your handler on
event_id. - It does not by itself recover a session ID you never received.
vendor_data is your identifier for the entity, such as user-42. It is an entity reference, not proof that an operation is unique.
Prerequisites
- A Didit application and API key. Newly issued keys start with
sk_test_for sandbox orsk_live_for live, followed by 43 URL-safe characters. Older keys may have no prefix and remain valid. - The
workflow_idof the workflow you want to run. The workflow type decides whether the session is a User Verification (KYC) session or a Business Verification (KYB) session. - Your entity reference for
vendor_data, such asuser-42. - curl or another HTTP client, and access to the Didit Business Console to confirm session state.
Step-by-step: create a session and handle an ambiguous result
Get a sandbox key. In the Business Console open Developers, then API keys, and copy the sandbox application key. You can also create one programmatically:
POST https://apx.didit.me/auth/v2/programmatic/register/emails a 6-character code, andPOST https://apx.didit.me/auth/v2/programmatic/verify-email/returnssandbox_application.api_key. Keep the key server-side, never in a browser or mobile bundle.Check endpoint support before you rely on a key. Read the endpoint reference and the API errors page. A reused key is one documented cause of
409. If the endpoint does not document idempotency support, do not add the header as if Didit guarantees it.Create the session exactly as API Authentication shows. The documented create call is
POST /v3/session/on the verification host, authenticated withx-api-key. This is the same curl shown in API Authentication, with no extra idempotency header: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"}'If the response is lost, look for the original session before anything else. A timeout or a
5xxcan leave the result of a write unknown. If you have thesession_id, retrieve the decision withGET /v3/session/{id}/decision/. If the session ID is missing, check the Didit Business Console, callGET /v3/sessions/as documented in the Sessions API overview, or look for a verified session webhook. Compare the available workflow, the entity reference and the creation time.vendor_datais an entity reference that can match several sessions, so it does not prove which session is yours. If you can confirm a match, retrieve the decision using itssession_id. If the match remains uncertain, keep the operation unresolved.Handle a 409 by reading the status and the code. A reused key is one documented cause. Inspect the error
codewhen it is present. If you already have the session ID, reload the state withGET /v3/session/{id}/decision/. If the original response was lost and you have no ID, the outcome is unresolved. Do not mint a new key to get past the conflict.Treat a middleware 429 separately. For a middleware
429, useRetry-Afteras the minimum delay and apply capped backoff with jitter. The rate limiting reference gives the 5s, 10s, 20s and 40s example with a small attempt ceiling. For other429responses, follow the endpoint's error contract.Make the webhook handler idempotent. Read the raw body before parsing. Verify
X-Signature-V2by computing HMAC-SHA256 over sorted, Unicode-preserved canonical JSON and comparing signatures in constant time. Checkabs(now - X-Timestamp) <= 300seconds. The current secret verifiesX-Signature-V2. After a destination secret is rotated, the replaced secret verifiesX-Signature-V2-Previous, which is sent for 24 hours after the rotation; accept a valid match on either and keep the timestamp freshness check. Then apply the event keyed onevent_id, return 2xx promptly and update state idempotently. See the webhook reference.Keep review boundaries outside retries.
"In Review"requires a human decision. A reviewer may act through the Console or the documentedPATCH /v3/session/{id}/update-status/API. Use the webhook status and read the decision object when present. See verification statuses and the webhook reference. Nothing in an idempotency key moves a session to"Approved".
Expected output
A successful create returns a session object. The fields you rely on include session_id, session_kind, session_url, status, workflow_id and vendor_data. Status values are exact and case-sensitive, as listed in the verification statuses reference.
{
"session_id": "...",
"session_kind": "user",
...
}

Inputs and outputs
| Item | Direction | Example | Why it matters for retries |
|---|---|---|---|
x-api-key | Input, header | sk_test_... | A wrong or expired key answers 401. Fix it before retrying |
Idempotency-Key | Input, header, only where documented | A client-generated operation ID | Lets an endpoint that documents support recognise attempts. It is not a Didit-wide guarantee |
workflow_id | Input, body | UUID of the workflow | Must not change between attempts |
vendor_data | Input, body | user-42 | Your entity reference. It is not proof of operation uniqueness |
metadata | Input, body | Free-form JSON | Use it for analytics tags or a schema version, not the key |
callback | Input, body | Your return URL | Use the same value on every attempt |
session_id | Output | UUID | Store it when you see it. It is how you recover the decision |
event_id | Output, webhook | UUID | Your deduplication key on the webhook side |
Failure cases and recovery
| Status | Meaning in this flow | Retry | Recovery |
|---|---|---|---|
400 | A field failed validation, or on session creation an ordinary insufficient-credit response | After fixing or topping up | Fix what the body names, or add credit |
401 | Key wrong, malformed, revoked or expired | After fixing | Issue or fetch a valid key |
402 | A check could not be paid for, as in some standalone API families such as bank account check | After topping up | Add credit |
403 | No key, a scoped key without access, an IP outside the key list, or a low balance on most standalone APIs. On a contract, session create can return contract_billing_suspended | After fixing | Read the body, then adjust the key, the balance or the billing state |
404 | No such resource, or the session is outside the key's workflow or status limits | No | Check the ID and the key scope |
409 | A conflict with current state, for example a reused Idempotency-Key or a step that already ran | Depends on code | Read code. If you have the session ID, reload state |
410 | The session or invitation expired | No | Create a replacement only when that is intended |
415 | The body is not JSON | After fixing | Send Content-Type: application/json |
429 | A rate limit or quota was reached | Yes, after waiting | For a middleware 429, use Retry-After as the minimum delay. For other 429 responses, follow the endpoint contract |
500, 502, 503 | Unexpected error, dependency error, or a temporary failure such as query_timeout. A timed-out session create or a 5xx can leave the outcome unknown | Only after you reconcile the original write | Read code when present, then reconcile the original write before sending another create, unless the endpoint explicitly documents a safe retry for that request. If the documented retry uses an idempotency key, reuse the original key and payload |
403 with application_deleted | The key's application was deleted | No | Use a key from an application that exists |
Error bodies do not share one envelope, and a 500 may carry no JSON at all, so parse defensively. This snippet is from the Didit error reference:
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);
A timeout or 5xx can leave the result of a write unknown, so reconcile the original write before sending another create, unless the endpoint explicitly documents a safe retry for that request. If the documented retry uses an idempotency key, reuse the original key and payload. If you have a session ID, retrieve the decision. If you do not, look for the original session in the Didit Business Console or through GET /v3/sessions/. Treat the operation as unresolved until you can confirm its outcome, and do not create another session in the meantime.
Sandbox checks and what to record
Run these checks in the sandbox before using a live key.
| Test | How to simulate | What to record |
|---|---|---|
| Confirmed success | Send the documented create call | The status, any error code and the session_id. Confirm the session in the console |
| Lost response after request send | Kill the client after the request is sent and before the response is read | The observed status, any error code and any session ID. Verify session state through the console or a known session ID |
| 409 observation | Only on an endpoint that documents idempotency support, send the same key twice | The observed status, any error code and any session ID. Treat replay observations as test results only |
| Middleware 429 | Simulate a middleware 429 with a Retry-After header | Whether the client waits at least Retry-After, then backs off with jitter |
| 5xx with no JSON body | Have a proxy return a non-JSON 500 | The parser falls back to the status code, and the client checks the outcome before another create |
| Duplicate webhook | Deliver the same event_id twice | The handler applies the status once and returns 2xx promptly |
If you test the real throttle instead of a simulated one, the generic write limit is 300 requests per minute and the session-create scope is 600 per minute. The first scope to exceed its counter returns 429.
Paid steps and what a duplicate costs
The sandbox is free on every plan and every check is mocked, so the checks above cost nothing. On live keys, billing is per completed check from prepaid credit. A full KYC check is $0.33: ID document verification $0.15, passive liveness $0.10, face match 1:1 $0.05, and device and IP analysis $0.03. KYB is priced by country and data tier from $2.00 per company, with each owner or officer taking a linked full ID check and person AML. The docs pricing page notes that some no-match database lookups and retries are billable, so read it before you assume every retry is free.

Worked cost example
Take 5,000 intended KYC checks a month with AML screening on each, at list prices. KYC: 5,000 x $0.33 = $1,650.00. AML: 5,000 x $0.20 = $1,000.00. Total: $1,650.00 + $1,000.00 = $2,650.00. Together, full KYC and AML screening cost $0.53 per completed pair at list prices, since $0.33 + $0.20 = $0.53.
Now suppose 1.5% of 5,000 intended sessions each yield one duplicate and all 75 duplicates complete both checks. The added list-price usage is 5,000 x 0.015 x ($0.33 + $0.20) = 75 x $0.53 = $39.75. Charges are based on completed checks. A key can prevent a duplicate session only where the endpoint documents idempotency support. It does not guarantee those savings by itself.
On Scale the 10% discount applies to Didit prices: full KYC $0.297 and AML $0.18, so 5,000 x ($0.297 + $0.18) = 5,000 x $0.477 = $2,385.00. The difference against list is $2,650.00 - $2,385.00 = $265.00 a month. Scale itself is $299 a month with $350 of monthly credit, so model the credit and the top-up separately on the pricing page.

Sources
- Didit API errors: status codes, bodies and fixes
- Didit API rate limiting: limits, headers and 429 backoff
- Didit webhooks: events and HMAC signing
- Didit verification statuses
- Didit API authentication
- Didit Sessions API overview
- Didit create session
- Didit pricing in the docs
- Didit pricing page and pricing.json, plus the live price feed read November 26, 2026
- Didit MCP server
- User Verification product page
Next step: open the sandbox at business.didit.me, create a test session, and record the status, any error code and any session ID. Confirm the session in the console before creating another. No sales call is needed to start.
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 idempotency key in an API integration?
An idempotency key is a client-generated identifier for one logical operation, sent with attempts at that operation when an endpoint documents support. The idea is that the server can tell a retry from a new request. We list a reused Idempotency-Key as one example cause of HTTP 409 in our API errors reference. It does not establish support for every endpoint.
Does Didit support idempotency keys on session creation?
The documented POST /v3/session/ example does not use an Idempotency-Key header. Check the reference for the specific endpoint before relying on same-key retries. Our API errors reference only lists a reused key as one possible cause of 409. Use same-key retries only where the endpoint explicitly documents support. Otherwise, treat the header as undocumented for that call.
What should I do after a 409 from Didit?
A reused key is one documented cause of HTTP 409. Read the HTTP status and inspect the error code when present. If you already have the session ID, retrieve the decision with GET /v3/session/{id}/decision/. If the original response was lost and you have no ID, treat the outcome as unresolved.
How do I identify a session after a lost response?
Use a session ID you already recorded, check the Didit Business Console, call GET /v3/sessions/ or look for a verified session webhook. Compare the workflow, the entity reference and the creation time, because vendor_data can match several sessions. If you can confirm a match, call GET /v3/session/{id}/decision/ with its session_id. If the match stays uncertain, leave the operation unresolved.
When should I create a new verification session?
Create a new session only when you intentionally want a new verification. First confirm that an earlier ambiguous request did not already create one. Our API errors reference gives no retention window for idempotency keys, so do not invent a cutoff and then open a second session while the first outcome is unknown.
How long should an idempotency key stay valid?
Our API errors reference gives no retention window for idempotency keys. A general design rule is to cover your retry window, but that is not a guarantee we make. Keep the ambiguous operation unresolved until you can confirm its outcome before creating another session.
Is it safe to retry a Didit call after a timeout?
A timeout or 5xx can leave the outcome unknown, so reconcile the original write before sending another create unless the endpoint explicitly documents a safe retry, and reuse the original key and payload when that retry uses an idempotency key. For a middleware 429, use Retry-After as the minimum delay and apply capped backoff with jitter. For other 429 responses, follow the endpoint's error contract.
Which Didit errors should I retry?
For a middleware 429, wait at least as long as Retry-After before retrying. For other 429 responses, follow the endpoint's error contract. For 500, 502 and 503, the outcome can be unknown, so reconcile the original write before another create unless the endpoint explicitly documents a safe retry, and reuse the original key and payload when the documented retry uses an idempotency key. Do not retry 400, 401, 402, 403 or 415 until you have fixed what they name. After 404, check the ID and key scope, and after 410, create a replacement only when that is intended.
How do I deduplicate webhook deliveries?
Read the raw body before parsing, verify X-Signature-V2 with HMAC-SHA256 over sorted, Unicode-preserved canonical JSON in constant time, and check that abs(now - X-Timestamp) <= 300 seconds. The current secret verifies X-Signature-V2, and the replaced secret verifies X-Signature-V2-Previous when that header is present, so accept a valid match on either and keep the freshness check. Then apply the event keyed on event_id, return 2xx promptly and update state idempotently.
Do retries cost money on Didit?
Billing is per completed check from prepaid credit. A full KYC check is $0.33 and KYB starts at $2.00 per company. The docs pricing page states that some no-match database lookups and retries are billable, so check it for the endpoints you use. A duplicate session that completes checks is a billable event.
How do I test idempotency before going live?
Run the sandbox checks: confirmed success, a lost response after request send, a 409 observation where the endpoint documents support, a simulated middleware 429, a non-JSON 500 and a duplicate webhook. Record the observed status, any error code and any session ID. Verify session state through the console or a known session ID, and treat replay observations as test results only.
Can I use idempotency keys for GET requests?
You do not need to. A GET reads state, so repeating it has the same effect as calling it once. Keys belong on calls that change state, and only where the endpoint documents support.
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


