Skip to content
Guides

Webhooks

Register an https endpoint in the dashboard, and Root Herald posts events to it as they happen. Each endpoint gets its own signing secret: check every request with it before you act on the event. Minting a key posts no event.

what arriveshttp
POST /your/endpoint HTTP/1.1
content-type: application/json
webhook-id: msg_2fk9xq7t4b1a
webhook-timestamp: 1756512000
webhook-signature: v1,K8mN2pQ...

{"type":"attestation.verdict","policy_id":"...","verdict":{...}}

Verify the signature

Root Herald signs {webhook-id}.{webhook-timestamp}.{raw body} with HMAC-SHA256 under the endpoint's secret, base64-encodes the result and prefixes it with v1,. Compute the same value, compare it in constant time, and reject anything older than five minutes.

import crypto from "node:crypto";

export function verify(req: { headers: Record<string, string>; rawBody: string }, secret: string) {
  const id = req.headers["webhook-id"];
  const ts = req.headers["webhook-timestamp"];
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;

  const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
  const mac = crypto.createHmac("sha256", key).update(`${id}.${ts}.${req.rawBody}`).digest("base64");
  const expected = Buffer.from(`v1,${mac}`);

  return req.headers["webhook-signature"].split(" ").some((candidate) => {
    const got = Buffer.from(candidate);
    return got.length === expected.length && crypto.timingSafeEqual(got, expected);
  });
}
Validate before you act

An endpoint that skips these headers accepts forged events from anyone who learns its URL.

Events

  • attestation.verdict — a device was appraised. You can narrow it to specific policies.
  • device.enrolled — an enrollment began; no proof exists yet. Proposed: its shape may change.
  • device.activated — an installation proved its attestation key. Carries device_id and platform.
  • usage.alert — a budget's spend or the included devices reached one of its alert thresholds (line: "threshold"), or a budget's spend reached its warn line (line: "warn", thresholdPercent null, limit the line). Once per threshold or line per calendar month.

Disclosure class

Set it per endpoint to cap what each event reveals, whatever verify asked for. It uses the same disclosure classes as a verdict, and starts at pseudonymous.

Delivery

  • Events arrive at least once and in no particular order, so deduplicate on webhook-id; it stays the same across retries.
  • Answer with a 2xx to accept an event. A 3xx counts as a failure, because redirects aren't followed, and 410 Gone disables the endpoint.
  • Failed deliveries are retried for about three days with increasing backoff, so keep your deduplication window at least that long.
  • Twenty failures in a row disable the endpoint; re-enable it in the dashboard.
  • When you rotate a secret, events are signed with the previous one too for 24 hours, with both signatures in the same header, so you can switch without dropping any.
  • The URL must be https, carry no credentials, and resolve to a publicly routable address on every A and AAAA record. Webhooks are on Pro and above.