Webhooks
Defraudo sends every webhook below to one URL per project, as signed JSON. Read the type field of the body to route it (alert webhooks you add to notification rules go to their own URLs and have a different body):
type | When it is sent |
|---|---|
decision | An event is scored with allow, block or review, sync or async. |
case_resolution | An analyst or an API call decides a review case. |
case_woke | A snoozed case wakes up and returns to the open queue. One message per wake. |
event_decision_updated | An analyst changes the decision of a scored event. |
webhook.test | You press the test send in the project settings. Body: webhook_id, type, project_id, sent_at, with no environment. |
switch (body.type) {
case 'decision': /* act on body.decision */ break;
case 'case_resolution': /* apply body.decision to the held action */ break;
case 'case_woke': /* the case is open again */ break;
case 'event_decision_updated': /* apply body.decision if body.revision is newer */ break;
}
Every body has webhook_id. Every body except webhook.test also has environment (live or sandbox).
Examples
decision
{
"webhook_id": "msg_01k3f7wz9re2xa8m4n0dpq5vjt",
"type": "decision",
"event_id": "3f2b8c1e-5d47-4a9e-9c6b-0e1f2a3b4c5d",
"risk_score": 30,
"max_possible": 480,
"decision": "review",
"breakdown": [
{ "rule_id": "R-MED-REP-SUSPICIOUS-PAYMENT-REF", "rule_name": "Suspicious wallet or IBAN", "rule_version": 8, "score_delta": 30, "band": "medium", "matched": true, "reason": "R-MED-REP-SUSPICIOUS-PAYMENT-REF" }
],
"flags": [],
"trust_override": false,
"hard_block_hit": false,
"latency_ms": 12,
"environment": "live",
"actions": []
}
- Sent for every scored event, including
review. - Each message has its own
webhook_id. The examples below use different ones on purpose. event_idis the id you submitted.breakdownandflagsare the same as in the event result, withrule_namefor a readable label.actionsis empty when no rule requested one.
case_resolution
{
"webhook_id": "msg_01k3f7x4c8e5ya9n2p1dqr6wkv",
"type": "case_resolution",
"event_id": "ev_01k3f7wz9re2xa8m4n0dpq5vjt",
"external_event_id": "3f2b8c1e-5d47-4a9e-9c6b-0e1f2a3b4c5d",
"case_id": "case_01k3f7wz9re2xa8m4n0dpq5vjt",
"decision": "block",
"reason": "Card used on four accounts",
"actor_ref": "0192f3c4-8b7a-7c3e-9d21-5f6a7b8c9d0e",
"decided_at": "2026-11-18T10:15:00Z",
"environment": "live"
}
decisionisalloworblock.actor_refis the id of the Dashboard user who decided. When the case was decided through the API it is the API key as the Dashboard lists it (key_...).reasonandactor_refcan benullor absent.event_idandexternal_event_idcan both benull, for a case that has no linked event.- A snooze sends no resolution. See
case_woke.
case_woke
{
"webhook_id": "msg_01k3f7xm6f3qza7b5t0dnr8hcw",
"type": "case_woke",
"case_id": "case_01k3f7wz9re2xa8m4n0dpq5vjt",
"event_id": "ev_01k3f7wz9re2xa8m4n0dpq5vjt",
"external_event_id": "3f2b8c1e-5d47-4a9e-9c6b-0e1f2a3b4c5d",
"woke_at": "2026-11-18T10:15:00Z",
"environment": "live"
}
A case snoozed twice sends two case_woke messages with different webhook_id values. event_id and external_event_id can both be null.
event_decision_updated
{
"webhook_id": "msg_01k3f7y2h9d4ma6c1v3dps7jxe",
"type": "event_decision_updated",
"event_id": "ev_01k3f7wz9re2xa8m4n0dpq5vjt",
"external_event_id": "3f2b8c1e-5d47-4a9e-9c6b-0e1f2a3b4c5d",
"decision": "allow",
"previous_decision": "review",
"revision": 1,
"reason": "Verified by phone",
"actor_ref": "0192f3c4-8b7a-7c3e-9d21-5f6a7b8c9d0e",
"decided_at": "2026-11-18T10:15:00Z",
"environment": "live"
}
revisionis 1 for the first manual change of an event and grows by one with each change. Retries can deliver an older change after a newer one, so apply a message only when itsrevisionis higher than the one you hold.previous_decisionis the decision in force before the change: the previous manual decision, the resolved case decision, or the engine verdict.event_idis always set here.- The
decisionwebhook is not sent again for the event.
Match a webhook to your event
- A
decisionbody has your submittedevent_id. - The other three bodies have
event_id(the Defraudoev_...id) andexternal_event_id, which holds theevent_idyou submitted. Useexternal_event_idto find your payment. external_event_idisnullwhen no linked score is available, for example a legacy case without an event. Incase_resolutionandcase_woke,event_idcan then benulltoo.
Set up and receive
Set the webhook URL and a signing secret on the project in the dashboard. The URL must be HTTPS on port 443 or 8443, without credentials, and not a private or internal host. Each delivery times out after 5 seconds.
Return any 2xx to acknowledge. A non-2xx, a timeout or a redirect counts as failure.
Retries and duplicates
- Each delivery makes up to three attempts in a row, 1 second and 2 seconds apart. If all fail, the message is retried after 1 minute, then 5 minutes, then every 15 minutes until your endpoint answers
2xx. - A URL that is not allowed, or a host that resolves to a private address, is not retried.
- Delivery is at least once. Deduplicate on
webhook_id: every retry of a message carries the same value, and no other message does. - While a project has a URL but no signing secret, messages are held and go out once a secret is set. With no URL, nothing is sent.
The Webhook section of the project settings lists recent deliveries, with the response code, attempts, duration and error, kept for 30 days; a message that failed and was delivered later shows a row for each. A test send there posts one signed sample to the URL right away, without retries, and needs a signing secret.
Verify the signature
Each request has the header x-antifrod-signature: t=<unix-ms>,v1=<hex>[,v1=<hex>...]. The signature is HMAC-SHA256(secret, "<t>.<raw body>") in hex. Rules:
- Use the raw request body, not re-serialised JSON.
- Accept the request if any
v1matches, compared in constant time. During the 24 hours after a secret rotation the header carries signatures for the new secret and up to three recently replaced ones. - Reject if
tis more than 5 minutes from your clock.
- Node.js
- Python
- PHP
import crypto from 'node:crypto';
export function verify(rawBody, header, secret, maxSkewMs = 300_000) {
let t;
const signatures = [];
for (const part of header.split(',')) {
const [key, value] = [part.slice(0, part.indexOf('=')).trim(), part.slice(part.indexOf('=') + 1).trim()];
if (key === 't') t = parseInt(value, 10);
if (key === 'v1' && /^[0-9a-f]{64}$/i.test(value)) signatures.push(value);
}
if (!Number.isFinite(t) || signatures.length === 0) return false;
if (Math.abs(Date.now() - t) > maxSkewMs) return false;
const expected = crypto.createHmac('sha256', secret).update(`${t}.${rawBody}`).digest();
return signatures.some((signature) => crypto.timingSafeEqual(Buffer.from(signature, 'hex'), expected));
}
import hashlib
import hmac
import time
def verify(raw_body: bytes, header: str, secret: str, max_skew_ms: int = 300_000) -> bool:
t = None
signatures = []
for part in header.split(','):
key, _, value = part.strip().partition('=')
if key == 't' and value.isdigit():
t = int(value)
elif key == 'v1' and len(value) == 64:
signatures.append(value.lower())
if t is None or not signatures:
return False
if abs(time.time() * 1000 - t) > max_skew_ms:
return False
expected = hmac.new(secret.encode(), f'{t}.'.encode() + raw_body, hashlib.sha256).hexdigest()
return any(hmac.compare_digest(signature, expected) for signature in signatures)
<?php
function verify(string $rawBody, string $header, string $secret, int $maxSkewMs = 300000): bool
{
$t = null;
$signatures = [];
foreach (explode(',', $header) as $part) {
[$key, $value] = array_pad(explode('=', trim($part), 2), 2, '');
if ($key === 't' && ctype_digit($value)) $t = (int) $value;
if ($key === 'v1' && preg_match('/^[0-9a-f]{64}$/i', $value)) $signatures[] = strtolower($value);
}
if ($t === null || !$signatures) return false;
if (abs((int) (microtime(true) * 1000) - $t) > $maxSkewMs) return false;
$expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret);
foreach ($signatures as $signature) {
if (hash_equals($expected, $signature)) return true;
}
return false;
}