# Webhooks

> Signed events when lists finish, credits run low, or outcomes arrive.

Add an endpoint in the dashboard (**Webhooks**) or with `POST https://api.verifyngn.com/v1/webhooks` `{"url": "https://...", "events": [...]}`. The signing secret is shown once.

Events: `list.completed`, `list.failed`, `credits.low`, `feedback.received`. Each is a POST with JSON `{"id", "type", "created_at", "data"}` and the headers `Verify-Event-Id` and `Verify-Event-Type`. `data` is `{"list"}` for list events, `{"balance", "threshold"}` for credits.low and `{"email", "outcome", "at"}` for feedback.received.

## Signatures

Every request carries `Verify-Signature: t=<unix seconds>,v1=<hex>`, where `v1` is HMAC-SHA256 of `"<t>.<raw body>"` with your secret. Check it and refuse anything older than 5 minutes:

```js
import { createHmac, timingSafeEqual } from "node:crypto";
function verify(secret, rawBody, header) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return false;
  const want = createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
  return want.length === parts.v1.length && timingSafeEqual(Buffer.from(want), Buffer.from(parts.v1));
}
```

## Retries

Answer with any 2xx within 10 seconds. Otherwise we retry after 1 minute, 5 minutes, 30 minutes, 2, 6, 12 and 24 hours, then stop.
