Skip to main content

Idempotent API Clients for Reliable Identity Verification

Designing an idempotent API client is crucial for robust identity verification systems, ensuring consistent results despite retries and network issues.

Idempotent API Clients for Reliable Identity Verification

Contents

In this guide

Jump to the part you need.

Ensure Data ConsistencyImplement idempotent API calls to guarantee that repeated requests for identity verification do not lead to multiple, conflicting, or erroneous outcomes, maintaining data integrity.

Mitigate Network GlitchesDesign your client to handle transient network failures gracefully by safely retrying operations without unintended side effects, improving system resilience.

Prevent Duplicate ActionsUtilize unique idempotency keys for each request to allow the API to recognize and appropriately respond to replayed requests, preventing double processing of verification sessions.

Simplify Integration with DiditDidit's API is built with idempotency in mind, offering a developer-first experience that naturally supports reliable retries for ID Verification, Liveness, and AML Screening, simplifying your integration process.

The Challenge of Distributed Systems and Identity Verification

In today's interconnected digital landscape, identity verification is a cornerstone of trust and security. From onboarding new users to complying with AML regulations, businesses rely heavily on API-driven identity solutions. However, the very nature of distributed systems—with their inherent network latencies, timeouts, and potential for temporary service unavailability—introduces a significant challenge: how do you ensure that an operation, like initiating an ID verification check, is processed exactly once, even if the request is sent multiple times?

Without careful design, a simple network hiccup could lead to a client retrying a request, causing the verification system to process the same user's ID document or liveness check multiple times. This not only wastes resources but can also lead to inconsistent states, complicate auditing, and degrade the user experience. This is where the concept of idempotency becomes critical.

What is Idempotency and Why Does it Matter for KYC?

An operation is idempotent if executing it multiple times produces the same result as executing it once. In the context of API calls, an idempotent request means that if you send the same request payload with the same idempotency key repeatedly, the server will process it only once, and subsequent identical requests will return the original result without re-executing the underlying action.

For Know Your Customer (KYC) and identity verification processes, idempotency is paramount:

  • Preventing Duplicate Verifications: Imagine a user attempts to verify their ID, but a network error prevents your system from receiving the success response. Without idempotency, a retry might initiate a second, identical ID Verification session, leading to redundant work and potential charges.
  • Ensuring Consistent State: If an AML Screening check is initiated, and the response is lost, a retry with an idempotent client ensures the original screening status is returned, rather than triggering a new, potentially different, screening.
  • Simplifying Error Handling: Developers can implement robust retry logic without fear of unintended side effects, making their integration more resilient and easier to debug.

Designing an Idempotent API Client

To build an idempotent API client for identity verification, you need to leverage idempotency keys. These are unique, client-generated tokens that accompany each request. The server uses this key to detect duplicate requests within a specific timeframe (e.g., 24 hours).

1. Generate Unique Idempotency Keys

For every unique logical operation you perform (e.g., creating a new verification session for a specific user), generate a unique idempotency key. A UUID (Universally Unique Identifier) is an excellent choice for this. This key should be associated with the specific action you want to be idempotent.

Example: When initiating a new ID Verification session for user_id_123, generate idempotency_key_abc.

2. Include the Idempotency Key in Requests

Most APIs that support idempotency will expect a specific header, often Idempotency-Key, or a field within the request body. Ensure your client consistently includes this key for all relevant requests, particularly those that create or modify resources.

3. Implement Robust Retry Logic

When a transient error occurs (e.g., a 5xx server error, network timeout), your client should retry the request using the same idempotency key. Exponential backoff with jitter is a common strategy to space out retries and avoid overwhelming the server.

Consider the Create Session API for Didit's Business Console. If you're creating a verification link via API, you might send a POST request to /v3/session/. If this request times out, you can retry it with the same idempotency key. The Didit API will recognize the key, and if a session was already successfully created, it will simply return the existing session details, preventing a duplicate. This is crucial for products like Didit's ID Verification and Passive & Active Liveness checks.

4. Store and Manage Idempotency Keys

Your client application needs to store the idempotency key alongside the state of the operation. This allows you to retrieve the correct key if a retry is needed. Ensure the key is stored persistently if the application might crash or restart between the initial request and a potential retry.

Beyond Idempotency: Enhancing Reliability with Webhooks

While idempotency handles retries effectively, a truly reliable system also incorporates webhooks. Didit, for example, sends automated updates to your configured webhook URL as the user progresses through a verification flow and when the final result is ready. This push-based notification system complements idempotency by providing definitive status updates, reducing the need for your client to poll the API and further enhancing system resilience.

By combining an idempotent client with webhook notifications, you achieve a highly robust integration: your client can safely retry requests, and your system receives real-time updates on verification outcomes for products like AML Screening & Monitoring and Proof of Address, even if initial API responses are lost.

How Didit Helps

Didit is designed from the ground up to support highly reliable and idempotent integrations, making it an ideal choice for businesses that prioritize robustness and developer experience. Our AI-native platform provides a modular architecture, allowing you to compose verification workflows with ease, and our APIs are built with idempotency in mind.

When you create a session for Didit's ID Verification, Passive & Active Liveness, 1:1 Face Match, or AML Screening, our system inherently handles the idempotency of these creation requests. This means your development team can focus on building your core product, knowing that retrying session creation calls won't lead to unintended duplicate verifications or erroneous charges. Didit's commitment to a developer-first approach includes providing comprehensive documentation and clean APIs that simplify the implementation of resilient retry mechanisms. Furthermore, with Didit's Core KYC on pay-per-use pricing, you can implement these robust solutions without upfront costs, only paying per check. Our no-setup-fee model and AI-native capabilities ensure that your identity verification processes are not only reliable but also efficient and scalable.

Ready to Get Started?

Ready to see Didit in action? Get a free demo today.

Start verifying identities for free with Didit's free tier.

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

Blog questions

Who writes the Didit blog?
The Didit team. Guides reviewed by Alberto Rosas, co-founder and CEO, carry his byline. The rest are published as Didit.
Which topics does the blog cover?
Eight topics: ID verification, business verification (KYB), AML, sanctions and compliance, fraud prevention, transaction monitoring and crypto, country guides, agents and developers, and product updates.
Is the blog available in my language?
Yes, in 15 languages: English, Spanish, French, German, Brazilian and European Portuguese, Catalan, Russian, Arabic, Chinese, Japanese, Hindi, Indonesian, Korean and Swahili. Not every post is translated, so each language shows the posts it has.
Where do I find product updates?
In the changelog at /changelog/ and under the Product updates topic.
Are these posts legal advice?
No. Regulation posts explain rules; your legal team decides how they apply.
How do I find posts on one topic?
Open one of the eight topics, or search the blog.
Are posts dated?
Yes. Every post shows when it was published and when it was last updated.
Do posts link to the docs?
Developer posts link to the matching page on docs.didit.me and to the API reference.
Is the blog the same as the docs?
No. The blog explains rules, markets and product changes for a general reader, while docs.didit.me holds the integration guides and the API reference. Developer posts link the matching docs page and the API reference they describe.

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.