POST to your HTTPS endpoint every time an alert attached to it fires (alert.triggered) or recovers (alert.recovered). Each request carries an HMAC-SHA256 signature over a timestamp and the raw body, so your endpoint can prove the request came from CrispStats and is recent. This page covers the payload, the headers, how to verify the signature and how to handle retries.
Set up the channel and the alerts that use it in the dashboard; see alert channels.
Endpoint requirements
Events
Headers
Payload
The body is a JSON object. Fields undermessage are written for people and are the same text the email, Slack and Discord channels show; data carries the raw numbers behind the alert.
The raw values that triggered the alert. Its fields depend on the rule type.
{ "test": true } on alert.test.Verify the signature
1
Read the raw body
Read the request body as bytes before any JSON parsing. Parsing and re-serializing changes the bytes and breaks the signature.
2
Check the timestamp
Read
X-CrispStats-Timestamp. Reject the request if it is more than 300 seconds away from your current time, in either direction. This stops an old request from being replayed.3
Compute the expected signature
Compute HMAC-SHA256 with the channel’s signing secret as the key, over the string
{timestamp}.{raw body}: the timestamp, a full stop, then the body. Encode the result as lowercase hex.4
Compare in constant time
X-CrispStats-Signature holds one or more v1=<hex> values separated by commas or spaces. Accept the request if any v1 value equals your result, using a constant-time comparison.5
Deduplicate
Store each
X-CrispStats-Delivery id you have processed, and skip a request whose id you have seen. Then answer 200.CRISPSTATS_WEBHOOK_SECRET.
express.raw({ type: "application/json" }) on the webhook route, and in Flask use request.get_data().
Retries and duplicates
- A
429or5xxanswer is retried once, after theRetry-Afteryou send (seconds or an HTTP date) or after 1 second. IfRetry-Afteris longer than 5 seconds, the delivery fails without a retry. - A timeout or network error is not retried, because the request may have arrived. A
4xxother than429, and any3xx, fail at once. - If a delivery run is interrupted, the firing is picked up again later and sent with the same delivery id.
X-CrispStats-Delivery. Answer quickly and do slow work after responding, so you stay inside the 8-second timeout.
Next steps
Alert channels
Add a webhook channel and send a test.
Alert rule types
What each rule type watches and when it fires.
Alerts overview
How alerts, cooldowns and recoveries work.