Skip to main content

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.

Idempotency Keys for APIs: A Developer's Guide (2026)

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

Idempotency answers with the current Didit facts
QuestionAnswer
Session entity identifiervendor_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 keyA 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 retryFor 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 retry400, 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, currentGrowth 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

What to do with the result of a create attempt
SituationWhat you haveAction
Successful create with a session IDA session_id and a hosted flowStore 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 IDNo session_idThe outcome is unknown. If you cannot identify a known session, do not automatically send another create. Reconcile with your records first.
HTTP 409A conflict response, possibly with codeInspect 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 webhookAn event_id you have seenDeduplicate 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.
A session overview with its warnings in the Didit Business Console
A session overview in the Didit Business Console. This is the record you read when you have a 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-Key as one possible cause of 409. Our Create Session documentation does not establish request-level replay protection for POST /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_time controls 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 or sk_live_ for a live one, followed by 43 URL-safe characters. Treat it as a server-side secret.
  • The workflow_id UUID 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 callback must match an allowed origin by scheme, host and port. An origin mismatch returns 400.
  • A place in your application to keep your operation key next to any session_id you receive. That store is yours, not ours.

Create a Didit session and handle uncertain retries

  1. 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.

  2. Create or copy an API key in the Didit Business Console under Developers, then API keys. New keys start with sk_test_ or sk_live_, followed by 43 URL-safe characters. Treat the key as a server-side secret.

  3. 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"}'

    metadata is echoed back in responses and webhooks for correlation and is not shown to the user. tags are returned on create and support filtering in the console, with up to 10 tags of up to 50 characters each.

  4. 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 or vendor_data, so avoid automatically sending another create.

  5. 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_ID to the ID returned by the create call. The key must hold the read:sessions privilege.

    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.

  6. 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.

  7. 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.

  8. In the sandbox, create one session with sandbox_scenario set to a slug from GET /v1/sandbox/scenarios/. Save its session_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

The subject identifier stays stable and the operation key changes only for a new verification
EventSubject identifierOperation keyWhat changes
First verificationvendor_data user-42op-2026-11-26-001Create the session and store the session_id.
Network retryvendor_data user-42, unchangedop-2026-11-26-001, unchangedIf the session_id is known, read the decision. If it was lost, reconcile and do not automatically create.
Later reverificationvendor_data user-42, unchangedop-2027-05-01-001, newTreat 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.

Didit Business Console session detail showing the ID document result
Reading the decision of a known session is how you check what already happened.

Inputs and outputs

What you send, what comes back, and why each field matters for a retry
FieldDirectionWhy it matters for idempotency
x-api-keyRequest headerAuthenticates 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_idRequest body, UUIDThe workflow that runs. A KYC workflow creates a user session, a KYB workflow creates a business session.
vendor_dataRequest body, stringYour 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.
metadataRequest body, objectArbitrary JSON, echoed back in responses and webhooks. Use it for correlation. The supplied docs do not define it as a replay key.
tagsRequest body, arrayUp to 10 names, 50 characters each, returned on create and filterable in the console.
callbackRequest body, URLRedirect 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_idResponseThe handle you store against your operation key and the path parameter for the decision.
session_urlDecision responseThe hosted flow. Send the person there once.
statusResponseThe current session state. Compare the documented status strings exactly.

Failure cases and recovery

Didit HTTP statuses, whether to retry, and what to do instead
StatusWhat happenedRetryRecovery
400Validation failed, or the balance cannot cover session creationAfter fixing itRead the response body. Fix the validation error or top up if the body reports insufficient credit
401The key is wrong, malformed, revoked or expiredAfter fixing itCheck DIDIT_API_KEY or create a new key
402The check could not be paid for, so it did not runAfter topping upTop up the balance, then retry
403No key sent, no access to the resource, request outside the key's IP list, or the balance cannot cover the callAfter fixing itRead the body and the API key error table
404The resource does not exist, or the session is outside the key's workflow or status limitsNoCheck the id and the key's limits
409Conflict with the current state. One listed cause is a reused Idempotency-Key.Depends on codeInspect code and reload state. Reuse an existing result only after confirming the same operation.
410The resource expiredNoCreate a new one
415The body is not JSONAfter fixing itSend Content-Type: application/json
429A middleware throttle or a quota was reachedYes after Retry-After for a middleware throttle. Endpoint-specific caps keep their own contract.Wait, then back off with jitter
500An unexpected error on our sideOnly when the endpoint's retry contract makes the operation safe to repeatInspect code when present. If a create may have succeeded and replay protection is unconfirmed, reconcile before another create.
502A service we depend on returned an errorOnly when the endpoint's retry contract makes the operation safe to repeatInspect code. Use backoff only when safe. Reconcile uncertain creates.
503A service we depend on is unavailable, or the request timed outOnly when the endpoint's retry contract makes the operation safe to repeatInspect 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

  1. Read the raw request body before you parse JSON.
  2. Verify X-Signature-V2 with constant-time comparison. It is HMAC-SHA256 over the sorted, Unicode-preserved canonical JSON. X-Signature works only if your stack does not re-encode the body. 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.
  3. If you verified with the deprecated X-Signature-Simple, retrieve the decision from GET /v3/session/{session_id}/decision/ before you apply any decision-dependent update, instead of trusting the payload, because that signature authenticates the envelope only.
  4. 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.

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.

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.

How Didit billing works: credits, auto-recharge and volume discounts
Billing is per completed check from prepaid credit, so an extra completed check is a cost.

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

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.

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 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.

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.