Skip to main content
Every webhook Strails sends is signed with an HMAC-SHA256 signature. Verifying this signature before you act on the payload guarantees that the event originated from Strails and was not tampered with - or replayed - by a third party. Strails passes the signature and all verification metadata in request headers.

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:
Where:
  • webhook_secret is the secret you configured when you registered your webhook URL.
  • timestamp is the exact value of the X-Strails-Timestamp header.
  • payload is 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

Webhook Handler Example

Acknowledge every webhook immediately with 200 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 calling POST /setwebhook:
The /setwebhook endpoint is rate-limited to 10 rpm. Avoid calling it more than once per deployment.

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_SECRET or 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-Timestamp is more than 5 minutes in the past to prevent replay attacks.
  • Return 200 OK quickly 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.