# Webhooks

Get a call to your server when something happens.

Make one in **Automations**, or with `POST /automations`. The secret shows once.

```json title="What we send"
{
  "id": "evt_...",
  "type": "sale.created",
  "created_at": "2026-12-03T20:00:00Z",
  "workspace_id": "6f1d2c9a-3b47-4c0e-9a55-1f2e3d4c5b6a",
  "data": { "id": "0b8a7c65-1d2e-4f30-8a9b-7c6d5e4f3a2b", "amount_cents": 200000, "currency": "USD" }
}
```

## Check the signature

| Header | Holds |
|---|---|
| `X-Totems-Id` | The event id |
| `X-Totems-Time` | Time in seconds |
| `X-Totems-Signature` | `v1=` and an HMAC SHA-256 of time, a dot, and the raw body |

Use the raw body, before any JSON parser changes it. Turn away anything older than 5 minutes.

```ts title="verify.ts"
import { createHmac, timingSafeEqual } from "node:crypto";

export function verify(rawBody: string, headers: Headers, secret: string, now = Date.now()): boolean {
  const time = Number(headers.get("x-totems-time"));
  if (!Number.isFinite(time) || Math.abs(now / 1000 - time) > 300) return false;
  const want = Buffer.from("v1=" + createHmac("sha256", secret).update(`${time}.${rawBody}`).digest("hex"));
  const got = Buffer.from(headers.get("x-totems-signature") ?? "");
  return want.length === got.length && timingSafeEqual(want, got);
}
```

## Answer fast

Send any 2xx status within 8 seconds, then do your work. Save the event `id`, and skip one you have seen. The same event can arrive twice.

## Retries

We try again after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 24 hours. Redirects are not followed. Private network addresses are blocked.

The [trigger names](/docs/automations/make) are the same as the event types.
