Skip to content

Webhooks

Receive real-time delivery events at your own endpoints.

Endpoint URLEventsSigning secretRow actions
Showing 0–0 of 0

Verify webhook signatures

Every delivery includes a BAAP-Signature header.

Compute an HMAC-SHA256 of the timestamp and raw request body with your signing secret, compare it in constant time and reject requests older than five minutes.

verify.js
import crypto from "node:crypto";

export function verifyBaapSignature(rawBody, header, secret) {
  // header format: t=1732093200,v1=<hex hmac>
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const expected = crypto
    .createHmac("sha256", secret)
    .update(`${parts.t}.${rawBody}`)
    .digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
  return fresh && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}