# Webhooks

> Get a signed HTTP request whenever posts, pages, tags or site settings change.

Webhooks tell your systems when content changes: refresh a cache, rebuild a static site, post to Slack. Changes made in the dashboard and by agents over MCP both trigger them.

## Add a webhook

1. Open **Settings → Developer → Webhooks** (admins only).
2. Enter the URL that should receive requests.
3. Pick the events to listen to. Tick a group such as **Posts** to select all of its events.
4. Save, and copy the **signing secret** (`whsec_…`).

Use **Send test** to deliver a sample request. Each webhook shows the time, HTTP status and error of its last attempt.

A site can have up to 50 webhooks.

## Events

| Event | When |
| --- | --- |
| `site.updated` | Site settings, design, integrations or navigation change |
| `post.created` | A post is created, in any status |
| `post.updated` | A post is saved |
| `post.published` | A post is created as, or changes to, published, including a scheduled post going live at its publish date |
| `post.deleted` | A post is deleted (moved to the trash) |
| `page.created` · `page.updated` · `page.deleted` | The same for pages |
| `tag.created` · `tag.updated` · `tag.deleted` | Tag changes |

A webhook only receives the events you ticked. Events added to Quillhive later are not turned on for existing webhooks.

## The request

Quillhive sends one `POST` per event:

```http
POST /your/endpoint HTTP/1.1
Content-Type: application/json
User-Agent: Blogging-Webhooks/1.0
X-Blogging-Event: post.published
X-Blogging-Delivery: 5f0c…
X-Blogging-Signature: t=1762682400,v1=3b1f…

{
  "id": "5f0c…",
  "event": "post.published",
  "createdAt": "2026-11-09T10:00:00.000Z",
  "site": { "id": "…", "slug": "field-notes" },
  "data": { "postId": "…", "postSlug": "hello-world" }
}
```

`data` carries the ids and slugs of what changed: `postId` and `postSlug`, `pageId` and `pageSlug`, `tagSlug`, or `tagSlugs`. Fetch the full object from the [Content API](/docs/api) if you need it. A test delivery sends `{ "test": true }` as `data`.

## Verify the signature

Always check that a request came from Quillhive before acting on it.

`X-Blogging-Signature` has a timestamp `t` and a signature `v1`. `v1` is the hex HMAC-SHA256 of `` `${t}.${rawBody}` ``, keyed with your signing secret. Compute it over the **raw** request body, before parsing JSON.

```typescript title="verify.ts"
import { createHmac, timingSafeEqual } from 'crypto'

export function verifyQuillhiveSignature(
  rawBody: string,
  header: string,
  secret: string,
) {
  const { t, v1 } = Object.fromEntries(
    header.split(',').map((part) => part.split('=')),
  )
  const expected = createHmac('sha256', secret)
    .update(`${t}.${rawBody}`)
    .digest('hex')
  // Reject old requests to block replays
  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300
  return (
    fresh &&
    v1?.length === expected.length &&
    timingSafeEqual(Buffer.from(v1), Buffer.from(expected))
  )
}
```

```typescript title="Next.js route handler"
import { revalidateTag } from 'next/cache'

export async function POST(request: Request) {
  const body = await request.text()
  const signature = request.headers.get('x-blogging-signature') ?? ''
  if (!verifyQuillhiveSignature(body, signature, process.env.QUILLHIVE_WEBHOOK_SECRET!)) {
    return new Response('Invalid signature', { status: 401 })
  }
  const { event, data } = JSON.parse(body)
  if (data.postSlug) revalidateTag(`post:${data.postSlug}`)
  revalidateTag('posts')
  return Response.json({ ok: true, event })
}
```

A site has **one signing secret shared by all its webhooks**, so one endpoint can verify every event with one value. Rotate it from the Webhooks page; the new secret applies to every webhook at once.

## Delivery

- Sent right after the change is saved. One attempt with a 10 second timeout; there are no retries yet.
- Any `2xx` response counts as success.
- URLs must be `http` or `https` and resolve to a public address. Redirects are not followed.
- Respond quickly, and do slow work in the background.

> [!TIP]
> Since there are no retries, also give cached content a time limit, so a missed webhook only delays an update.
