webhook.test
Sent only by `testWebhook`, only to that endpoint, at once (also while it is turned off).
webhook-id*stringThe event's id. The same on every retry and replay of it, so dedupe on it.
^evt_[0-9A-Za-z]{20}$"evt_3Kp8Zr1WqN6xBv4MhS9a"webhook-timestamp*stringUnix seconds when this attempt was sent, as a decimal string. It is signed in, so refuse one more than 5 minutes away from now.
^[0-9]+$webhook-signature*stringOne v1,<base64> per secret still signing, space-separated (two after a rotation, during its grace).
To verify: the signature is the base64 HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{raw body}, keyed
with the bytes of the secret (the base64 after whsec_, decoded). Check the raw body before parsing it,
refuse a timestamp more than 5 minutes off, compare in constant time, and accept if any v1, signature
matches. Any Standard Webhooks library does all of this (npm i standardwebhooks, pip install standardwebhooks, Go, Rust, PHP, Ruby: new Webhook(secret).verify(rawBody, headers)). By hand, in Node:
import crypto from "node:crypto";export function verifyWebhook(secret, headers, rawBody) { const id = headers["webhook-id"], ts = headers["webhook-timestamp"], sigs = headers["webhook-signature"] ?? ""; if (!id || !ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; const key = Buffer.from(secret.slice("whsec_".length), "base64"); const expected = crypto.createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest(); return sigs.split(" ").some((s) => { if (!s.startsWith("v1,")) return false; const given = Buffer.from(s.slice(3), "base64"); return given.length === expected.length && crypto.timingSafeEqual(given, expected); });}^v1,[A-Za-z0-9+/]+={0,2}( v1,[A-Za-z0-9+/]+={0,2})*$"v1,j3DA+jkjXWui/cEnonEAVLuZfyTYaPasc6ZdLT4x/Vk="user-agent*stringAlways daxov-webhooks/1.
application/json- body
Every webhook delivery's body. The JSON is compact, with its keys in alphabetical order.
{ "created_unix": 1793300100, "data": { "endpoint_id": "whe_6Tn1Vb8XcK3mPq9LsD2f", "message": "A test event: this endpoint receives webhooks." }, "id": "evt_7Rc2Yj5LmT9pQw3NdF6k", "type": "webhook.test"}id*EventId^evt_[0-9A-Za-z]{20}$"evt_3Kp8Zr1WqN6xBv4MhS9a"type*stringThe event's type.
created_unix*UnixUnix seconds, UTC.
int641793300000data*What the event is about; its shape depends on type.
Delivered. Answer any 2xx within 10 seconds, then do the slow work. The body is ignored.
{ "created_unix": 1793300100, "data": { "endpoint_id": "whe_6Tn1Vb8XcK3mPq9LsD2f", "message": "A test event: this endpoint receives webhooks." }, "id": "evt_7Rc2Yj5LmT9pQw3NdF6k", "type": "webhook.test"}{ "webhook-id": "evt_7Rc2Yj5LmT9pQw3NdF6k", "webhook-timestamp": "1793300100", "webhook-signature": "v1,j3DA+jkjXWui/cEnonEAVLuZfyTYaPasc6ZdLT4x/Vk=", "user-agent": "daxov-webhooks/1"}