Verify webhooks
MailPidge follows Standard Webhooks, so any Standard Webhooks library works.
| Header | Value |
|---|---|
webhook-id |
Delivery id (dwd_…), same on every retry |
webhook-timestamp |
Unix seconds of this attempt |
webhook-signature |
v1,<base64>; two space-separated values during rotation |
Verify against the raw body, not a re-serialized one.
import { verifyWebhookRequest } from '@mailpidge/sdk'
const body = await request.text()const isValid = await verifyWebhookRequest({ headers: request.headers, body, secret: process.env.MAILPIDGE_WEBHOOK_SECRET!,})if (!isValid) return new Response('invalid signature', { status: 401 })from mailpidge import verify_webhook_request
body = request.get_data(as_text=True)if not verify_webhook_request(headers=request.headers, body=body, secret=WEBHOOK_SECRET): return "invalid signature", 401- Refuse if
webhook-timestampis more than 300 s from your clock. - Base64-decode the part of the secret after
whsec_. - HMAC-SHA256
{webhook-id}.{webhook-timestamp}.{body}with it; base64-encode. - Compare with each
v1,value in constant time. One match passes.
Rotate the secret
Section titled “Rotate the secret”After Rotate secret, requests carry both signatures for 72 hours.