Developers

Webhooks

Get notified in real time when orders, bookings and invoices change, instead of polling.

A business registers its own webhook endpoints through this API. This is separate from Resend's inbound email webhook, which is BeniBrain's own infrastructure and isn't part of this integration surface — the endpoints below are for a business's outbound notifications about its own orders and bookings.

A business adds webhook endpoints in Settings → Developers → Webhooks (or through these endpoints with a dashboard session). Each business can register up to 10 endpoints.

Event catalogue

EventFires when
conversation.createdA new customer conversation starts
message.receivedA customer sends a message
order.createdA store order is created
order.paidAn order's payment is confirmed
order.fulfilledAn order is marked fulfilled/shipped
order.refundedAn order is refunded (partial or full)
order.cancelledAn order is cancelled
invoice.paidAn invoice is paid
invoice.sentAn invoice is sent to a customer
invoice.voidedAn invoice is voided
booking.createdA booking is created
booking.confirmedA booking's payment/hold is confirmed
booking.cancelledA booking is cancelled
booking.rescheduledA booking's time is changed

Subscribe to specific events with a comma-separated events list, or "*" for everything.

Registering an endpoint

POST /webhooks
{
  "url": "https://yoursite.com/webhooks/benibrain",
  "events": "order.paid,order.refunded,booking.confirmed"
}

The endpoint must be a publicly reachable https:// URL — it's validated both at registration and again at every delivery (covering DNS rebinding and endpoints that later start resolving to a private address). The response includes a secret field, shown only once at creation — store it to verify signatures.PATCH /webhooks/{id} updates the URL/events/active state, POST /webhooks/{id}/test sends a test payload, and GET /webhooks/{id}/deliveries returns recent delivery attempts with status codes and errors, newest first (25 at a time by default, up to 50 with limit).

Payload & signing

Delivered body
{
  "eventId": "8e2f...",
  "eventType": "order.paid",
  "occurredAt": "2026-09-18T14:02:11.000Z",
  "businessId": "biz_1",
  "schemaVersion": "2026-09-02",
  "event": "order.paid",
  "timestamp": "2026-09-18T14:02:11.000Z",
  "data": { "orderId": "ord_456", "totalAmount": 29.0, "currency": "gbp" }
}

Every delivery carries these headers:

HeaderPurpose
X-BeniBrain-EventThe event type
X-BeniBrain-Event-IdStable ID for this delivery — use it for idempotency
X-BeniBrain-Signaturesha256=… — HMAC-SHA256 of the raw body using your webhook secret
Idempotency-KeySame value as X-BeniBrain-Event-Id
Verifying the signature (Node.js)
import crypto from "node:crypto";

function isValid(rawBody, signatureHeader, secret) {
  const expected = "sha256=" + crypto.createHmac("sha256", secret).update(rawBody).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signatureHeader));
}

Verify against the raw request body (before JSON parsing) and use eventId to de-duplicate — retries reuse the same ID rather than minting a new one.

Retries & reliability

A delivery is attempted once, then retried up to 3 times with exponential backoff (1s, 2s, 4s) if your endpoint doesn't return a 2xx within 10 seconds. Endpoints that repeatedly fail — or that stop resolving to a public, non-private address — are automatically disabled; check GET /webhooks/{id}/deliveries if events stop arriving.