Skip to content

Receive

Webhooks

Braidport POSTs every event to your endpoints, signed with the Standard Webhooks convention, so any off-the-shelf verifier works. Delivery is at least once, retried for about a day.

On this page

Endpoints#

Create endpoints in the dashboard (a workspace's Webhooks tab, or Developers for organization-level ones) or with the API:

POST/v1/webhook-endpointsscope admin

Create a webhook endpoint; the signing secret is returned once

FieldTypeDescription
urlURLrequired≤ 2,048 charsWhere events are POSTed. HTTPS; private and internal addresses are refused.
workspace_idws_ idoptionalThe workspace whose events the endpoint receives. Organization keys may omit it to receive every workspace's events.
descriptionstringoptional≤ 500 charsYour note.
events"message.received" | "message.sent" | "message.status" | "message.edited" | "message.deleted" | "channel.connected" | "channel.disconnected" | "channel.status_changed" | "template.status_changed" | "ping" | "*"[]optional≥ 1 items≤ 20 itemsdefault ["*"]Event types to receive, or ["*"] for all.
source"api" | "n8n"optionaldefault "api"Who manages the endpoint. The n8n node uses n8n.
is_activebooleanoptionaldefault trueCreate it paused with false.
  • A workspace endpoint receives the events of one workspace. An organization endpoint (no workspace_id, created with an organization key) receives the events of every workspace, so one URL serves all your clients. An event goes to every matching active endpoint.
  • The response includes secret once. It can be revealed and rotated later in the dashboard.
  • Endpoint URLs must be reachable from the internet: private, loopback and link-local addresses are refused, and redirects are not followed.
  • A workspace holds at most 5 endpoints and the organization level at most 10, disabled ones included. Above that, creating one, or moving one to another workspace or level, answers plan_limit_reached with details.resource: "webhook_endpoint"; send several event types to one endpoint instead.

Manage endpoints with GET, PATCH and DELETE /v1/webhook-endpoints/:id (scope admin).

The request#

Each delivery is a POST whose JSON body is one event (see Events), with these headers:

HeaderValue
webhook-idThe event id (evt_…), identical on every retry.
webhook-timestampUnix time in seconds of this attempt.
webhook-signaturev1,<base64 signature>; several space-separated entries are possible.
content-typeapplication/json
user-agentBraidport/1.0 (+https://braidport.com/docs/webhooks)

Answer with any 2xx within 10 seconds (5 seconds to connect). Any other status, a timeout or a connection error counts as a failure and is retried. Acknowledge first and do slow work (calling an LLM, booking) afterwards.

Verifying signatures#

The signature is an HMAC-SHA256 over <webhook-id>.<webhook-timestamp>.<body>, keyed with the endpoint secret: the bytes obtained by base64-decoding the part after whsec_. Compare in constant time and reject timestamps more than 5 minutes away from your clock, which stops replays.

Verify the raw body

The signature covers the exact bytes sent. A body parsed and re-serialized by a JSON middleware will not verify: read the raw body first, parse it after.
verify-braidport-webhook.jsjavascript
import { createHmac, timingSafeEqual } from "node:crypto"; const TOLERANCE_SECONDS = 300; /** * Verifies a Braidport webhook (Standard Webhooks) and returns the parsed event. * rawBody: the exact bytes received (string or Buffer), never a re-serialized object. * headers: lower-case header names, e.g. req.headers in Node.js. */export function verifyBraidportWebhook(rawBody, headers, secret, nowSeconds = Math.floor(Date.now() / 1000)) {  const id = headers["webhook-id"];  const timestamp = headers["webhook-timestamp"];  const signatures = headers["webhook-signature"];  if (!id || !timestamp || !signatures) throw new Error("missing webhook headers");  if (!/^\d+$/.test(timestamp) || Math.abs(nowSeconds - Number(timestamp)) > TOLERANCE_SECONDS) {    throw new Error("timestamp outside the tolerance");  }   const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");  const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(rawBody, "utf8");  const expected = createHmac("sha256", key)    .update(`${id}.${timestamp}.`)    .update(body)    .digest();   // The header may hold several space-separated signatures ("v1,<base64> v1,<base64>").  const valid = signatures.split(" ").some((entry) => {    const [version, value] = entry.split(",");    if (version !== "v1" || !value) return false;    const received = Buffer.from(value, "base64");    return received.length === expected.length && timingSafeEqual(received, expected);  });  if (!valid) throw new Error("invalid signature");   return JSON.parse(body.toString("utf8"));}

A complete receiver, with de-duplication:

server.jsjavascript
import http from "node:http";import { verifyBraidportWebhook } from "./verify-braidport-webhook.js"; const seen = new Set(); // use your database or Redis in production http  .createServer((req, res) => {    const chunks = [];    req.on("data", (chunk) => chunks.push(chunk));    req.on("end", () => {      let event;      try {        event = verifyBraidportWebhook(Buffer.concat(chunks), req.headers, process.env.BRAIDPORT_WEBHOOK_SECRET);      } catch {        res.writeHead(400).end();        return;      }      res.writeHead(204).end(); // answer first, work afterwards      if (seen.has(event.id)) return; // at-least-once delivery: de-duplicate on the event id      seen.add(event.id);      handle(event);    });  })  .listen(3000);

The official Standard Webhooks libraries (JavaScript, Python, Go, Ruby, PHP, Java, …) accept the whsec_ secret as it is.

At-least-once delivery#

An event can reach you more than once: after a timeout on a request you actually processed, after a redelivery, or when you test. Its id never changes, so record the ids you have handled and skip repeats. Keeping them for 24 hours is enough, because events are not delivered after that.

Retries mean a later event can arrive before an earlier one that is still being retried. Order by the event's timestamps, not by arrival.

When a reply depends on an event, send it with an Idempotency-Key derived from the event id (for example reply-evt_…). A second delivery then cannot produce a second message.

Retries and schedule#

A failed delivery is retried with these delays (each ±20 % jitter). After the last attempt the delivery is marked expired.

RetryDelayAbout this long after the first attempt
15 s5 s
215 s20 s
31 min1 min
45 min6 min
515 min21 min
61 h1 h 21 min
72 h3 h 21 min
84 h7 h 21 min
96 h13 h 21 min
108 h21 h 21 min

Every attempt appears in the workspace's Logs with its status code and duration. While an event is still stored (24 hours), you can send it again from the logs (Resend) or with the API:

POST/v1/events/:id/redeliverscope admin

Queue an event for delivery again while it is still stored

One delivery of an event to an endpoint is pending at a time. An endpoint whose delivery of the event is still retrying is skipped, and when that leaves nothing to send the answer is 409 conflict: redeliver once the logs show it delivered, failed, expired or dropped. A delivery we could not complete on our side is marked failed with internal_error and can be sent again the same way.

Failing endpoints#

  • Concurrency. At most 4 deliveries to one endpoint, and 8 for one organization, are in flight at a time, so a slow receiver does not hold up anyone else. The others wait their turn without using up a retry.
  • Circuit breaker. After 5 consecutive failures an endpoint is paused: its deliveries wait and one probe a minute checks whether it has recovered. The first success resumes normal delivery.
  • Backlog cap. With more than 5,000 deliveries waiting for one endpoint, new events for it are logged as dropped (backlog_full) and your organization is alerted.
  • Automatic disable. An endpoint with no successful delivery for 48 hours and at least 10 failed attempts is disabled and you are alerted. Endpoints created by the n8n node are disabled without an alert; n8n registers them again when the workflow is activated.
  • Unreadable signing secret. If the endpoint's signing secret can no longer be read on our side (for example after a restore), nothing is sent to it: its deliveries keep the usual retry schedule and show retrying with secret_unreadable in the logs (next to the HTTP status and duration of the last attempt that made a request, if one did), and a test event reports the same code. Once the secret can be read again (we restore it, or you rotate it and give the new one to your receiver), each delivery goes out at its next retry; one whose retries ran out first is marked expired. Resend expired events from the logs while they are stored (24 hours).

Re-enable a disabled endpoint with PATCH /v1/webhook-endpoints/:id and { "is_active": true }, or from the dashboard.

Testing an endpoint#

POST/v1/webhook-endpoints/:id/testscope admin

Send a signed ping event to the endpoint and report the result

Sends a signed ping event and reports what your endpoint answered:

FieldTypeDescription
event_idevt_ idId of the ping event that was sent.
successbooleanWhether your endpoint answered with a 2xx.
http_statusinteger | nullThe status your endpoint answered with, if any.
duration_msinteger | nullHow long the request took.
error_codestring | nullWhy it failed: timeout, connection_failed, http_status, blocked_target, …

To test real message flows, use the sandbox.