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:
/v1/webhook-endpointsscope adminCreate a webhook endpoint; the signing secret is returned once
| Field | Type | Description |
|---|---|---|
url | URL | required≤ 2,048 charsWhere events are POSTed. HTTPS; private and internal addresses are refused. |
workspace_id | ws_ id | optionalThe workspace whose events the endpoint receives. Organization keys may omit it to receive every workspace's events. |
description | string | optional≤ 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_active | boolean | optionaldefault 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
secretonce. 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_reachedwithdetails.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:
| Header | Value |
|---|---|
webhook-id | The event id (evt_…), identical on every retry. |
webhook-timestamp | Unix time in seconds of this attempt. |
webhook-signature | v1,<base64 signature>; several space-separated entries are possible. |
content-type | application/json |
user-agent | Braidport/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.
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:
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.
| Retry | Delay | About this long after the first attempt |
|---|---|---|
| 1 | 5 s | 5 s |
| 2 | 15 s | 20 s |
| 3 | 1 min | 1 min |
| 4 | 5 min | 6 min |
| 5 | 15 min | 21 min |
| 6 | 1 h | 1 h 21 min |
| 7 | 2 h | 3 h 21 min |
| 8 | 4 h | 7 h 21 min |
| 9 | 6 h | 13 h 21 min |
| 10 | 8 h | 21 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:
/v1/events/:id/redeliverscope adminQueue 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
retryingwithsecret_unreadablein 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 markedexpired. 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#
/v1/webhook-endpoints/:id/testscope adminSend a signed ping event to the endpoint and report the result
Sends a signed ping event and reports what your endpoint answered:
| Field | Type | Description |
|---|---|---|
event_id | evt_ id | Id of the ping event that was sent. |
success | boolean | Whether your endpoint answered with a 2xx. |
http_status | integer | null | The status your endpoint answered with, if any. |
duration_ms | integer | null | How long the request took. |
error_code | string | null | Why it failed: timeout, connection_failed, http_status, blocked_target, … |
To test real message flows, use the sandbox.