Webhooks
POST /v1/webhooks with { "url": "https://...", "events": [...] } registers an https endpoint and returns its signing secret once. Store it then; it is not shown again.
Events
analysis.completed: carries the full result indata.result.analysis.failed
Both are sent by default. Failed deliveries are retried with backoff.
Checking a delivery
Each delivery carries nextgrade-event, nextgrade-delivery and nextgrade-signature: t=<unix>,v1=<hex>. The signature is the HMAC-SHA256 of t + "." + body with your secret. Check it, and reject old timestamps.
import { createHmac, timingSafeEqual } from "node:crypto";
function verify(body, header, secret) {
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const expected = createHmac("sha256", secret).update(`${t}.${body}`).digest("hex");
return timingSafeEqual(Buffer.from(expected), Buffer.from(v1));
}Managing endpoints
GET /v1/webhooks lists them and DELETE /v1/webhooks/{id} turns one off.