API Security for Webhooks: HMAC and Key Rotation (2026)
Verify every delivery with HMAC-SHA256 on the raw body or X-Signature-V2 canonical JSON, reject timestamps older than 300 seconds, and rotate a Business Console destination secret while -Previous headers are still sent for 24.

Contents
In this guide
Jump to the part you need.
Secure webhooks come down to two habits: verify the HMAC-SHA256 signature on every delivery, and rotate the signing secret without breaking what is already deployed. This guide is for developers who receive Didit session, business and transaction events. Webhook delivery has no line in the public price book; you pay per completed check, for example $0.33 for a full KYC. The main caveat: the deprecated X-Signature-Simple header authenticates the envelope, not the decision body.
Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.
| Item | Answer |
|---|---|
| Signature scheme | HMAC-SHA256 |
| Recommended header | X-Signature-V2 over sorted canonical JSON |
| Raw byte header | X-Signature over the exact request body |
| Freshness window | 300 seconds from X-Timestamp |
| Rotation overlap | -Previous headers for 24 hours after a destination secret is rotated |
| Where the secret lives | Per destination; the list call returns only secret_last4 |
| Delivery health | health_status: healthy, degraded, failing |
| Price of webhooks | No published webhook-specific price line; billing is per completed check |
Start free in the sandbox at https://business.didit.me/, with no sales call to get going. If you build with a coding agent, connect Didit to an AI assistant through the Didit MCP server.
The outcome and the recommended method
The outcome is a webhook endpoint that accepts only fresh, correctly signed deliveries, stays verified while a destination secret is rotated, and fails visibly when it stops answering. The recommended method is X-Signature-V2 over the documented canonical JSON, the 300 second timestamp window, constant-time comparison against the current and -Previous signatures, then an idempotent state change keyed on event_id.
What you need before you start
- A Didit organization and an application. Every application comes as a Live and a Sandbox environment, and a key belongs to one environment, so a sandbox key never creates a billed verification.
- An API key from Developers then API keys in the Business Console, sent as the
x-api-keyheader. New keys start withsk_live_orsk_test_, and older keys without a prefix keep working. - An endpoint URL that can answer 2xx.
- Access to the raw request body before JSON parsing. Signature verification fails when a framework re-serializes the body first.
- A runtime with HMAC-SHA256 support, or a language library for it. The header names and the 300 second window are the same in every language.
- The webhooks guide open beside the console while you wire the first destination.
Steps to secure a Didit webhook endpoint
- Create the destination and subscribe to exact events. Destinations belong to one application, and
subscribed_eventstakes exact event names with no wildcard. List every family you want, for examplestatus.updated,transaction.created,travel_rule.status.updatedorinvestigator.report.ready. When two systems need the same events, create two destinations and fan out rather than sharing one secret across teams. - Read the signing secret once and keep it server side. The list call returns
secret_last4, never the secret itself, which is how you tell secrets apart during an audit. Read the full secret from the documented get-destination call and store it as an environment variable on your server.
Treat it the way Didit treats API keys: server side only, never in frontend code, public repositories or client bundles.curl -X GET "https://verification.didit.me/v3/webhook/destinations/" \ -H "x-api-key: YOUR_API_KEY" - Reject stale deliveries before you hash anything. Read
X-Timestamp, the Unix epoch seconds when Didit dispatched the delivery, and reject the request whenabs(now - X-Timestamp)is greater than 300 seconds. This is the control HMAC cannot give you on its own: an intercepted payload replayed an hour later is still correctly signed. - Recompute the signature over the bytes Didit signed.
X-Signature-V2is HMAC-SHA256 over the sorted, Unicode-preserved canonical JSON and is the recommended header; it requires that you reconstruct Didit's documented canonical JSON before hashing.X-Signatureis HMAC-SHA256 over the exact raw bytes and works only if your stack does not re-encode the body.X-Signature-Simpleis a deprecated fallback over{timestamp}:{session_id}:{status}:{webhook_type}, so it authenticates the envelope and not the decision body. - Compare in constant time and accept the previous key. Compare with a timing-safe function against the header and, when present, its
-Previousheader, and accept a match on either.X-Signature-V2-Previous,X-Signature-PreviousandX-Signature-Simple-Previousare sent for 24 hours after a destination signing secret is rotated in the Business Console, and that overlap is what lets you deploy a new secret without dropping deliveries. It is not sent for the legacy applicationwebhook_url. - Answer 2xx fast and process idempotently. Parse the JSON after verification, branch on
webhook_type, and key your state change onevent_id, so a retry or a resend does not apply the same decision twice. The envelope also carriesenvironmentand, on an armed sandbox session,sandbox_scenario. - Rotate on a schedule and keep the overlap short. Replace the destination signing secret in the Business Console, keep both keys accepted in code, confirm that deliveries verify, then drop the old key when the 24 hour window closes. Reverse that order and every delivery inside the window fails verification.
A documented verification sequence
The documented sequence is language neutral. It uses the raw body, X-Timestamp, X-Signature-V2 (or X-Signature), and the parsed event_id and webhook_type fields. For X-Signature-V2, follow Didit's canonicalization rule exactly: HMAC-SHA256 over the sorted, Unicode-preserved canonical JSON. Do not invent your own serialization.
1. Read the raw request body before any JSON parser runs.
2. Read X-Timestamp. Reject when abs(now - X-Timestamp) is greater than 300 seconds.
3. Recompute X-Signature-V2: HMAC-SHA256 over the sorted, Unicode-preserved canonical JSON, using the destination signing secret.
4. Compare in constant time with X-Signature-V2 and, when present, X-Signature-V2-Previous. Accept a match on either.
5. Only after verification, parse the JSON body.
6. Branch on webhook_type and record event_id before you change state.
7. Return 2xx quickly.
If your stack cannot reconstruct the canonical JSON, use X-Signature over the exact raw bytes instead, with the same timestamp check and the same -Previous comparison. Didit's integration prompt for coding agents documents the same order: raw body first, then the timestamp and signature checks, then JSON, then an idempotent state change.
What a signed delivery and a destinations list look like
{
"event_id": "uuid",
"session_id": "uuid",
"status": "Approved",
"webhook_type": "status.updated",
"created_at": 1627680000,
"timestamp": 1627680000,
"application_id": "uuid",
"environment": "live",
"sandbox_scenario": null,
"workflow_id": "uuid",
"workflow_version": 1,
"vendor_data": "your-internal-user-id",
"metadata": { "user_type": "premium" },
"decision": { }
}
Status values are exact, case-sensitive strings, and Kyc Expired uses a single capital K. The decision object appears only on Approved, Declined, In Review and Abandoned. KYB payloads add business_session_id and session_kind.

status.updated delivery reports, as it appears in the Business Console.The list response carries one object per destination. Values below are illustrative; the field set is what the response returns, ordered by creation time and never paginated.
[
{
"uuid": "uuid",
"url": "https://myapp.com/api/webhooks/didit",
"label": "billing-events",
"enabled": true,
"webhook_version": "v3",
"subscribed_events": ["status.updated", "transaction.created"],
"secret_last4": "9f2c",
"health_status": "healthy",
"failing_streak": 0,
"deliveries_count": 1284,
"failed_deliveries_count": 3,
"error_rate_percentage": 0.23,
"average_response_time_ms": 84,
"environment": "live"
}
]

transaction.created and transaction.status.updated deliveries point at records like this one.Those transaction events come from the Transaction Monitoring product; session and business events come from verification workflows.
Failure cases and recovery
| Symptom | Cause | Recovery |
|---|---|---|
401 on the management API | The x-api-key value is wrong, malformed, revoked or expired | Read the key again under Developers then API keys, or create a new one |
403 on the management API | No x-api-key header, or a scoped key without access to this endpoint | Send a key with the access the call needs |
Every delivery rejected with 400 by your own handler | Server clock drift makes X-Timestamp look older than 300 seconds | Put hosts on a time source, then re-check the window |
Your handler answers 401 on real deliveries | The body was parsed and re-encoded before hashing | Hash the raw bytes for X-Signature, or verify X-Signature-V2 canonical JSON |
| Signature passes but the decision is not trustworthy | You verified X-Signature-Simple, which covers only the envelope | Re-fetch GET /v3/session/{session_id}/decision/ instead of trusting the body |
health_status is failing | Three or more consecutive events failed their first attempt since the destination last answered successfully | Read failing_streak, failing_since and error_rate_percentage, fix the endpoint, then let a retry or a resend close the streak |
404 on destination activity | The destination id does not exist for that application | Re-read the destination list and use its uuid |
429 | Rate limit on the management API | Wait for the retry period and back off |
Inputs and outputs
| Input | Where it comes from | Output |
|---|---|---|
Destination URL, label, subscribed_events, webhook_version | Business Console, per application | A destination uuid that receives only the listed events |
| Full signing secret | Get-destination call | A server-side secret, plus secret_last4 for audits |
X-Timestamp, signature header, raw body | Each delivery | Accept or reject, before any JSON is parsed |
event_id, webhook_type, status, decision | Verified envelope | One idempotent state change, answered with 2xx |
health_status, failing_streak, daily_points | List-destinations metrics, last 30 days | The alert that fires when an endpoint stops answering |
Signing key rotation guidance for webhooks and billing
Rotate two different things on two different clocks. The destination signing secret protects webhook payloads. The application API key protects your calls into the Didit API. Neither rotation changes your invoice, because billing is per completed check from prepaid credit.
The signing secret rotation sequence that does not drop deliveries:
- Rotate the destination signing secret in the Business Console.
- Deploy code that verifies with the new secret and still accepts the
-Previousheaders, which Didit sends for the next 24 hours. - Watch
health_statusandfailed_deliveries_countuntil the window closes and every attempt verifies with the new secret alone. - Remove the old secret from your configuration and from your secret manager.
The 24 hour overlap applies to a destination signing secret rotated in the Business Console. The -Previous headers are never sent for the legacy application webhook_url, so a rotation there has no overlap and needs a deliberate cutover. And a rotation triggered by suspicion is not a maintenance task: rotate first, then audit which deliveries verified against the old secret.
For API keys, create a new key under Developers then API keys, ship it to the service, confirm traffic, then retire the old key. When your organization requires two-factor, Confirm sensitive actions asks for it again on billing changes, API key rotation and role edits. Keep rotation on a calendar rather than on memory, and give every service or partner its own key so one compromise does not force a company-wide swap.
On the billing side, rotation has no published webhook-specific price line, and webhooks are not a priced line in the public price book. What you pay for is completed checks: didit.me/pricing lists every module price, and pricing in the docs lists the billing rules, including which retries and no-match database lookups are billable.

Worked cost example
On the webhook side, the public price book has no webhook-specific line for delivery or signing secret rotation. The list-destinations management call is marked pay-per-call in its documentation, and no webhook-specific price is published, so check that call against your billing view rather than assuming it is free. For the checks themselves, here is the published arithmetic for a team that runs 2,000 complete KYC checks a month and consumes status.updated and transaction.created webhooks:
- Full KYC: 2,000 x $0.33 = $660.00. The $0.33 is ID verification $0.15 + passive liveness $0.10 + face match 1:1 $0.05 + device and IP analysis $0.03 = $0.33.
- AML screening on the same 2,000 people: 2,000 x $0.20 = $400.00.
- List total: $660.00 + $400.00 = $1,060.00.
- On Scale, 10% off every Didit price: $660.00 x 0.10 = $66.00, so $594.00; $400.00 x 0.10 = $40.00, so $360.00; total $954.00.
- Scale includes $350.00 of monthly credit: $954.00 - $350.00 = $604.00 paid from top-ups or extra credit, on top of the $299.00 monthly fee.
Rotating the signing secret twice a year adds no published webhook price line. Adding a second destination to fan events out to a warehouse changes none of the check costs.
Paid steps and review boundaries
- Free: The sandbox is free and unlimited on every plan. Nothing in sandbox is billed.
- Paid: each completed check at list price, drawn from prepaid credit. Plan credit resets monthly and does not roll over; top-ups last 12 months.
- Not in the public price book: creating a destination, rotating a signing secret, rotating an API key, and receiving deliveries. The list-destinations management call is marked pay-per-call in the docs, so treat management API reads as a separate item to confirm.
- Your side of the line: raw-body capture, constant-time comparison, the 300 second window, idempotent state changes on
event_id, secret storage, the rotation calendar and alerting onfailing. - Our side of the line: signing each delivery, sending the
-Previousheaders for 24 hours after a rotation, bounded retries, and the health status and 30 day metrics you read back. - The review boundary: a passing signature proves the payload came from a holder of the secret and was not altered. It does not prove the decision is correct. Read the decision object for that, and if you still verify with
X-Signature-Simple, re-fetch the decision rather than trusting the body.
Sources
- Didit docs: Webhooks, real-time KYC and KYB events, HMAC signing
- Didit docs: List webhook destinations API
- Didit docs: Get webhook destination API
- Didit docs: Webhook destination failure activity API
- Didit docs: API authentication
- Didit docs: API errors, status codes and fixes
- Didit docs: Applications in the Didit Console, live and sandbox
- Didit docs: Security and sign-in settings
- Didit pricing page and pricing as JSON, read November 26, 2026
- Didit docs: pricing and billing rules
- Didit MCP server and integration prompt
- No competitor pages were used for this guide.
Next step: create a sandbox application at https://business.didit.me/, add a destination, and run the verification sequence against a test delivery. No sales call, and nothing is billed in sandbox.
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
How do I verify that a webhook really came from Didit?
Recompute HMAC-SHA256 with the destination signing secret and compare it in constant time with X-Signature-V2, or with X-Signature over the exact raw body, then reject the request when X-Timestamp is more than 300 seconds from your clock. A match proves the payload came from a holder of the secret and was not changed in transit.
Which header should I use, X-Signature or X-Signature-V2?
X-Signature-V2 is the recommended header: HMAC-SHA256 over the sorted, Unicode-preserved canonical JSON, which you reconstruct from the documented canonicalization rule before hashing. X-Signature covers the exact raw bytes and only works if nothing re-serializes the body before you hash it. X-Signature-Simple is deprecated and authenticates the envelope only.
How long is a Didit webhook timestamp valid?
300 seconds. The first verification step is abs(now - X-Timestamp) <= 300. Keep your hosts on a time source, because a drifting clock turns valid deliveries into rejected ones that look like an attack.
What happens to signatures when I rotate the webhook signing secret?
For 24 hours after a destination signing secret is rotated in the Business Console, Didit also sends X-Signature-V2-Previous, X-Signature-Previous and X-Signature-Simple-Previous: the same signatures made with the replaced secret. Accept a match on either header, deploy the new secret, then retire the old one when the window closes. Those -Previous headers are never sent for the legacy application webhook_url.
Where do I find the webhook signing secret in Didit?
The list call returns only secret_last4, so read the full secret from the get-destination call and store it server side. Destinations and their secrets are configured per application, which means a secret from one application never verifies deliveries sent to another.
How do I rotate a Didit API key, and does it need two-factor?
Create a new key under Developers then API keys in the Business Console, ship it to your service, confirm traffic, then retire the old one. When your organization requires two-factor, the Confirm sensitive actions setting asks for it again on API key rotation, billing changes and role edits. New keys start with sk_live_ or sk_test_, and keys created before that format keep working.
Does rotating a key or receiving webhooks change what I pay?
No. Billing is per completed check from prepaid credit, for example $0.33 for a full KYC, and no price-book line covers webhook delivery or secret rotation. Rotating an API key does not reset plan credit or move you to another plan.
What does health_status failing mean for a destination?
failing means three or more consecutive events failed their first delivery attempt since the destination last answered successfully, with failing_streak counting them and failing_since dating the first. degraded means an attempt failed in the last 24 hours and no later attempt has delivered that event. Any successful attempt, including a retry or a resend, ends the streak, and health status is independent of enabled.
Can one destination receive several event types?
Yes. subscribed_events is a list of exact event names and there is no wildcard, so include every family you want, such as status.updated, transaction.created or travel_rule.status.updated. Create an additional destination when a different URL needs a different set.
Does the console IP allowlist affect webhook delivery?
No. The IP allowlist in Security and sign-in restricts console sign-in only, and the API is not affected by it. Webhook authenticity comes from the signature and the timestamp window, not from the source address.
Do these steps cover all webhook scenarios?
They cover signature verification, replay protection, rotation and failure handling for every event family that destinations carry, from status.updated through the investigator events. Authentication activity and bank events are documented on their own pages, so read those before registering their event types.
Is X-Signature-Simple still usable?
It is a deprecated last-resort fallback. It hashes {timestamp}:{session_id}:{status}:{webhook_type}, so it authenticates the envelope and not the decision body. If you verify with it, re-fetch GET /v3/session/{session_id}/decision/ instead of trusting the payload.
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


