Build a Go Webhook Handler for Identity Verification Events (2026)
Build one Go HTTPS endpoint that verifies Didit's HMAC-SHA256 signature, checks the timestamp, branches on the exact webhook_type and status strings, and returns 200 fast. Webhooks carry no price; the checks behind them do.

Contents
In this guide
Jump to the part you need.
This guide is for Go developers who need to act on a Didit verification result the moment it changes: approve a user or open a review. You will build one HTTPS endpoint that verifies the HMAC signature, reads the event, and answers 200. Webhook delivery has no line in our price book, so the cost is the checks behind it, from $0.33 for a full ID check. The caveat: verify before you trust, and make the state change idempotent.
Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.
| Item | What you get |
|---|---|
| Endpoint you build | POST /api/webhooks/didit served over HTTPS |
| Signature headers | X-Signature-V2 (recommended, canonical JSON) or X-Signature (exact raw bytes) |
| Timestamp header | X-Timestamp, Unix epoch seconds, reject when the skew is over 300 seconds |
| Rotation headers | X-Signature-V2-Previous and X-Signature-Previous, sent for 24 hours after a secret rotation |
| Core event to handle first | status.updated, with the full decision object on Approved, Declined, In Review and Abandoned |
| Go runtime and SDK | Go 1.22 or newer, github.com/didit-protocol/sdk-go |
| What a webhook costs | No webhook line in the published price book. You pay for completed checks: full ID check $0.33, AML screening $0.20 |
| Sandbox | Free and unlimited, nothing is charged in sandbox |
Start in the sandbox at business.didit.me, no sales call, and read our published prices before you size the bill. If you want an AI assistant to read the same documentation while you build, connect the Didit MCP server.
What Didit sends to your endpoint
A webhook destination is a URL plus a list of event names. There is no wildcard, so you list every event family you want. You can create several destinations to fan out to different URLs, for example one endpoint for session outcomes and another for transaction verdicts.
| Event value | When it fires | What your handler does |
|---|---|---|
status.updated | A session or business session status changed | Your main branch. Read status and the decision object |
data.updated | Verification data on a session was edited | Re-read the decision, do not trust cached per-feature results |
user.status.updated | A User entity became ACTIVE, FLAGGED or BLOCKED | Update your own user risk state |
user.data.updated | User profile or aggregate data changed | Refresh the profile you mirror |
business.status.updated | A Business entity status changed | Hold or release a merchant account |
business.data.updated | Business profile or aggregate data changed | Refresh the KYB record |
transaction.created | A transaction was created and its initial verdict is ready | Pause or release the transaction |
transaction.status.updated | A transaction status changed | Update the ledger entry |
travel_rule.status.updated | A Travel Rule exchange changed status | Update the transfer record |
workflow.compliance_changed | A published workflow's compliance status changed after re-evaluation | Re-scan the affected population |
investigator.decision.overridden | A person took a different action than the Investigator, or overrode it | Alert your operations team |
investigator.rfi.overdue | An information request passed its deadline | Escalate or close the case |

The envelope is flat and small, so you can parse it into a struct without a schema generator. Session events look like this:
{
"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": { }
}
KYB and business session payloads additionally carry business_session_id and session_kind set to business. The decision object appears only on Approved, Declined, In Review and Abandoned, and it mirrors GET /v3/session/{sessionId}/decision/. Per-feature results sit in plural arrays, so a workflow with two document steps returns two entries in id_verifications[]. Every feature object carries a node_id that pins it to the workflow node that produced it.
Prerequisites
- Go 1.22 or newer, because that is the minimum for the official Go SDK.
- A Didit API key from the Business Console, and at least one published workflow to verify against.
- A public HTTPS URL for your handler.
- A webhook destination with a signing secret, and the exact event names you want.
- An HTTP stack that hands you the raw request body. If a middleware decodes and re-encodes JSON, byte-level signatures stop matching.
Build the handler in six steps
Step 1: Create the destination and copy the signing secret
In the Business Console, add a webhook destination with your URL, a label, and the events you want. Save the signing secret once, in an environment variable or a secret manager, never in the repository. The list endpoint shows only secret_last4, the last four characters, so you can tell two secrets apart; the full secret comes from the single-destination read.
Step 2: Subscribe to exact event names
Check the boxes for status.updated and data.updated at minimum, plus transaction.status.updated if you screen transactions. There is no wildcard and no default set: an event family you do not list never reaches your endpoint.
Step 3: Write the handler
The order matters. Read the raw body first, check the timestamp, verify the signature with a constant-time comparison, and only then decode JSON. Scope: this is a raw-byte fallback tutorial, not the production handler we recommend. The sample below implements X-Signature, HMAC-SHA256 over the exact raw bytes, which works only when your stack hands you the payload unchanged. It does not implement X-Signature-V2 canonicalization, and V2 is the header we recommend for production. If you need V2, implement it from the webhooks page before you ship.
package main
import (
"crypto/hmac"
"crypto/sha256"
"crypto/subtle"
"encoding/hex"
"encoding/json"
"io"
"log"
"net/http"
"os"
"strconv"
"time"
)
type Envelope struct {
EventID string `json:"event_id"`
SessionID string `json:"session_id"`
Status string `json:"status"`
WebhookType string `json:"webhook_type"`
CreatedAt int64 `json:"created_at"`
Environment string `json:"environment"`
WorkflowID string `json:"workflow_id"`
VendorData string `json:"vendor_data"`
Metadata json.RawMessage `json:"metadata"`
Decision json.RawMessage `json:"decision"`
}
func hmacHex(body []byte, secret string) string {
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(body)
return hex.EncodeToString(mac.Sum(nil))
}
func equal(a, b string) bool {
return subtle.ConstantTimeCompare([]byte(a), []byte(b)) == 1
}
func webhook(secret string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}
body, err := io.ReadAll(r.Body) // raw bytes, no JSON parsing yet
if err != nil {
http.Error(w, "cannot read body", http.StatusBadRequest)
return
}
ts, err := strconv.ParseInt(r.Header.Get("X-Timestamp"), 10, 64)
if err != nil {
http.Error(w, "missing timestamp", http.StatusUnauthorized)
return
}
skew := time.Since(time.Unix(ts, 0))
if skew > 5*time.Minute || skew < -5*time.Minute {
http.Error(w, "stale timestamp", http.StatusUnauthorized)
return
}
// X-Signature only: this sample does not implement X-Signature-V2 canonical JSON.
if !equal(r.Header.Get("X-Signature"), hmacHex(body, secret)) {
prevSecret := os.Getenv("DIDIT_WEBHOOK_SECRET_PREVIOUS")
prevOK := prevSecret != "" && equal(r.Header.Get("X-Signature-Previous"), hmacHex(body, prevSecret))
if !prevOK {
http.Error(w, "invalid signature", http.StatusUnauthorized)
return
}
}
var env Envelope
if err := json.Unmarshal(body, &env); err != nil {
http.Error(w, "invalid json", http.StatusBadRequest)
return
}
switch env.WebhookType {
case "status.updated":
switch env.Status {
case "Approved":
log.Printf("grant access vendor_data=%s session=%s", env.VendorData, env.SessionID)
case "Declined":
log.Printf("deny access vendor_data=%s session=%s", env.VendorData, env.SessionID)
case "In Review":
log.Printf("hand to a human reviewer session=%s", env.SessionID)
case "Kyc Expired":
log.Printf("ask vendor_data=%s to re-verify", env.VendorData)
}
case "data.updated":
log.Printf("data changed, re-read the decision session=%s", env.SessionID)
}
log.Printf("event_id=%s type=%s session=%s status=%s environment=%s",
env.EventID, env.WebhookType, env.SessionID, env.Status, env.Environment)
w.WriteHeader(http.StatusOK)
}
}
func main() {
secret := os.Getenv("DIDIT_WEBHOOK_SECRET")
if secret == "" {
log.Fatal("DIDIT_WEBHOOK_SECRET is not set")
}
http.HandleFunc("/api/webhooks/didit", webhook(secret))
log.Println("webhook listener on :8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}
Step 4: Branch on the exact status strings
Statuses are exact, case-sensitive strings with spaces inside them. Kyc Expired uses a single capital K, not KYC. Compare against the literal strings, never against a lowercased copy.
| Status string | Handler action |
|---|---|
Approved | Grant access and store the decision. The payload includes the full decision object |
Declined | Deny access, notify the user. A reviewer can still move it to Resubmitted |
In Review | Do not decide automatically. A person resolves it in the Console, which sends another event |
Kyc Expired | The verified document passed its expiry date. Trigger re-verification |
Resubmitted | The user was asked to redo specific steps. Expect another status.updated |
Expired | The user never opened the link before the TTL ran out. Wait for the user or send a reminder |
Abandoned | The user started and did not finish in time |
Awaiting User | KYB only: the parent waits on key people. No action on the parent |
Not Started, In Progress | Informational. Log them if you track funnel conversion |
Step 5: Answer fast and update state idempotently
Return 2xx as soon as the signature and timestamp pass and the event is recorded. Store event_id, skip an id you have already seen, and make the state write idempotent, so a repeated delivery cannot grant access twice.
Step 6: Test, then watch delivery health
Deploy the handler behind a public HTTPS URL, then use Try Webhook in the Console, which delivers an activity.created event to that destination. In sandbox you can arm a scenario so a session ends in a decline path; an armed session shows the scenario slug in sandbox_scenario, and the field is null on live sessions. Once you are live, read the destination list with the documented call:
curl -X GET "https://verification.didit.me/v3/webhook/destinations/" \
-H "x-api-key: YOUR_API_KEY"
Each destination returns webhook_version, subscribed_events, health_status, failing_streak, failing_since, and 30 days of delivery counts, failed counts and average response time. Per-destination failure alerts come from the destination activity endpoint, paginated with limit and offset.
Expected output
Start the server, send a signed event, then send the same body with one byte changed. The first call is acknowledged, the second is refused.
$ export DIDIT_WEBHOOK_SECRET=your_destination_secret
$ go run .
2026/11/26 10:14:02 webhook listener on :8080
2026/11/26 10:14:09 grant access vendor_data=user_8821 session=8f14e45f
2026/11/26 10:14:09 event_id=2b9d1c0a type=status.updated session=8f14e45f status=Approved environment=sandbox
$ curl -i -X POST localhost:8080/api/webhooks/didit \
-H "X-Timestamp: 1795000449" -H "X-Signature: 6a1c..." -d @event.json
HTTP/1.1 200 OK
$ curl -i -X POST localhost:8080/api/webhooks/didit \
-H "X-Timestamp: 1795000449" -H "X-Signature: 6a1c..." -d @tampered.json
HTTP/1.1 401 Unauthorized
invalid signature
Failure cases and recovery
- 401 invalid signature. Either the secret is wrong or a middleware re-encoded the body. Verify against the raw bytes, and check the destination secret, not your API key.
- 401 stale timestamp. Your clock drifted or you replay an old capture. Reject anything with a skew over 300 seconds.
- Rotation window. For 24 hours after you rotate a destination signing secret, Didit also sends the signatures made with the replaced secret:
X-Signature-PreviousalongsideX-Signature, andX-Signature-V2-PreviousalongsideX-Signature-V2. Accept a match on the current or the previous header so a deploy cannot break delivery. The Go sample checksX-SignatureandX-Signature-Previousonly, because it implements the raw-byte header. - Duplicate delivery. Retries and manual resends can deliver the same event twice. Deduplicate on
event_idand keep the state write idempotent. - Slow or failing endpoint. A response of 400 or above, a timeout, or a refused connection counts as a failed attempt. Three or more consecutive first-attempt failures since the last success set
health_statusto failing, withfailing_sincemarking when it started; a single failure in the last 24 hours with no later success sets it to degraded. - Weak signatures.
X-Signature-Simpleis deprecated and authenticates only the envelope. If you verify with it, do not trust the payload: re-fetch the decision fromGET /v3/session/{sessionId}/decision/. - Management API refusals. A missing or malformed
x-api-keyanswers 401, a key without access answers 403 with adetailmessage, and 429 means you are rate limited and should back off.
Inputs and outputs
| Side | Name | Notes |
|---|---|---|
| Input | Raw request body | The JSON envelope as sent. Hash these exact bytes |
| Input | X-Timestamp | Unix epoch seconds when Didit dispatched the event |
| Input | X-Signature | HMAC-SHA256 over the raw bytes |
| Input | X-Signature-V2 | HMAC-SHA256 over sorted, Unicode-preserved canonical JSON. Recommended |
| Input | X-Signature-Previous | Same signature made with the replaced secret, for 24 hours after a rotation |
| Input | X-Signature-V2-Previous | V2 signature made with the replaced secret, for 24 hours after a rotation |
| Input | Destination signing secret | Read from the Console or the single-destination endpoint |
| Output | HTTP status | 2xx means delivered. 400 or above, a timeout, or a refused connection is a failed attempt |
| Output | State change | Grant, deny, or route to a reviewer, keyed on status |
| Output | Signal to the Management API | Your answers become health_status, delivery counts and error rate |
Paid steps and review boundaries
The endpoint itself is free to run, and Didit does not price webhook deliveries. What bills is each completed check behind the event: ID document verification $0.15, passive liveness $0.10, face match 1:1 $0.05, device and IP analysis $0.03, so the full ID check is $0.33. AML screening is $0.20 per check and ongoing AML monitoring is $0.07 per person a year. Business verification starts at $2.00 per company, with person AML at $0.20 per owner and a linked full ID check at $0.33 per person. Phone codes cost the carrier price plus our $0.02 fee, and transaction monitoring is $0.001 per transaction beyond your plan allowance. Sandbox testing is free and unlimited: nothing is charged there, whatever your handlers log. Our published price list carries every line, including the plans and the monthly credit.
Two boundaries belong in code, not in a runbook. First, In Review means a person must decide in the Business Console: your handler should open a task and stop, never approve. Second, Kyc Expired is a compliance signal, not a bounce; start a new verification session rather than reinstating access.

Worked cost example
Take a marketplace that verifies 20,000 new sellers a month and screens 3,000 of them against AML lists. On list prices:
- 20,000 full ID checks x $0.33 = $6,600.00
- 3,000 AML screenings x $0.20 = $600.00
- Total at list price = $7,200.00 for the month
On the Scale plan the same volume takes the 10% discount: 20,000 x $0.297 = $5,940.00, and 3,000 x $0.18 = $540.00, for $6,480.00 of usage. The $299.00 monthly fee brings $350.00 of credit, which pays the first $350.00 of that usage, leaving $6,130.00 from top-ups. Cash for the month is $6,130.00 + $299.00 = $6,429.00, which is $771.00 less than the list-price total. Webhooks add nothing to either figure.

Sources
- Didit docs: Webhooks, real-time KYC and KYB events, HMAC signing
- Didit docs: Verification statuses and session lifecycle
- Didit docs: Data models for every report object
- Didit docs: Server SDKs overview
- Didit docs: Go SDK
- Didit docs: Retrieve session decision
- Didit docs: List webhook destinations
- Didit docs: Webhook destination failure activity
- Didit Go SDK source on GitHub
- Didit pricing page and cost estimator
- Didit MCP server setup
Next step: open business.didit.me, create a sandbox application, add a webhook destination, and send your first signed event to the handler above. No sales call, and nothing is charged 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 a Didit webhook signature in Go?
Read the raw request body, compute HMAC-SHA256 with your destination signing secret, hex-encode it, and compare it to the X-Signature header with hmac.Equal or subtle.ConstantTimeCompare. Check that X-Timestamp is within 300 seconds of now before you compare signatures. Only parse JSON after both checks pass.
Should I use X-Signature or X-Signature-V2?
Didit recommends X-Signature-V2, which is HMAC-SHA256 over the sorted, Unicode-preserved canonical JSON and keeps working when a proxy reformats the body. X-Signature hashes the exact raw bytes and works only if your stack does not re-encode the payload. X-Signature-Simple is deprecated: it authenticates the envelope, not the decision body, so re-fetch the decision from GET /v3/session/{sessionId}/decision/ if you rely on it.
What is the difference between status.updated and data.updated?
status.updated fires when a session or business session status changes, and it carries the full decision on Approved, Declined, In Review and Abandoned. data.updated fires when verification data on a session was edited, so your handler should re-read the decision rather than reuse cached per-feature results.
How fast must my handler respond, and does Didit retry?
Answer 2xx as soon as possible, because a slow or failing endpoint counts as a failed delivery. Didit retries failed deliveries a bounded number of times. Repeated first-attempt failures show up on the destination as health_status set to failing, with failing_streak and failing_since telling you how long it has lasted.
How do I stop the same event being processed twice?
Store event_id when you accept an event and skip an id you have already seen. Retries and manual resends both produce duplicates. Make the state write idempotent too, so granting access to an already approved user is a no-op.
Which status strings should my Go switch statement use?
Use Not Started, In Progress, Approved, Declined, In Review, Awaiting User, Resubmitted, Expired, Abandoned and Kyc Expired. They are exact and case-sensitive, and Kyc Expired uses a single capital K.
Does Didit have an official Go SDK for webhooks?
Yes. Install it with go get github.com/didit-protocol/sdk-go; it needs Go 1.22 or newer and reads DIDIT_API_KEY, DIDIT_ORGANIZATION_ID and DIDIT_APPLICATION_ID from the environment. It calls the server APIs and verifies the webhooks Didit sends you. Release 1.0.1 does not yet include nine server endpoints, most of them Travel Rule, which the docs list explicitly.
Do webhooks cost anything on Didit?
There is no webhook line in the published price book. You pay per completed check: $0.33 for a full ID check, $0.20 for AML screening, from $2.00 per company for business verification. Sandbox testing is free and unlimited, and nothing is charged in sandbox.
How do I test the handler without spending money?
Create a webhook destination in a sandbox application and use Try Webhook in the Console, which delivers an activity.created event to that destination. Sandbox sessions can also be armed with a scenario, shown in the sandbox_scenario field, so you can exercise a declined path without a real document. General deployment guidance: the destination needs a public HTTPS URL, so point it at a staging address rather than a machine on your laptop.
What happens to my endpoint when I rotate the signing secret?
For 24 hours after you rotate a destination's signing secret, Didit also sends X-Signature-V2-Previous or X-Signature-Previous, the same signatures made with the replaced secret. Accept a match on either header so delivery keeps working while your deployment rolls out. These previous headers are never sent for the legacy application webhook URL.
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


