Skip to main content

HMAC Signature Verification: Securing Your Didit Webhooks

Verify Didit webhooks with the signing input for the header you check: X-Signature-V2 over canonical JSON, X-Signature over exact raw bytes. Check X-Timestamp within 300 seconds and compare in constant time.

HMAC Signature Verification: Securing Your Didit Webhooks

Contents

In this guide

Jump to the part you need.

This guide is for developers who receive Didit webhooks and need to verify each request before acting on it. The checks behind these events are billed per completed check. Full KYC is $0.33 per completed full KYC check at list price. The main caveat: preserve the raw request body on receipt, then use the signing input defined for the header you verify. X-Signature-V2 is recommended and signs sorted, Unicode-preserved canonical JSON. X-Signature signs the exact raw request bytes.

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

Didit webhook signature headers, from the Didit webhooks guide.
HeaderWhat it signsWhen to use it
X-Signature-V2HMAC-SHA256 over sorted, Unicode-preserved canonical JSONRecommended default
X-SignatureHMAC-SHA256 over exact raw request bytesUse when your stack passes the body through untouched
X-Signature-SimpleHMAC-SHA256 over four envelope fields: {timestamp}:{session_id}:{status}:{webhook_type}Deprecated fallback. Authenticates the envelope, not the decision body
X-TimestampUnix epoch seconds when Didit dispatched the webhookCheck in both directions. Reject missing, invalid or more than 300 seconds away
X-Signature-V2-Previous, X-Signature-Previous, X-Signature-Simple-PreviousThe same signatures made with the replaced secretSent for 24 hours after a rotation. Not sent for the legacy application webhook URL

Start free in the Didit sandbox with no sales call. For developers, connect Didit to an AI assistant through the Didit MCP server.

What HMAC verification proves

Every Didit destination has its own signing secret. We compute an HMAC-SHA256 signature over the material defined by the header and send it with the request. Each signature authenticates the material it covers using the shared secret. X-Signature-V2 authenticates sorted, Unicode-preserved canonical JSON. X-Signature authenticates the exact raw request bytes. X-Signature-Simple authenticates four envelope fields only.

A matching signature shows that the covered material was signed by a holder of the destination secret. A signature alone cannot establish that this delivery is new. It does not approve a user. For X-Signature-V2, a match does not establish byte-for-byte equality of the raw body. For Simple, decision fields in the payload are left unauthenticated, not removed.

X-Timestamp is checked for freshness, while V2 and the raw signature cover the body and Simple covers the documented four-field string, including its timestamp field. Reject a missing or invalid timestamp and any timestamp more than 300 seconds away from your clock in either direction. Freshness and idempotency are separate checks. Use the session event event_id as the dedupe key only after successful V2 or raw-body verification. The timestamp check does not deduplicate events within the window.

For session events, the envelope carries event_id, session_id, webhook_type, status, environment and, for decision statuses, a decision object. status.updated means a session or business-session status changed. Branch on the exact status before acting on a decision.

Prerequisites before you write code

  • A webhook destination with a signing secret, created in the Business Console. Each destination has its own secret, and sandbox and live are separate applications.
  • An API key for the Management API calls that read the secret and destination health.
  • A runtime with HMAC-SHA256 and a constant-time comparison.
  • An endpoint that preserves the raw request bytes and, for V2, can build canonical JSON as documented. Do not parse for event processing before verification succeeds.
  • A clock synced to a time source, because the freshness window is 300 seconds.
  • The exact event names you want. There is no wildcard.

Steps to verify a Didit webhook

  1. Create the destination and subscribe. Use exact values. For session status changes use status.updated and branch on the exact status before a decision. Use data.updated for edits and transaction.created for transaction monitoring. Multiple destinations fan out to different URLs.
  2. Read the signing secret. The list endpoint never returns it, only secret_last4. The full secret comes from the single destination GET route documented on the Get webhook destination page.
  3. Store secrets per destination. Keep each secret outside your repository. During rotation, keep the current secret and the replaced secret available for the 24-hour overlap.
  4. Preserve the raw body and choose the signing input. Lead with the recommended V2 path: compute the HMAC over sorted, Unicode-preserved canonical JSON. Beside it, for X-Signature, compute over the exact raw request bytes. For Simple, use the four envelope fields.
  5. Check freshness. Reject with 401 when X-Timestamp is missing, invalid or more than 300 seconds in either direction.
  6. Recompute and compare. For X-Signature-V2, compare the canonical JSON HMAC with X-Signature-V2. For X-Signature, compare the raw-byte HMAC with X-Signature. Do not compare a raw-body HMAC with V2. Use constant-time comparison. When a matching -Previous header is present, verify the current header with the new secret or the corresponding -Previous header with the replaced secret.
  7. Defer event processing until verification succeeds. Preserve the raw request bytes and check timestamp freshness. For V2, decode the JSON only to build the documented canonical signing input. For the raw signature, verify the exact bytes before decoding. For Simple, read only the four fields needed for verification. Defer event routing and state changes until verification succeeds. Use event_id as the dedupe key only after successful V2 or raw-body verification. If Simple is the only verified signature, use the authenticated session_id to retrieve the decision and apply the retrieved state idempotently. Do not use the webhook's unauthenticated event_id or decision.
  8. Answer 2xx quickly and make the handler idempotent.
  9. Watch destination health. health_status is failing when three or more consecutive events failed their first attempt since the destination last answered successfully. Otherwise, degraded means an attempt failed in the last 24 hours and no later attempt delivered that event. Any successful attempt clears the failing streak. The failure activity endpoint lists recorded failure alerts, not individual attempts or signature failures.

Documented destination list call

This is the documented Management API call for destination inventory and health. It never returns the signing secret. The single destination route returns the secret and a delivery summary.

curl -X GET "https://verification.didit.me/v3/webhook/destinations/" -H "x-api-key: YOUR_API_KEY"

The response is a JSON array ordered by creation time. Each item carries uuid, url, enabled, webhook_version, subscribed_events, secret_last4, 30-day delivery metrics and health_status.

Expected outcomes:

  • Valid delivery: your endpoint returns 2xx and processes the event once.
  • Signature rejection: your endpoint returns 401 and writes nothing downstream.
  • Timestamp rejection: missing, invalid or outside 300 seconds returns 401 and writes nothing downstream.
  • Repeated session event after V2 or raw-body verification: the same event_id leaves the result unchanged. If Simple is the only verified signature, the authenticated session_id drives an idempotent write of the API-fetched decision.

Inputs and outputs

Session-event inputs and outputs for a verified webhook handler.
ItemDirectionValue and source
Raw request bodyInputPreserve the exact bytes on receipt. For X-Signature, compute HMAC-SHA256 over the exact raw bytes with the destination secret. For X-Signature-V2 use the documented canonical JSON procedure.
X-TimestampInputUnix epoch seconds at dispatch. Reject missing, invalid or more than 300 seconds in either direction.
X-Signature-V2 or X-SignatureInputHMAC-SHA256 from Didit. Compare only with the matching signing input.
X-Signature-SimpleInputHMAC over four envelope fields. Deprecated. If used, re-fetch the decision before acting.
Signing secretInputPer destination, from the single destination GET route.
event_id, session_id, webhook_type, statusInputSession-event envelope fields. Use event_id for dedupe only after successful V2 or raw-body verification; with Simple, use the authenticated session_id and the API-fetched decision. For status.updated, branch on the exact status from the verified payload after V2 or raw-body verification. If Simple is the only verified signature, branch on the status returned by the decision API.
decisionInputSession-event decision object, present only for Approved, Declined, In Review and Abandoned.
2xxOutputAcknowledge quickly. Your handler.
401OutputReject on missing or invalid timestamp, or signature mismatch. Your handler.
GET /v3/session/{session_id}/decision/OutputRe-fetch after Simple verification before acting.

Failure cases and recovery

Verification failures, likely cause and fix.
SymptomLikely causeRecovery
Mismatch on every requestYour framework re-serialised the body, the secret belongs to another destination or environment, or you used the wrong signing inputFor X-Signature, compute HMAC-SHA256 over the exact raw bytes with the destination secret. For X-Signature-V2 follow the canonical JSON procedure and compare with V2. Check the destination secret.
Mismatch right after a rotationThe destination secret was replaced in the Business ConsoleVerify the current header with the new secret or the corresponding -Previous header with the replaced secret while it is available for 24 hours. Deploy the new secret, then remove the fallback.
Signature fine, timestamp missing, invalid or staleClock drift, a missing header, or a timestamp more than 300 seconds in either directionSync the server clock. Reject with 401. Handle a repeated event with event_id as a separate idempotency check after V2 or raw-body verification, or with the authenticated session_id when Simple is the only verified signature.
health_status is failingThree or more consecutive events failed their first attempt since the destination last answered successfullyRead destination metrics and failure alerts, fix the endpoint, then resend. Any successful attempt clears the failing streak.
Duplicates downstreamThe same event delivered more than onceKey the session write on event_id after V2 or raw-body verification. If Simple is the only verified signature, key it on the authenticated session_id and the API-fetched decision, and make the handler idempotent.
Decision fields unauthenticatedYou verified with X-Signature-SimpleSimple signs four envelope fields, not the decision body. Re-fetch GET /v3/session/{session_id}/decision/ before acting, even when the payload contains a decision.
Status carries no decisionThe current status is not a decision statusHandle the status without assuming the payload is incomplete. Wait for the event that carries a decision.

Sandbox rollout checklist

Use only the documented webhook route. If your team asks about ticket attachment, the supplied docs show no ticket connector. Your application's verified webhook handler receives status.updated or data.updated; the docs do not prescribe ticket actions.

  1. Create a sandbox destination, point it at your endpoint and subscribe to the exact event you need. Sandbox testing is free on every plan.
  2. Send a signed delivery. Expected: 2xx and one processed event.
  3. Test each signature path separately by configuring the handler to accept only the signature under test. For V2, change the value of event_id. For X-Signature, change one raw byte. For Simple, change a signed field such as status. Keep the original signature and expect rejection in each case. Then run a separate Simple-only test that changes just the payload's decision and confirm the handler applies the API-fetched decision.
  4. Send a missing, invalid or old timestamp. Expected: 401 and no downstream write.
  5. Repeat the same session event. Expected: after V2 or raw-body verification the same event_id leaves the result unchanged, and with Simple the authenticated session_id drives the same idempotent write.

Received HMAC, expected HMAC, and what Didit signs

When a log says the received HMAC does not match the expected HMAC, two values are compared. Record the header name, the verification outcome and the body length. Do not log signature values, secrets, raw payloads or decision data. An optional local SHA-256 digest is only a fingerprint for a later byte comparison.

The usual causes are a body that was re-encoded before hashing, a secret from another destination or environment, or a proxy that altered a header. HMAC is a keyed hash, not encryption, so there is nothing to decrypt: recompute and compare. A manual copy of JSON can be re-serialised by a viewer or chat window, so use the local digest fingerprint if you need to compare later.

Didit documents a JSON POST body and HMAC signature headers for webhook verification. Use the signing input specified for the header you verify.

The checks that produce events are billed per completed check from prepaid credit:

  • Full KYC check $0.33, which is ID document verification $0.15 plus passive liveness $0.10 plus face match 1:1 $0.05 plus device and IP analysis $0.03.
  • AML screening $0.20 per check, ongoing AML monitoring $0.07 per person a year.
  • Business verification from $2.00 per company, plus $0.20 company AML, plus $0.20 person AML for owners and officers, plus $0.33 for each linked KYC.
  • Wallet screening $0.15 per screening. Transaction monitoring $0.001 per transaction beyond the plan allowance.

The destination list call is documented as pay-per-call. Our public price feed does not list a webhook delivery fee. We bill completed verification checks separately. For the checks in our full KYC example, see Didit User Verification. Use Didit pricing and the machine-readable price feed for current numbers.

A session overview with its warnings in the Didit Business Console
The session a status.updated webhook points to, with the warnings that drove the decision.

A valid signature authenticates the covered material with the shared secret. It does not approve anything. In Review means automated checks raised warnings and a person decides: approve, decline or request a resubmission. Approved and Declined arrive with the decision object for session events, and Kyc Expired uses a single capital K. Status strings are exact and case sensitive, as the verification statuses page lists them.

The details of an AML hit in the Didit Business Console
An AML hit in the Didit Business Console. For an authenticated session event with the status In Review, a reviewer must make the final decision.

Worked cost example

These are verification-check usage figures. Suppose a month brings 10,000 sessions: 8,000 full KYC checks and 2,000 that also need AML screening.

  • 8,000 full KYC checks at $0.33 = $2,640.00
  • 2,000 compliance bundles at $0.33 + $0.20 = $0.53 each = 2,000 x $0.53 = $1,060.00
  • List verification-check total = $2,640.00 + $1,060.00 = $3,700.00

On Growth the discount is 4% before plan fees and credits. $0.33 x 0.96 = $0.3168, so 8,000 x $0.3168 = $2,534.40. $0.53 x 0.96 = $0.5088, so 2,000 x $0.5088 = $1,017.60. Discounted usage total = $3,552.00 before the $99 monthly plan fee and the $115 monthly credit.

On Scale the discount is 10% before plan fees and credits. $0.33 x 0.90 = $0.297, so 8,000 x $0.297 = $2,376.00. $0.53 x 0.90 = $0.477, so 2,000 x $0.477 = $954.00. Discounted usage total = $3,330.00 before the $299 monthly plan fee and the $350 monthly credit.

How Didit billing works, with credits, auto-recharge and volume discounts
Credits, auto-recharge and plan discounts set what the checks cost. The worked total covers verification checks only.

Sources

The next step is a sandbox test: create a destination, send a signed delivery, confirm your handler returns 2xx, and repeat the same session event to confirm the result is unchanged. Start free at business.didit.me, no sales call needed.

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 signature header does Didit send with a webhook?

Didit sends X-Signature-V2, an HMAC-SHA256 over the sorted, Unicode-preserved canonical JSON body, and recommends it. It also sends X-Signature, an HMAC-SHA256 over the exact raw request bytes, and X-Timestamp in Unix epoch seconds. X-Signature-Simple exists as a deprecated fallback that signs four envelope fields: timestamp, session ID, status and webhook type.

Why does my received HMAC not match my expected HMAC?

The values differ when the bytes or canonical form you hashed are not the material Didit signed, or when the secret is from another destination or environment. For X-Signature, recompute over the exact raw body. For X-Signature-V2, follow the documented canonical JSON procedure and compare to X-Signature-V2. HMAC is a keyed hash, not encryption, so there is nothing to decrypt.

How do I verify a Didit webhook signature in Node.js?

In Node.js, preserve the raw request body and validate X-Timestamp. Compute HMAC-SHA256 over the documented V2 canonical JSON, or over the exact raw bytes for X-Signature. Compare with the corresponding header in constant time and reject missing or malformed signatures before processing the event.

How fresh must a webhook be before I reject it?

Reject a missing or invalid X-Timestamp, and reject any timestamp more than 300 seconds away from your clock in either direction. Freshness and idempotency are separate checks. Use the session event event_id for dedupe only after successful V2 or raw-body verification; with Simple, use the authenticated session_id and the API-fetched decision. Keep the server clock synced.

What happens when my endpoint returns an error?

Didit retries failed deliveries a bounded number of times. A failed attempt is one your endpoint answered at HTTP 400 or above, or did not answer at all. Failed first attempts affect destination health: health_status is failing when three or more consecutive events failed their first attempt since the destination last answered successfully. Otherwise, degraded means an attempt failed in the last 24 hours and no later attempt delivered that event. Any successful attempt clears the failing streak.

How do I rotate a webhook signing secret without losing events?

Configure secrets per destination. During rotation, verify the current header with the new secret or the corresponding -Previous header with the replaced secret while it is available for 24 hours. The previous headers are not sent for the legacy application webhook URL.

Is X-Signature-Simple safe to use?

Use X-Signature-Simple only as a last resort. It signs four envelope fields, so the decision fields in the payload are left unauthenticated, not removed. If you verify with it, re-fetch GET /v3/session/{session_id}/decision/ before acting, even when the payload contains a decision.

Do webhook deliveries cost anything?

Our public price feed does not list a webhook delivery fee. Completed verification checks are billed separately, for example $0.33 per completed full KYC check at list price or $0.20 for AML screening. The destination list call is documented as pay-per-call; keep that separate from any delivery fee.

Does Didit send a verification.json file or a bundle SHA-256?

For webhook verification, we document a JSON POST body and HMAC headers rather than a verification.json file or a bundle checksum. Use the signing input specified for the header you verify. For your own records, a local SHA-256 digest over the bytes you received is only a fingerprint for a later byte comparison.

How do I test webhook verification in the sandbox?

Create a sandbox destination, point it at your endpoint and drive a session. Sandbox testing is free on every plan, environment is sandbox, and armed sandbox sessions carry a sandbox_scenario such as decline_aml_hit so you can reproduce a decision on demand. The sandbox guide lists the scenarios and magic values.

How do I see all my destinations and their health?

Call GET https://verification.didit.me/v3/webhook/destinations/ with the x-api-key header. It returns every destination with webhook_version, subscribed_events, secret_last4, 30-day delivery metrics and health_status. The secret itself is only returned by the single destination endpoint.

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.