Webhooks send events to a URL of yours as they happen, so your systems do not have to ask. Add an endpoint in the dashboard under Webhooks and choose its events. Each event then arrives as an HTTPS POST with a JSON body, signed with the endpoint's secret.
Webhooks follow the Standard Webhooks specification, so you can verify them with its libraries for most languages.
Events#
| Type | When |
|---|---|
moderation.completed |
A check finished, with status completed or partial. Playground checks count too; source says api or playground. |
moderation.flagged |
A check finished and raised at least one flag. |
moderation.failed |
An async check ended without a result. |
moderation.action |
An action was taken on a request, in the dashboard or through the API. See Metadata and actions. |
live.moment |
A live session kept a flagged moment. |
live.session.ended |
A live session stopped: you stopped it, it ran out of credits or frames, or its stream ended or failed. |
webhook.test |
You pressed Send test event on an endpoint's page. Only that endpoint gets it. |
The request#
Every event is a POST with a JSON body. An example:
{
"type": "moderation.flagged",
"timestamp": "2026-10-02T09:41:07.512Z",
"data": {
"id": 1042,
"type": "image_moderation",
"mode": "capture",
"status": "completed",
"flagged": true,
"flags": [
{ "flag": "sexual", "confidence": 0.91, "detections": [{ "label": "sexual", "confidence": 0.91 }] }
],
"checked": ["hate", "scam", "sexual", "violence"],
"unchecked": [],
"tookMs": 412,
"usage": { "charged": 2, "remaining": 28 },
"source": "api"
}
}type: the event.timestamp: when it happened (ISO 8601).data, by event:moderation.completedandmoderation.flagged: the object the API answers with (see Responses), plussource. Yourmetadatais in it when you sent one.moderation.failed:id,type, yourmetadata, and the error (error,message).moderation.action: the action, the note, who took it, and the request with yourmetadata. See Metadata and actions.live.moment:id(the moment in your moderation history),sessionId,t(seconds into the session),flags, and the session'smetadatawhen it was started with one.live.session.ended: the session asGET /api/v1/live/sessions/{id}returns it, with itsstatus,reasonandmetadata.webhook.test:endpointId.
The headers:
| Header | Value |
|---|---|
webhook-id |
The message's id, for example msg_6f1c2e…. It is the same on every retry: use it to process each message once. |
webhook-timestamp |
When this attempt was sent, in Unix seconds. |
webhook-signature |
v1, followed by the signature in base64. Several may come, separated by spaces. |
Content-Type |
application/json |
User-Agent |
Detectivision-Webhooks/1.0 |
Verify the signature#
Each endpoint has a signing secret that starts with whsec_. Reveal it on the endpoint's page in the dashboard.
How the signature is made:
- The key is the part of the secret after
whsec_, base64-decoded. - The signed text is
{webhook-id}.{webhook-timestamp}.{body}. - The signature is HMAC-SHA256 of that text with that key, in base64.
Before you trust a message:
- Check its signature against the raw body, before parsing the JSON.
- Refuse it when
webhook-timestampis more than 5 minutes from your clock.
import crypto from "node:crypto";
export function verify(secret, headers, rawBody) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) throw new Error("too old");
const key = Buffer.from(secret.slice("whsec_".length), "base64");
const expected = crypto.createHmac("sha256", key).update(`${id}.${timestamp}.${rawBody}`).digest("base64");
const ok = headers["webhook-signature"]
.split(" ")
.map((s) => s.split(",")[1] ?? "")
.some((s) => s.length === expected.length && crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected)));
if (!ok) throw new Error("bad signature");
return JSON.parse(rawBody);
}import base64, hashlib, hmac, json, time
def verify(secret: str, headers: dict, raw_body: bytes) -> dict:
msg_id = headers["webhook-id"]
timestamp = headers["webhook-timestamp"]
if abs(time.time() - int(timestamp)) > 300:
raise ValueError("too old")
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{msg_id}.{timestamp}.".encode() + raw_body
expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
signatures = [s.split(",", 1)[1] for s in headers["webhook-signature"].split() if "," in s]
if not any(hmac.compare_digest(s, expected) for s in signatures):
raise ValueError("bad signature")
return json.loads(raw_body)The Standard Webhooks libraries do the same in one call. For example, after npm install standardwebhooks or pip install standardwebhooks: new Webhook(secret).verify(body, headers).
Answer quickly#
Answer with any 2xx status within 10 seconds, and do the work after answering. Anything else counts as a failure: another status, a redirect, or no answer within 10 seconds.
Retries#
When an attempt fails, the message is sent again after 1 minute, then 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours and 10 hours. That is 8 attempts over about 28 hours.
- Each attempt has a new
webhook-timestampand signature, but the samewebhook-id. - A message can arrive more than once and out of order. Use
webhook-idto process each one once, andtimestampto put them in order.
An endpoint that fails every attempt for 5 days is switched off. You can switch it back on in the dashboard. Its failed deliveries stay in its list and can be sent again; events that happen while it is off are not sent to it.
Endpoints#
- An account can have up to 10 endpoints, each with its own URL, events and secret.
- The URL must use
https, be on a public host, and leave out any user or password. - Rotate gives an endpoint a new secret at once, so update your receiver right away.
- An endpoint's page lists its deliveries from the last 30 days. Each one shows what was sent and what your server answered, and you can send it again.