Webhooks

A webhook is a URL of yours that Dispatchlet POSTs to when something happens. Buffer has no webhooks of its own, so this is also the simplest way to know when a Buffer post went out. Add one under Settings → Webhooks, or with POST /api/v1/webhooks. Pick the events, and optionally one automation; the signing secret is shown once.

Events

The delivery

One JSON body per event, with the same shapes the API returns (a run as GET /runs/:id gives it, a post as GET /posts/:id gives it):

POST https://your.example/hook
Content-Type: application/json
User-Agent: Dispatchlet-Webhooks/1
webhook-id: <delivery id>
webhook-timestamp: 1761740000
webhook-signature: v1,<base64 HMAC>

{
  "id": "<delivery id>",
  "type": "post.sent",
  "createdAt": 1761740000123,
  "data": {
    "post": { "_id": "…", "text": "…", "status": "sent", "externalLink": "https://x.com/…", … },
    "automation": { "id": "…", "name": "F1 news" }
  }
}

Answer with any 2xx within ten seconds. Anything else is retried after 1 minute, 10 minutes and 1 hour, then marked failed. Ten failed deliveries in a row switch the webhook off and you get an email. Settings lists the last 50 deliveries of each webhook, with a Retry button.

Verifying the signature

Deliveries follow the Standard Webhooks format, so any of its libraries verify them, and Zapier, Make and n8n have built-ins. By hand: HMAC-SHA256 the string `${webhook-id}.${webhook-timestamp}.${body}` with the secret’s bytes (base64-decode what follows whsec_), base64 the result, and compare with the part after v1,. Refuse timestamps more than five minutes old.

import { createHmac, timingSafeEqual } from 'node:crypto'

export function verify(secret, headers, rawBody) {
  const id = headers['webhook-id']
  const ts = headers['webhook-timestamp']
  const given = (headers['webhook-signature'] ?? '').split(' ')
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false
  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64')
  const expected = 'v1,' + createHmac('sha256', key).update(`${id}.${ts}.${rawBody}`).digest('base64')
  return given.some((s) => s.length === expected.length && timingSafeEqual(Buffer.from(s), Buffer.from(expected)))
}

Use the raw request body, not a re-serialised copy, or the signature will not match.

Recipes

Slack: a Zapier Zap with “Webhooks by Zapier → Catch Hook” as the trigger and “Slack → Send Channel Message” as the action; use data.post.text and data.post.externalLink. n8n: a Webhook node, then whatever you like; the body is already JSON. A spreadsheet of what went out: subscribe to post.sent only and append a row per delivery.

Webhook URLs must be https on port 443 or 8443, on a public host, with no user name or password in them. Deliveries never contain tokens or keys.