Baack

Getting started with webhooks

Browse the docs
Developer

A webhook is an HTTP request one system sends to another the moment something happens, so the receiver doesn't have to keep asking an API whether anything has changed. Baack sends one when a record you subscribe to is created, updated or deleted: a short JSON message saying what happened, signed so your endpoint can check it came from Baack.

Webhooks at Baack provide a robust, event-driven mechanism to move from a "pull" model to real-time integrations. With over 80% of the API surface covered, webhooks allow your application to receive instant updates whenever data changes on the platform.

API Client Creation

Before setting up webhooks, you must have a valid API Client and a Bearer Token if you intend to use Bearer authentication for your administrative requests to the Baack API.

  • Sign Up/Log In: Access the Baack developer portal.
  • Create a webhook client: Navigate to the "API Clients" section of your dashboard and select "New API client".
  • Scope: Ensure your client is provisioned with the correct scope, typically webhook.baack.co. Only clients scoped to the webhooks sub-domain can subscribe to events. This restriction prevents webhook clients from accessing general api scopes.
  • Authorization: Select full read access for your webhook client, or manually grant fine-grained permissions for specific subjects.
  • Client Identifier: For Basic authentication, set the client ID to the expected username. For Bearer authentication, the client ID is ignored in favor of the token.

Webhook Subscription Setup

Baack supports fine-grained subscriptions, allowing you to "listen" only to the specific events your product requires.

Subscription Parameters

Subscriptions can be configured for individual subjects (e.g., a specific message thread) with the following event types:

  • Create: Triggered when a new resource is generated.
  • Update: Triggered when an existing resource is modified.
  • Delete: Triggered when a resource is removed.
  • All: A catch-all for all lifecycle events of the subject.

To manage these, use the Webhook Subscription endpoint.

  • Create a subscription: In the "Webhooks" dashboard, select "New Webhook Subscription".
  • Select Client: Choose the appropriate client from your provisioned list.
  • Subject: Select the webhook subject e.g. Entity to receive updates about content entity changes.
  • Event Type: Select the specific event type. Choosing "ALL" captures the full resource lifecycle.
  • Destination URL: Provide the endpoint URL that will receive the JSON webhook events.
  • Subscription end time: All subscriptions are for up to 90 days. They can be renewed via the subscription API.
  • Authentication: Select the authentication method the Baack service should use when calling your endpoint.
  • Webhook Secret: Define a secret token for HMAC-SHA256 signatures and chosen authentication mechanisms.
  • Rate Limiting: Define the maximum delivery attempts per minute to prevent overwhelming your infrastructure.

Webhook Authentication

Baack offers flexible, standards-based authentication mechanisms to ensure that delivery to your integration is secure and compatible with your existing infrastructure.

Authentication Method Description
HTTP BASIC Uses the API Client ID as the username and the Subscription Secret as the password.
BEARER Standard token-based authentication using the Bearer token associated with the API Client.
mTLS Mutual TLS for high-security environments; available on request, as support needs to set up the keys.
HMAC-SHA256 Signature-only verification. The signature is calculated as: HMAC-SHA256(payload, secret) payload = body + timestamp + idempotencyKey

Note: the signature is always provided.

Webhook Payload and Delivery

The delivery mechanism prioritizes speed and reliability through a "fast-then-slow" retry strategy. Initial delivery attempts are rate-limited based on your subscription's events-per-minute configuration.

Integrations should use the Idempotency-Key header (the trigger URN) to detect duplicates. For versioned resources, the vectorClock field should be used to ensure updates are processed in the correct order.

Delivery Characteristics

  • Latency: The first attempt usually starts within a second or two of the update being committed to the platform: in our tests, deliveries arrived 0.2 to 1.6 seconds after the change. Each change is matched against your company's subscriptions in turn, so a company with many subscriptions takes a little longer, and connecting to your endpoint, including its TLS handshake, adds to it. Retries are increasingly delayed to allow infrastructure to recover from outages.
  • Retries: If delivery fails in a retryable way, Baack utilizes a "back-off" approach, attempting delivery over a 24-hour period before stopping the subscription.
  • Payload Inspection: Deliveries include the original trigger, allowing you to inspect the exact event that caused the webhook.
  • Rate Limiting: Throttling can be configured at the subscription level. The platform supports up to 6,000 deliveries per minute by default.

The payload is intended to be as simple as possible to allow an integration to determine how to route the update. Webhook event messages do not provide the content of the representation for security reasons.

Failed deliveries due to timeouts (HTTP 408, 418) or server errors (HTTP 429, 503, 504) are retried with exponential back-off for up to 24 hours: 10 attempts in all, numbered in the X-Attempt-Number header (from 0) and counted down in X-Attempts-Remaining. In our tests, an endpoint answering 503 was tried again about 20 to 30 seconds later, then about 35 seconds after that.

A failure that can't be retried expires the subscription immediately, and so do retries that all fail. Please verify that the endpoint is functional before re-enabling the subscription as delivery attempts count against your billable requests.

Webhook Verification

To ensure the integrity and authenticity of the data received, every webhook includes security headers to prevent spoofing and replay attacks.

  • HMAC-SHA256 Signature: Every delivery has a Signature header, allowing you to verify that the message was sent by Baack and has not been tampered with. Signed-Headers lists what it covers, in order: the body, then Last-Modified, then Idempotency-Key. See the worked example below.
  • Timestamps: Last-Modified is the trigger's time, in UTC with no zone, and it's signed. It stays the same on every attempt, so if you reject old deliveries, allow at least the 24 hours of retries.
  • Idempotency Keys: We recommend building your integration to handle replays based on the provided idempotency keys or representation versions, which facilitates easy debugging and recovery from outages.

The headers on every delivery

Each delivery is an HTTP POST with a JSON body. Every header it carries:

Header Example What it is
Content-Type application/json; charset=UTF-8 The body is JSON, in UTF-8.
Content-Length 540 The body's length in bytes.
Host hooks.example.com Your endpoint's host, from the destination URL.
Connection keep-alive Set by the HTTP client.
Authorization Signature, Basic ... or Bearer ... Depends on the subscription's authentication: see below.
Idempotency-Key ea8c1fed-af5d-44f1-a04a-de4f0a52ee97 The trigger's URN: the same on every attempt at one event.
Last-Modified 2026-10-29T12:31:43.829 The trigger's time, in UTC with no zone: the same on every attempt.
Signature Bhx8JSduGUpGY3mTm4neLVmg+Y4nrdNo/UkeGsdFBhw= Base64 HMAC-SHA256 of the delivery, with the subscription's secret. Always sent.
Signed-Headers body,last-modified,idempotency-key What the signature covers, in order.
X-Attempt-Number 0 This attempt, counting from 0.
X-Attempts-Remaining 9 Attempts left after this one: 10 in all.

Authenticating deliveries

Every delivery is signed, whichever authentication the subscription uses, so checking the signature is enough to know it came from Baack. A subscription can also present credentials in the Authorization header, for endpoints behind infrastructure that expects them:

  • Bearer (Authorization: Bearer ...), recommended: your webhook API client's bearer token, as well as the signature. The token expires and can be replaced, so it's the strongest of the options.
  • Basic (Authorization: Basic ...): your API client's ID as the username and the subscription's secret as the password, as well as the signature.
  • HMAC-SHA256 (Authorization: Signature): the signature alone.
  • Mutual TLS: available on request, as support needs to set up the keys.

Setting up Bearer authentication

Baack sends the bearer token that belongs to the subscription's API client, so the client needs one before its first delivery:

  1. Create a bearer token for your webhook API client, with an expiry date, on the Bearer token endpoint (POST /n/v1/bearertoken/ with apiClient and expirationTimestamp).
  2. Keep the token: it's shown when it's created and never again. Store it with your endpoint's other secrets, so the endpoint can check it.
  3. Renew it before it expires: create the next token while the current one is still valid, and accept both until the old one has expired.

Without a bearer token, Baack doesn't send the delivery: it records BEARER_UNAVAILABLE in the delivery log, which you can see on the webhook trigger.

Checking the signature

Compute an HMAC-SHA256 with your subscription's secret over the raw body, then the Last-Modified value, then the Idempotency-Key value, joined with nothing between them, and compare its Base64 with the Signature header. In TypeScript, with no dependencies:

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

/**
 * Whether a Baack webhook delivery is genuine: its Signature header, a Base64 HMAC-SHA256 with the subscription's
 * secret over the raw body, then the Last-Modified header (the trigger's timestamp), then the Idempotency-Key header
 * (the trigger's URN). Check it on the body exactly as received, before parsing it.
 */
export function verifyBaackWebhook(rawBody: string, headers: Headers, secret: string): boolean {
  if (headers.get("signed-headers") !== "body,last-modified,idempotency-key") return false
  const signed = rawBody + (headers.get("last-modified") ?? "") + (headers.get("idempotency-key") ?? "")
  const expected = createHmac("sha256", secret).update(signed).digest()
  const received = Buffer.from(headers.get("signature") ?? "", "base64")
  return received.length === expected.length && timingSafeEqual(received, expected)
}

Checking Basic or Bearer credentials

Compare the Authorization header with what you expect, in constant time, as well as checking the signature:

import { timingSafeEqual } from "node:crypto"

/** Compares two strings in constant time, so timing doesn't reveal how much of a credential matched. */
function same(a: string, b: string): boolean {
  const left = Buffer.from(a)
  const right = Buffer.from(b)
  return left.length === right.length && timingSafeEqual(left, right)
}

/** Basic: the Authorization header holds your API client's ID and the subscription's secret. */
export function verifyBasicAuth(headers: Headers, clientId: string, secret: string): boolean {
  return same(headers.get("authorization") ?? "", `Basic ${Buffer.from(`${clientId}:${secret}`).toString("base64")}`)
}

/** Bearer: the Authorization header holds the bearer token you expect. */
export function verifyBearerAuth(headers: Headers, token: string): boolean {
  return same(headers.get("authorization") ?? "", `Bearer ${token}`)
}

Using the TypeScript client

The Baack TypeScript client (0.0.8 and later) does all of this in one call. verifyWebhook checks the signature and, when you pass bearer or basic, the Authorization header, then returns the parsed delivery; it throws a WebhookVerificationError saying why when a check fails. It uses Web Crypto only, so it also runs on Cloudflare Workers, Deno and Bun:

import { verifyWebhook } from "@baack-software/baack-ts-client"

const delivery = await verifyWebhook({ body: await request.text(), headers: request.headers, secret, bearer })

A real delivery

This is a delivery Baack sent to a test endpoint when a content entity was created, with the headers above. The body, laid out here for reading (it arrives on one line, and it's those exact bytes that are signed):

{
  "trigger": {
    "urn": "ea8c1fed-af5d-44f1-a04a-de4f0a52ee97",
    "owner": { "urn": "2ad747ab-51a9-11f0-b99c-d8bbc160a611", "url": "/n/v1/company/2ad747ab-51a9-11f0-b99c-d8bbc160a611" },
    "timestamp": "2026-10-29T12:31:43.829",
    "event": "CREATE",
    "subject": "ENTITY",
    "targetUrn": "72e85ece-3685-4fea-80b0-860ed5a80372"
  },
  "subscription": { "urn": "4fb15466-84a6-4026-81c4-7453ab482a47", "url": "/n/v1/webhooksubscription/4fb15466-84a6-4026-81c4-7453ab482a47" },
  "v1": { "urn": "72e85ece-3685-4fea-80b0-860ed5a80372", "url": "/n/v1/entity/72e85ece-3685-4fea-80b0-860ed5a80372" }
}

The trigger says what happened (CREATE), to what (ENTITY) and when; v1 links to the record. The record's content isn't included: read it from the API with your own client's permissions.

We ran the code above against every delivery from our tests, HMAC-SHA256, Basic and Bearer: each one verified with its subscription's secret and credentials, and none did with a wrong secret, wrong credentials or a changed body. Then:

  • Verify before parsing: check the body exactly as received. Parsed and re-serialized JSON won't match.
  • Answer quickly: reply with a 2xx as soon as the delivery is verified and recorded, and do the work afterwards, so a slow job isn't taken for a failure and retried.
  • Deduplicate: keep each Idempotency-Key you've handled, and skip a delivery you've seen before: a retry carries the same key.

For assistance with integration testing or to request mTLS setup, please contact support@baack.co.