Docs / Integrations
Webhooks
Signed event delivery, verification and retries.
Delivery needs the runtime events worker, which the base Compose file does not start.
Create an endpoint
curl -X POST $RAI_BASE_URL/v1/productization/webhooks \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"name":"ops","url":"https://hooks.example.com/rai","event_types":["approval.*","enforcement.deny"]}'The signing secret (whsec_…) is returned once. URLs must be HTTPS and resolve to public addresses unless WEBHOOK_ALLOW_HTTP or WEBHOOK_ALLOW_PRIVATE_HOSTS allow otherwise. Rotate with POST .../webhooks/{id}/rotate.
Events
| Event | When |
|---|---|
approval.requested, approval.approved, approval.rejected | Approval created or decided |
approval.cancelled, approval.expired, approval.consumed | Approval closed or used |
enforcement.deny, enforcement.require_approval, enforcement.monitor | Runtime decisions |
risk.finding.created | A new finding |
Subscribe to a family with approval.* or enforcement.*. Plain allow decisions do not emit events. Approval payloads contain identifiers and an action digest, not raw parameters.
{
"id": "event-id",
"type": "approval.requested",
"created_at": "2026-01-01T10:00:00+00:00",
"data": { "approval_request_id": "…", "status": "PENDING", "expires_at": "…" }
}Verify the signature
X-RAI-Signature is v1= followed by the hex HMAC-SHA256 of {X-RAI-Timestamp}.{raw body}. Verify against the raw bytes and reject old timestamps.
import hashlib, hmac, time
def verify(secret: str, headers, body: bytes, max_skew: int = 300) -> bool:
timestamp = headers["X-RAI-Timestamp"]
if abs(time.time() - int(timestamp)) > max_skew:
return False
expected = hmac.new(secret.encode(), timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
return hmac.compare_digest("v1=" + expected, headers["X-RAI-Signature"])const crypto = require("node:crypto");
function verify(secret, headers, rawBody, maxSkew = 300) {
const timestamp = headers["x-rai-timestamp"];
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > maxSkew) return false;
const digest = crypto.createHmac("sha256", secret).update(timestamp + ".").update(rawBody).digest("hex");
const expected = Buffer.from("v1=" + digest);
const received = Buffer.from(headers["x-rai-signature"] || "");
return expected.length === received.length && crypto.timingSafeEqual(expected, received);
}Delivery
Respond with a 2xx status within 10 seconds. Failures are retried up to 8 attempts with growing delays, then dead-lettered. Deduplicate on X-RAI-Event-Id. Inspect attempts at GET /v1/productization/webhooks/deliveries.