Skip to main content

API Security for Sensitive Identity Data: 8 Steps for 2026

Secure identity APIs with server-side scoped keys, HMAC signed webhooks, retry-aware error handling and configurable retention. A full Didit KYC check is $0.33 and the sandbox is free.

API Security for Sensitive Identity Data: 8 Steps for 2026

Contents

In this guide

Jump to the part you need.

This guide fits engineering and security teams that call an identity API and then hold the identity data it returns. It covers keys, webhooks, error handling, retention and deletion against Didit's documented endpoints. A full KYC check lists at $0.33 per completed check and the sandbox is free on every plan. The main caveat: the API key is a server-side secret, so never let it reach a browser or mobile bundle.

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

Identity API risks and the control that closes them
RiskControlWhere it is documented
Key copied into a browser or mobile bundleKey lives on the server only, one key per workloadAPI authentication
Key reaches more than it shouldScoped keys with workflow, status and IP limitsAPI errors
Forged webhook changes a decisionHMAC-SHA256 X-Signature-V2 and a 300 second timestamp windowWebhooks
Wrong or missing key fails silentlyBranch on 401, 403 and the body codeAPI errors
Runaway loop exhausts the quotaRespect Retry-After and cap retriesRate limiting
Identity data kept longer than allowedRetention window plus the delete session callData retention

Start free in the sandbox at business.didit.me, no sales call. Developers who want an assistant to drive the integration can connect Didit through the Didit MCP server, and every list price sits on Didit pricing.

What an identity API exposes

An identity API accepts an ID document, a selfie, often a phone number, an email or an address, and returns decisions about a person. The decisions are the sensitive part. A document step returns extracted fields and authenticity results. Liveness and face match return whether a live person was present and whether that face matches the document portrait. Device and IP analysis returns location and device signals. AML screening returns list hits. Didit serves 4,000+ companies. The platform scores every session against 200+ fraud signals. Those results are available through the API and Business Console, so secure both access paths.

Two access paths are the boundary you defend. Routes on verification.didit.me take a long-lived API key in the x-api-key header. Routes on apx.didit.me take Authorization: Bearer plus a JWT access token, which you replace by logging in again when the API answers 403. Webhook payloads use HMAC signatures rather than either API authentication scheme. The API key is the long-lived secret of the three, so every control below starts with it and works outward to webhooks, errors, retention and deletion.

A verification session overview in the Didit Business Console with its warnings and status
A session overview in the Didit Business Console, with the warnings the API returns for that session.

Prerequisites

  • A Didit application, because every API key belongs to an application. The sandbox application is free.
  • The workflow_id of a published workflow, since a session cannot start without one.
  • A server that holds secrets as environment variables, and a deploy process that never writes them into client code.
  • An HTTPS endpoint that can receive POST requests and read the raw request body before JSON parsing.
  • Access to Developers and then API keys in the Business Console for the person who issues keys.

Eight steps to secure an identity API

  1. Separate the two hosts and their auth schemes. Didit has two hosts and they do not share a key format. https://verification.didit.me serves every /v3 route (sessions, workflows, entities, transactions, standalone APIs, lists, webhooks, billing) and authenticates with an x-api-key header. https://apx.didit.me serves account, organization and application management and authenticates with Authorization: Bearer plus a JWT access token. The verification API does not use OAuth Bearer tokens.
  2. Get a key and store it as a server-side secret. Two calls create the organization and return both applications inline, one sandbox and one live:
    curl -X POST https://apx.didit.me/auth/v2/programmatic/register/ -H "Content-Type: application/json" -d '{"email": "you@yourdomain.com", "password": "StrongP@ss1"}'
    curl -X POST https://apx.didit.me/auth/v2/programmatic/verify-email/ -H "Content-Type: application/json" -d '{"email": "you@yourdomain.com", "code": "A3K9F2"}'
    Persist sandbox_application.api_key as DIDIT_API_KEY and application.api_key as DIDIT_LIVE_API_KEY. New keys start with sk_live_ or sk_test_ followed by 43 URL-safe characters, and keys created before that format have no prefix, so never validate a key by its prefix.
  3. Give each service its own scoped key. In the Business Console open Developers then API keys. The Primary key is the application's own secret. Create a new key for each service or partner so one leak does not reach every workflow. A key can be limited to particular workflows and statuses, and to an IP allow list. A key called from outside its IP list returns 403, and a key used on a session outside its limits returns 404.
  4. Create sessions from your server, never from the client. Session creation is one billable route. Other standalone APIs have their own published prices. The call itself is short:
    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"}'
    vendor_data is your own user id, and the webhook envelope echoes it back so you can correlate events with your records. Keep the returned session_id as well, because the decision call and the delete call both need it. callback is where the user lands when the flow ends.
  5. Verify every webhook before you read the body. Read the raw request body before parsing JSON. Reject anything where abs(now - X-Timestamp) is over 300 seconds. Recompute HMAC-SHA256 with the destination signing secret over the sorted, Unicode-preserved canonical JSON and compare in constant time against X-Signature-V2, the recommended header. X-Signature signs the exact raw bytes and only works if your stack does not re-encode the body. Accept a match on X-Signature-V2-Previous when it is present, because Didit sends the previous signature for 24 hours after a secret rotation. X-Signature-Simple authenticates the envelope only, so if you verify with it, re-fetch the decision from GET /v3/session/{session_id}/decision/ instead of trusting the payload. Return 2xx quickly and write idempotently on event_id.
  6. Branch on status and body code, not on message text. Error bodies do not share one envelope: most carry detail, some add code, standalone APIs use error, and a 500 may have no JSON at all. 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);
    Rely on the status first and on code when it is present, because the text of a message can change.
  7. Back off correctly on 429. Didit counts requests per x-api-key in 60 second fixed windows and returns Retry-After plus X-RateLimit-Scope when a scope is exhausted. Session creation is capped at 600 per minute per key, generic-get at 600 per minute, and the v1 and v2 decision paths at 100 per minute. Wait at least Retry-After, then layer exponential backoff with jitter and stop after a small ceiling so a runaway loop does not keep burning quota.
  8. Set retention and delete on request. In the Business Console open App Settings then Data retention and pick a window from 1 month to 10 years. A new application starts at the longest window its plan includes. For an erasure request, delete the session and ask for the biometric template to go with it:
    curl --request DELETE --url https://verification.didit.me/v3/session/SESSION_ID/delete/ --header 'x-api-key: YOUR_API_KEY' --header 'Content-Type: application/json' --data '{"deletion_instruction": "privacy_erasure"}'
    A 200 response reports what happened to the face biometric data in face_retention_outcome, and a 404 means the session was already deleted.
The ID document result of a session in the Didit Business Console, showing extracted fields and checks
What the API returns for the document step, shown in the session detail of the Didit Business Console.
The liveness result of a session in the Didit Business Console
The liveness result for the same session. It is the kind of record your retention window governs.

Expected output

A correct verify-email call returns the access token, the refresh token, the organization and both applications with their keys:

200 OK
access_token, refresh_token, organization
application: { api_key, client_id, uuid, mode: "live" }
sandbox_application: { api_key, client_id, uuid, mode: "sandbox" }

A throttled request returns the scope that tripped and the wait, so your client can pause instead of guessing:

HTTP/1.1 429 Too Many Requests
X-RateLimit-Scope: session-v2-create
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 0
Retry-After: 37

{"detail": "Session creation rate limit exceeded. You can make up to 600 requests per minute.", "limit": 600, "remaining": 0, "reset": 1794358860, "window_seconds": 60}

Failure cases and recovery

API failures, what they mean and how to recover
StatusWhat it meansRecovery
401Key wrong, malformed, revoked or expiredCheck DIDIT_API_KEY or log back in to recover the key. Do not retry the same key.
403No key sent, key lacks access, call came from outside the key's IP list, or the balance cannot cover the callRead the body, then use a key with that access or fix the IP list
403 with code application_deletedThe key's application was deletedStop. The application and its keys no longer exist. Use a key of an application that exists.
404 on a session routeThe session sits outside the key's workflow or status limitsUse a key whose limits include that session
402, or 403 with insufficient_creditsThe check could not be paid for, so it did not runTop up at business.didit.me, then retry
409Conflict, for example a reused idempotency key or a step that already ranRead code, reload state, retry only if the code allows
429A rate limit or quota was reachedWait for Retry-After, add jitter, cap the attempts
500, 502, 503An unexpected error, or a service Didit depends on is downRetry with backoff, then contact support

Inputs and outputs

What your integration sends and what it receives
DirectionFieldNotes
Inputx-api-keyServer-side only, one key per workload
Inputworkflow_idThe published workflow the session runs
Inputvendor_dataYour own user id, echoed back in the webhook so you can correlate events
InputcallbackWhere the user returns when the flow ends
Inputdeletion_instructionSet to privacy_erasure to purge a retained biometric template
Outputsession_idUsed for the decision call and for deletion
OutputstatusApproved, Declined, In Review, In Progress, Not Started, Abandoned, Expired, Kyc Expired, Resubmitted, Awaiting User
Outputwebhook_typestatus.updated, data.updated, transaction.created and the other listed event families. There is no wildcard.
OutputdecisionPer-feature arrays: id_verifications, liveness_checks, face_matches, aml_screenings, ip_analyses and the rest

The sandbox is free and every check is mocked there, so key handling, webhook verification and deletion cost nothing to test. Live calls are paid per completed check from prepaid credit. A full KYC check is $0.33, AML screening is $0.20, proof of address is $0.20 and wallet screening is $0.15 per screening. A session create that cannot be paid for does not run the checks: POST /v3/session/ answers 400 when the balance cannot cover it. You can review the AML side on the AML screening page and the full list on Didit pricing.

The review boundary sits in the status. A session can have status In Review. Treat that status as pending in your system until it reaches an approved or declined status. Do not mark a user as verified because a session was created, and do not read an interrupted flow as an approval. Every price here is a published list price read from the live feed on November 26, 2026, so check the same line on Didit pricing before you commit a budget.

Worked cost example

Take 5,000 new users a month, each with a full KYC check and an AML screening, at list prices:

  • KYC: 5,000 x $0.33 = $1,650.00
  • AML screening: 5,000 x $0.20 = $1,000.00
  • Monthly total at list price: $2,650.00

On the Scale plan every Didit price drops 10 percent, so the KYC line is 5,000 x $0.297 = $1,485.00 and the AML line is 5,000 x $0.18 = $900.00, for $2,385.00 in usage. The plan fee is $299.00 a month and includes $350.00 of credit, so $2,385.00 minus $350.00 leaves $2,035.00 in top-ups, and $299.00 plus $2,035.00 is $2,334.00 paid that month. On Growth the same math runs at 4 percent off, with $99.00 a month and $115.00 of credit.

Sources

Next step: create a free sandbox application at business.didit.me, run one session with a sandbox key, and wire key handling, webhook verification and deletion before you spend anything. No sales call is needed to start.

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 API security for identity data?

It is the set of controls around the endpoints that accept documents, selfies and personal details and return decisions about a person. It covers how callers authenticate, what each key can reach, how signed events are verified, how failures are handled and how long the data is kept. The data is the target, so the API is the boundary you defend.

What is an identity API?

An identity API is a server-to-server interface that runs identity checks and returns results as data instead of a screen. At Didit one call creates a session from a published workflow, and the result comes back through the decision endpoint and through signed webhooks. The same open API covers ID checks, liveness, face match and AML screening.

How does Didit authenticate API requests?

Every /v3 route on verification.didit.me takes a long-lived key in the x-api-key header. Account, organization and application management on apx.didit.me takes Authorization: Bearer with a JWT access token. The verification API does not use OAuth Bearer tokens. A missing key returns 403 and a wrong, revoked or expired key returns 401.

Where should I store the Didit API key?

On the server only, as an environment variable such as DIDIT_API_KEY, and never in frontend code, a public repository or a mobile bundle. Give each service or partner its own key so one leak has a small blast radius, and limit that key to the workflows, statuses and IP ranges it needs.

How do I verify a Didit webhook signature?

Read the raw body before parsing, reject requests older than 300 seconds by X-Timestamp, recompute HMAC-SHA256 with the destination signing secret and compare in constant time against X-Signature-V2. Accept a match on X-Signature-V2-Previous while you rotate a secret. If you fall back to X-Signature-Simple, re-fetch the decision from the API rather than trusting the payload.

What happens when a Didit API call returns 401 or 403?

A 401 means the key is wrong, malformed, revoked or expired, so fix the key or recover it by logging in again. A 403 means no key was sent, the key lacks access to that resource, the call came from outside the key's IP list, or the balance cannot cover it. Do not loop on either status, because retrying the same request changes nothing.

How do I handle Didit rate limits?

Didit counts requests per API key in 60 second windows and returns 429 with Retry-After when a scope is exhausted. Wait at least that long, then add exponential backoff with jitter and stop after a small number of attempts. Session creation is limited to 600 requests per minute per key, and the generic GET ceiling is 600 per minute.

Does Didit keep the selfie and the ID document?

Didit stores verification inputs, outputs and operational metadata for the retention window you set on the application, from 1 month to 10 years. An application starts at the longest window its plan includes: 1 year on Free, 5 years on Growth, 10 years on Scale and unlimited on Enterprise. You can set a shorter window and delete a session on demand.

How do I delete a user's identity data on request?

Call DELETE on /v3/session/{session_id}/delete/ and send deletion_instruction set to privacy_erasure for an erasure request, which also purges any retained biometric template for that person. The call returns 200 with face_retention_outcome, or 404 if the session was already deleted. You remain the data controller and Didit is the processor.

Is Didit certified for security and privacy?

Didit is SOC 2 Type 2 certified, with a report covering the March 9 to July 1, 2026 observation period and issued in July 2026, and ISO/IEC 27001:2022 certified. Liveness detection is iBeta Level 1 and Level 2 certified under ISO 30107-3. Didit is GDPR compliant, acts as a data processor, and processes and stores data in the EU on AWS by default.

How much does an identity API cost?

At Didit you pay per completed check from prepaid credit. A full KYC check is $0.33 (ID document $0.15, passive liveness $0.10, face match 1:1 $0.05, device and IP analysis $0.03), AML screening is $0.20 and proof of address is $0.20. The sandbox is free on every plan, and the Free plan includes $10 of monthly credit for organizations that sign up with a work email.

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.