# Webhooks

Get every change of your orders as a signed POST to your own address, and check the signature.


A webhook sends each change of the orders in your account to an address that you choose: the status, the quote, the payment, the tracking, messages, refunds and the assembly guide. Agents use it to act at once, without asking again and again.

## Add a webhook

`POST /webhooks` with the `url` and an optional `description`. The address must use `https`. It answers `201` with the webhook and its `secret`. The secret shows only once: keep it with the endpoint.

```sh
curl -X POST https://summonmade.com/api/v1/webhooks \
  -H "Authorization: Bearer $SUMMONMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/summonmade", "description": "Order updates for my agent"}'
```

```json
{
  "webhook": {
    "id": "wh_3kPq8ZtRw2mXa7Vb",
    "url": "https://example.com/summonmade",
    "description": "Order updates for my agent",
    "createdAt": "2026-12-03T09:30:00.000Z",
    "lastStatus": null,
    "lastAttemptAt": null
  },
  "secret": "whsec_…"
}
```

An account has at most 10 webhooks.

## List and delete webhooks

`GET /webhooks` answers `200` with `{ "webhooks": [...] }`. Each webhook shows `lastStatus`, the HTTP status of its last delivery, and `lastAttemptAt`. The list does not show the secrets.

`DELETE /webhooks/{id}` deletes a webhook. Deliveries to it stop at once.

```sh
curl https://summonmade.com/api/v1/webhooks -H "Authorization: Bearer $SUMMONMADE_API_KEY"
curl -X DELETE https://summonmade.com/api/v1/webhooks/wh_3kPq8ZtRw2mXa7Vb -H "Authorization: Bearer $SUMMONMADE_API_KEY"
```

## The delivery

Each change is a `POST` to your address with a JSON body:

| Field | What it holds |
| --- | --- |
| `type` | `order.updated`. |
| `order` | The order after the change, with every field, as `GET /orders/{id}` gives it. |
| `event` | The event that changed it, with `id`, `at`, `type`, `detail`, `by` and `status`. See [Read an order](/docs/api/orders#read-an-order). |

The events that send a webhook are `submitted`, `quote_review`, `quoted`, `paid`, `in_production`, `shipped`, `delivered`, `cancelled`, `refunded`, `message` and `instructions`.

Answer with a `2xx` status within 10 seconds. When the endpoint fails, Summonmade tries again after 30 seconds and after 5 minutes: 3 attempts in all. A repeated delivery has the same order ID and event `id`, so use the two together to ignore a repeat.

## Check the signature

Each delivery has the header `Summonmade-Signature`:

```text
Summonmade-Signature: t=1764754200,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
```

`t` is the time of the delivery in Unix seconds. `v1` is the HMAC-SHA256 of `t`, a dot and the raw body, with the webhook's secret as the key, in hexadecimal. Check it before you trust the body:

```js tab="JavaScript"
import { createHmac, timingSafeEqual } from "node:crypto";

function verify(header, body, secret) {
  const { t, v1 } = Object.fromEntries(header.split(",").map((part) => part.split("=")));
  if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
  const expected = createHmac("sha256", secret).update(`${t}.${body}`).digest("hex");
  return v1.length === expected.length && timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
}
```

```python tab="Python"
import hashlib
import hmac
import time

def verify(header: str, body: bytes, secret: str) -> bool:
    parts = dict(part.split("=", 1) for part in header.split(","))
    if abs(time.time() - int(parts["t"])) > 300:
        return False
    expected = hmac.new(secret.encode(), parts["t"].encode() + b"." + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(parts["v1"], expected)
```

Use the raw body as it arrived, before you parse the JSON. Refuse a delivery that is older than five minutes.

:::callout{type="note"}
The OpenAPI description lists the delivery as the webhook `order.updated`, with the schema `WebhookEvent`. See `https://summonmade.com/openapi.json`.
:::
