Skip to main content

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):

typeWhen it is sent
decisionAn event is scored with allow, block or review, sync or async.
case_resolutionAn analyst or an API call decides a review case.
case_wokeA snoozed case wakes up and returns to the open queue. One message per wake.
event_decision_updatedAn analyst changes the decision of a scored event.
webhook.testYou 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_id is the id you submitted. breakdown and flags are the same as in the event result, with rule_name for a readable label.
  • actions is 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"
}
  • decision is allow or block.
  • actor_ref is 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_...).
  • reason and actor_ref can be null or absent.
  • event_id and external_event_id can both be null, 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"
}
  • revision is 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 its revision is higher than the one you hold.
  • previous_decision is the decision in force before the change: the previous manual decision, the resolved case decision, or the engine verdict.
  • event_id is always set here.
  • The decision webhook is not sent again for the event.

Match a webhook to your event​

  • A decision body has your submitted event_id.
  • The other three bodies have event_id (the Defraudo ev_... id) and external_event_id, which holds the event_id you submitted. Use external_event_id to find your payment.
  • external_event_id is null when no linked score is available, for example a legacy case without an event. In case_resolution and case_woke, event_id can then be null too.

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 v1 matches, 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 t is more than 5 minutes from your clock.
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));
}