guide
Alert delivery & webhooks
Breached alert rules are evaluated hourly in the background and delivered to the channels you configure — email and HMAC-signed webhooks — with every attempt logged on the dashboard. Here's how delivery behaves, and how to build a receiver that verifies it.
Delivery semantics
- Dedupe counts successes only
- A rule+channel that delivered successfully stays quiet for its dedupe window (default 6h). Failed or skipped attempts don't consume the window — outages are retried on the next hourly evaluation, not silenced.
- No retry queue
- A failed attempt is recorded and retried at the next hourly tick while the rule is still breached. Every attempt — sent, failed, skipped — is listed under Recent alert deliveries.
- In-app always works
- Channels are additive: the dashboard banner and rules table show breaches whether or not delivery is configured.
- Public HTTPS targets only
- The SSRF guard resolves the hostname before connecting and again on the connection it opens (so a DNS answer that changes in between is refused too), refuses private, loopback, and metadata addresses, and does not follow redirects. Local dev can opt in with ALERT_WEBHOOK_ALLOW_LOCALHOST=1.
Two server env vars, then add recipients to the rule. Unset SMTP is recorded as skipped — never a silent drop.
SMTP_URL="smtps://user:pass@smtp.example.com:465" # any nodemailer URL SMTP_FROM="alerts@your-verified-domain.com" # Resend: smtps://resend:API_KEY@smtp.resend.com:465
The webhook payload
POSTed with Content-Type: application/json and X-AgentSentri-Signature — a hex HMAC-SHA256 of the raw request body, keyed with the rule's secret (stored encrypted, never returned by any API). 5s timeout, no redirects; any 2xx records sent.
{
"ruleId": "…",
"ruleName": "Low helpfulness",
"description": "Avg \"helpfulness\" score < 0.6 over 24h",
"metric": "avg_score",
"scoreName": "helpfulness",
"value": 0.41,
"threshold": 0.6,
"comparator": "lt",
"windowHours": 24,
"projectId": "…",
"firedAt": "2026-07-17T21:10:00.000Z"
}The one rule of receivers: verify over the RAW body
The signature covers the exact bytes sent. If your framework parses JSON before you read the body, re-serializing it produces different bytes and verification fails. Capture the raw body — Express uses express.raw() on the route; in Next.js:
// Next.js route handler — req.text() gives you the RAW body
import { createHmac, timingSafeEqual } from "node:crypto";
export async function POST(req: Request) {
const rawBody = await req.text();
const header = req.headers.get("X-AgentSentri-Signature") ?? "";
const expected = Buffer.from(
createHmac("sha256", process.env.ALERT_SECRET!)
.update(rawBody)
.digest("hex")
);
const received = Buffer.from(header);
if (expected.length !== received.length || !timingSafeEqual(expected, received)) {
return new Response("bad signature", { status: 401 });
}
const alert = JSON.parse(rawBody);
// route it: Slack, PagerDuty, ticket, …
return new Response(null, { status: 204 });
}Note the length guard: timingSafeEqual throws on length mismatch rather than returning false.
Reading the delivery log
| skipped — SMTP_URL not configured | Set SMTP_URL/SMTP_FROM; the next breached evaluation sends (skips never consume the dedupe window). |
| failed — SSRF guard: … | The URL was refused: it must be https and its host must resolve to a public address (not private, loopback, or metadata). The exact reason is not shown; your operator can read it in the server log. |
| failed — webhook request failed (ECONNREFUSED) | Your receiver could not be reached (or the TLS handshake failed); the code says which. Check the URL, the port, and the certificate. |
| failed — HTTP 401 | Your receiver rejected the signature — almost always a raw-body problem or a secret mismatch. |
| failed — webhook request timed out | Receiver took longer than 5s; respond 2xx first, process async. |
| Nothing at all | Rule not breached, channel not saved, or inside the dedupe window from an earlier successful delivery. |