Webhook Headers
Strails includes the following headers with every webhook delivery:Signature Format
Strails computes the signature by running HMAC-SHA256 over the concatenation of the timestamp, a literal., and the raw JSON request body:
webhook_secretis the secret you configured when you registered your webhook URL.timestampis the exact value of theX-Strails-Timestampheader.payloadis the raw request body string - do not parse it to JSON and re-serialize it before computing the digest, because whitespace or key ordering differences will produce a different hash.
Verifying Webhooks
- Node.js
- Python
Webhook Handler Example
Acknowledge every webhook immediately with200 OK and do the heavy lifting in a background queue. If your handler takes too long to respond, Strails may retry the delivery.
Configuring Your Webhook Secret
Register your webhook URL and secret by callingPOST /setwebhook:
Best Practices
- Use a long, random secret. Generate at least 32 bytes of cryptographically random data (e.g.
openssl rand -hex 32) and use that as your webhook secret. - Store the secret in an environment variable. Load it from
process.env.STRAILS_WEBHOOK_SECRETor your secrets manager - never hard-code it in source. - Always verify before acting. Process the event payload only after the signature check passes. Treat any verification failure as a potential attack.
- Reject stale timestamps. Discard webhooks where
X-Strails-Timestampis more than 5 minutes in the past to prevent replay attacks. - Return
200 OKquickly and process asynchronously. Enqueue the event and respond immediately. Long-running handlers risk timeouts that trigger unnecessary retries.
See Webhook Events for the complete list of event types and their payload schemas.