Webhook security
How to verify incoming webhook payloads, rotate signing secrets, stay within URL rules, and handle retries safely.
The signature header
Signatures are off by default (signature_enabled: false). When enabled and a secret exists, DeePsy signs every delivery and sends:
- Header:
X-Webhook-Signature: sha256=<hex> - Algorithm: HMAC-SHA256 keyed with your
whsec_secret - Signed input: the exact raw UTF-8 JSON request body (unescaped slashes and non-ASCII characters)
Always verify against the raw body bytes before parsing JSON (re-serializing changes escaping and breaks the signature), and use a constant-time comparison:
// Node.js
const expected = 'sha256=' +
crypto.createHmac('sha256', secret).update(rawBody, 'utf8').digest('hex');
const ok = crypto.timingSafeEqual(
Buffer.from(expected),
Buffer.from(req.get('x-webhook-signature') ?? '')
);
Try it locally
Signature playground
Computes HMAC-SHA256 locally in your browser using Web Crypto. Nothing is sent anywhere.
Computing...Enabling & rotating secrets
- At creation: pass
"signature_enabled": truetoPOST /webhooks. Copysecret(whsec_...) from the201response, because you won't see it again. - On an existing webhook:
PUT /webhooks/{webhook_id}lets you togglesignature_enabled, but doesn't generate a secret. CallPOST /webhooks/{webhook_id}/regenerate-secretto issue a newwhsec_secret and turn signatures on:
curl -X POST "https://deepsy.fr/api/v1/webhooks/{webhook_id}/regenerate-secret" \
-H "Authorization: Bearer deepsy-dev-your-api-key-here"
{ "secret": "whsec_abcd1234..." }
Suspended webhooks can't regenerate secrets (400). Set status back to active first.
Regenerating a secret invalidates the old one immediately. Update your receiver to accept the new secret as soon as you rotate (or swap it during a brief maintenance window).
Keep whsec_ in a secret manager or env var, never commit it, and don't log raw secrets or signature headers.
URL & transport rules
- URLs must use
https://(max 500 chars on create) and resolve to a public IP address. - At delivery time, DeePsy resolves your hostname and blocks private, loopback, and reserved IP ranges (this is what triggers
403URL blocked onPOST /webhooks/{webhook_id}/test). - Connect timeout is 10s, overall timeout is 30s, and redirects are not followed (
3xxcounts as failed).
Permissions & ownership
| Operations | Who can call it |
|---|---|
POST /webhooks | API key with ADMINISTRATOR on every company in company_ids |
/companies/{company_id}/webhooks* | API key with ADMINISTRATOR on {company_id} |
/webhooks/list, /webhooks/events, /webhooks/{webhook_id}*, /webhooks/logs* | Owning API key |
Remember the difference between revoke and deny: revoke pauses a company (authorized: false) so it can be re-authorized later; deny removes the company and deletes the webhook if no authorized company is left. All actions are attributed to the API key's creator (Authentication).
Retries & idempotency
Because automatic retries and manual replays can send the same event more than once, make your receiver idempotent using X-Webhook-Delivery (or delivery_id in the JSON body) as your deduplication key. Retries and manual replays reuse it.
- Automatic retries: run up to
max_retries(0–5, default0) only on transient errors: network failures,408,425,429, or5xx. Other4xxresponses fail immediately. Backoff is 2, 4, 8, 16, then 32 minutes. - Manual replay (
POST /webhooks/logs/{log_id}/retry): replays any non-successlog synchronously without checkingmax_retries, resetsretry_countto0, and clearsnext_retry_at. - Your endpoint's response body is stored in the log (up to 8,000 chars) to make debugging easier.