The sandbox records an event each time an account holder's verification status or a payment's status changes. When WEBHOOK_URL is set, it sends each event to that address as an HTTP POST, signed with the webhook secret. Your endpoint checks the signature, answers within 5 seconds, and handles each event once, however many times it arrives.
What Your Endpoint Receives#
This is the delivery the sandbox recorded for evt_0005, the event of the Quickstart's payment reaching BOOKED, with the headers the sandbox sets:
POST /webhooks HTTP/1.1
Content-Type: application/json
Brindlemark-Event-Id: evt_0005
Brindlemark-Timestamp: 1796115614
Brindlemark-Signature: v1=3e0671e516d6beaad4ae9837d9adba86386e01026a5e5e8b925d811ca9a45e8d
{"id":"evt_0005","type":"payment.status_changed","createdAt":"2026-12-01T09:00:14Z","data":{"paymentId":"pay_0001","previousStatus":"PENDING","status":"BOOKED"}}
| Header | What it holds |
|---|---|
Brindlemark-Event-Id |
The event's ID. Every delivery of the event carries the same one. |
Brindlemark-Timestamp |
When this delivery was sent, in seconds since 1970-01-01T00:00:00Z. |
Brindlemark-Signature |
v1= and the HMAC-SHA256, in hexadecimal, of the timestamp, a dot and the body, made with the webhook secret. |
The body is one line of JSON. Indented, it reads:
{
"id": "evt_0005",
"type": "payment.status_changed",
"createdAt": "2026-12-01T09:00:14Z",
"data": {
"paymentId": "pay_0001",
"previousStatus": "PENDING",
"status": "BOOKED"
}
}
| Field | What it holds |
|---|---|
id |
The event's ID, the same as Brindlemark-Event-Id. |
type |
What changed. See the table below. |
createdAt |
When the change happened, in UTC. |
data |
The ID of the object that changed, its previous status, and its new status. |
type |
Sent when | data |
|---|---|---|
account_ |
An account holder is onboarded (PENDING), and when its verification ends (VERIFIED or REFUSED). |
accountHolderId, previousStatus, status |
payment.status_changed |
A payment is initiated, and at each status after that. | paymentId, previousStatus, status, and rejectionReason when the status is REJECTED |
An event carries IDs and statuses, not the whole object. To act on it, read the object from the API: the answer is its state now.
Verify the Signature#
Anyone who finds your endpoint's address can post to it. The signature proves that a delivery comes from the sandbox and that nobody changed it on the way. Check it before you trust anything in the body:
- Read the body as raw bytes, before any JSON parsing.
- Make the HMAC-SHA256 of the
Brindlemark-Timestampvalue, a dot and the raw body, with your webhook secret. - Compare it with the hexadecimal digits of
Brindlemark-Signature, in constant time. - Check that the timestamp is within 300 seconds of your clock.
- If any check fails, answer HTTP 400 and do nothing else.
This is the function the example endpoint uses:
// Checks that a webhook delivery comes from the Brindlemark sandbox and is
// recent. The site's build runs this function against a delivery recorded
// from the sandbox, so the code on the Webhooks page is code that works.
import { createHmac, timingSafeEqual } from "node:crypto";
/** How far, in seconds, a delivery's timestamp may be from your clock. */
export const TOLERANCE_SECONDS = 300;
/**
* rawBody the body exactly as it arrived (a Buffer or a string),
* before any JSON parsing
* timestamp the Brindlemark-Timestamp header: seconds since 1970
* signature the Brindlemark-Signature header: v1= and 64 hex digits
* secret your webhook signing secret
* now your clock, in milliseconds
* Returns { ok: true }, or { ok: false, reason }.
*/
export function verifyWebhook({
rawBody, timestamp, signature, secret,
now = Date.now(), toleranceSeconds = TOLERANCE_SECONDS,
}) {
if (!/^\d{1,12}$/.test(String(timestamp ?? ""))) {
return { ok: false, reason: "The timestamp is missing or isn't a number." };
}
const sent = /^v1=([0-9a-f]{64})$/.exec(String(signature ?? ""));
if (!sent) {
return { ok: false, reason: "The signature is missing or malformed." };
}
// Sign what the sandbox signed: the timestamp, a dot and the raw body.
const expected = createHmac("sha256", secret)
.update(`${timestamp}.`)
.update(rawBody)
.digest();
// Compare in constant time: the time taken says nothing about how much
// of the signature matched.
if (!timingSafeEqual(expected, Buffer.from(sent[1], "hex"))) {
return { ok: false, reason: "The signature doesn't match." };
}
// A signed but old delivery may be a replay: refuse it outside the window.
if (Math.abs(now / 1000 - Number(timestamp)) > toleranceSeconds) {
return { ok: false, reason: "The timestamp is outside the window." };
}
return { ok: true };
}
The whole file: verify.mjs on GitHub.
- Why the raw bytes. Parsing the JSON and writing it again can change the bytes: the spaces, the order of the keys, the way a character is escaped. The signature covers the bytes as sent, so verify those.
- Why constant time. A comparison that stops at the first wrong character takes longer the more characters are right, and an attacker can measure that.
timingSafeEqualtakes the same time either way. - Why a tolerance window. A delivery someone recorded and posts again later still has a valid signature. Its timestamp is old, and the timestamp is part of what is signed, so it can't be changed without breaking the signature. Allow for clocks a little apart; keep your server's clock synchronized.
Answer Within 5 Seconds#
The sandbox waits 5 seconds for an answer. Any 2xx status is a success. Any other status, or no answer in time, is a failed delivery, which the sandbox sends again.
So answer first and work after: check the signature, record the event, answer 200, then do the slow work, such as updating your records or notifying a user, from your own queue.
Retries#
After a failed delivery, the sandbox tries again: 10 seconds after the first attempt, 60 seconds after the second and 300 seconds after the third, four attempts in all. Every attempt carries the same event ID and the same body, with a new timestamp and a new signature. Once one succeeds, the sandbox stops.
Here, the example endpoint is down for one delivery:
Example: Send a transfer while the endpoint is down
mutation Transfer($input: InitiateCreditTransferInput!) {
initiateCreditTransfer(input: $input) {
__typename
... on InitiateCreditTransferSuccess {
payment {
id status scheme
amount { value currency }
creditor { name iban }
account {
availableBalance { value }
bookedBalance { value }
}
}
}
... on Problem { message }
}
}
Variables:
{
"input": {
"accountId": "acc_0001",
"scheme": "SCT",
"amount": {
"value": "100.00",
"currency": "EUR"
},
"creditor": {
"name": "Example Flour Mill GmbH",
"iban": "DE89 3704 0044 0532 0130 00"
},
"reference": "Invoice 2026-121",
"idempotencyKey": "f05b9c27-8d1e-4a63-b4f0-2e7c6a9d1b38"
}
}
Sent while the example endpoint answers HTTP 500 to the next delivery, as an endpoint that is down would.
Response, HTTP 200:
{
"data": {
"initiateCreditTransfer": {
"__typename": "InitiateCreditTransferSuccess",
"payment": {
"id": "pay_0003",
"status": "INITIATED",
"scheme": "SCT",
"amount": {
"value": "100.00",
"currency": "EUR"
},
"creditor": {
"name": "Example Flour Mill GmbH",
"iban": "DE89370400440532013000"
},
"account": {
"availableBalance": {
"value": "3650.00"
},
"bookedBalance": {
"value": "3750.00"
}
}
}
}
}
}
The event's first delivery failed, and the sandbox has scheduled the next:
Example: Read the event after the failed delivery
query Event($resourceId: ID!) {
webhookEvents(resourceId: $resourceId) {
id nextRetryAt
deliveries { attempt reason sentAt responseStatus }
}
}
Variables:
{
"resourceId": "pay_0003"
}
Response, HTTP 200:
{
"data": {
"webhookEvents": [
{
"id": "evt_0009",
"nextRetryAt": "2026-12-01T09:00:35Z",
"deliveries": [
{
"attempt": 1,
"reason": "FIRST",
"sentAt": "2026-12-01T09:00:25Z",
"responseStatus": 500
}
]
}
]
}
}
Ten seconds later:
Example: Read the event after the retry
query Event($resourceId: ID!) {
webhookEvents(resourceId: $resourceId) {
id nextRetryAt
deliveries {
attempt reason sentAt responseStatus
headers { name value }
}
}
}
Variables:
{
"resourceId": "pay_0003"
}
Sent 9 seconds after the request before it, on the sandbox's clock.
Response, HTTP 200:
{
"data": {
"webhookEvents": [
{
"id": "evt_0009",
"nextRetryAt": null,
"deliveries": [
{
"attempt": 1,
"reason": "FIRST",
"sentAt": "2026-12-01T09:00:25Z",
"responseStatus": 500,
"headers": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Brindlemark-Event-Id",
"value": "evt_0009"
},
{
"name": "Brindlemark-Timestamp",
"value": "1796115625"
},
{
"name": "Brindlemark-Signature",
"value": "v1=6c9517ec5aa218c1a5f86bc3fe3d3d112b1c5b3e36578e049c98632910a22a43"
}
]
},
{
"attempt": 2,
"reason": "RETRY",
"sentAt": "2026-12-01T09:00:35Z",
"responseStatus": 200,
"headers": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Brindlemark-Event-Id",
"value": "evt_0009"
},
{
"name": "Brindlemark-Timestamp",
"value": "1796115635"
},
{
"name": "Brindlemark-Signature",
"value": "v1=8e68c0d267a4a913e0df936262b49476babe9d0e5c036555354f93245b048ab5"
}
]
}
]
}
]
}
}
The two deliveries share evt_0009 and the body. Their timestamps differ, so their signatures do too.
Duplicates and Order#
Delivery is at least once. An event can arrive twice: when your endpoint did the work but answered too late, the sandbox sends it again; and you can ask for any event again:
Example: Send an event again
mutation Resend($input: SandboxResendWebhookEventInput!) {
sandboxResendWebhookEvent(input: $input) {
__typename
... on SandboxResendWebhookEventSuccess {
event {
id
deliveries { attempt reason sentAt responseStatus }
}
}
... on Problem { message }
}
}
Variables:
{
"input": {
"eventId": "evt_0005"
}
}
Response, HTTP 200:
{
"data": {
"sandboxResendWebhookEvent": {
"__typename": "SandboxResendWebhookEventSuccess",
"event": {
"id": "evt_0005",
"deliveries": [
{
"attempt": 1,
"reason": "FIRST",
"sentAt": "2026-12-01T09:00:14Z",
"responseStatus": 200
},
{
"attempt": 2,
"reason": "RESEND",
"sentAt": "2026-12-01T09:00:36Z",
"responseStatus": 200
}
]
}
}
}
}
Handle each event once. Keep the IDs of the events you have accepted, and when an ID comes back, answer 200 without doing the work again. The example endpoint keeps them in memory. A live endpoint keeps them in a database table with a unique key, so that two deliveries arriving at the same moment can't both get through.
Don't rely on the order of arrival either. Deliveries don't wait for each other: when a payment is settled, its PENDING and BOOKED events are sent at the same moment and can arrive in either order, and a retried event arrives after events that happened later. To know a payment's status, compare the events' createdAt, or read the payment from the API.
A Complete Endpoint#
The example endpoint puts the above together: it verifies, deduplicates, answers, then hands the event to your code.
// A webhook endpoint for the Brindlemark sandbox: it verifies each delivery,
// answers at once, and handles each event once, however many times it
// arrives. The site's build runs it against the sandbox's real deliveries.
//
// node content/work/banking/receiver.mjs
//
// It listens at http://localhost:3000/webhooks. Environment: PORT (3000) and
// WEBHOOK_SECRET, the same secret the sandbox signs with.
import http from "node:http";
import { fileURLToPath } from "node:url";
import { verifyWebhook } from "./verify.mjs";
/** An HTTP handler. `handle(event)` does the work, after the answer. */
export function createReceiver({ secret, handle, now = () => Date.now() }) {
// The IDs of the events already accepted. In production: a table with a
// unique key, so two deliveries at the same moment can't both pass.
const seen = new Set();
return (req, res) => {
if (req.method !== "POST" || req.url !== "/webhooks") {
res.writeHead(404).end();
return;
}
const chunks = [];
req.on("data", (chunk) => chunks.push(chunk));
req.on("end", () => {
// Verify these bytes, not a parsed and re-serialized copy.
const rawBody = Buffer.concat(chunks);
const check = verifyWebhook({
rawBody,
timestamp: req.headers["brindlemark-timestamp"],
signature: req.headers["brindlemark-signature"],
secret,
now: now(),
});
if (!check.ok) {
res.writeHead(400, { "Content-Type": "text/plain" }).end(check.reason);
return;
}
const event = JSON.parse(rawBody);
if (seen.has(event.id)) {
res.writeHead(200).end(); // a retry or a resend: already accepted
return;
}
seen.add(event.id);
res.writeHead(200).end(); // answer now; slow work comes after
setImmediate(() => handle(event));
});
};
}
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const port = Number(process.env.PORT || 3000);
const receiver = createReceiver({
secret: process.env.WEBHOOK_SECRET || "sandbox-webhook-secret",
handle: (e) => console.log(e.id, e.type, JSON.stringify(e.data)),
});
http.createServer(receiver).listen(port, () => {
console.log(`Webhook receiver at http://localhost:${port}/webhooks`);
});
}
The whole file: receiver.mjs on GitHub.
Run it with node content/work/banking/receiver.mjs, and start the sandbox with WEBHOOK_URL=http://localhost:3000/webhooks. If you change the secret, set the same WEBHOOK_SECRET for both.
How the Build Tests This Code#
The code on this page is the code that runs. On each build of this site, scripts/banking-examples.mjs starts the sandbox with the example endpoint on a real port, sends every example of these pages, then checks:
- The recorded delivery passes verifyWebhook 30 seconds after it was sent.
- The same delivery with one character of the body changed fails: the signature doesn't match.
- The same delivery checked with another secret fails.
- The same delivery received 301 seconds after it was sent fails: it is outside the tolerance window.
- A signature with a hexadecimal digit missing fails before any comparison.
- The example endpoint handled each of the 9 events once: one reached it only on its retry, and one reached it again on request and wasn't handled twice.
- The endpoint failed once, as the retry example asks, and the sandbox tried again.
- The recorded delivery with one character of its body changed, posted to the example endpoint, is refused with HTTP 400.
- The same delivery posted again, unchanged, over an hour after it was sent is refused with HTTP 400: a replay outside the window.
- The retry came 10 seconds after the failed delivery.
- An access token stops working 3,600 seconds after it is issued.
If one of these fails, the build stops.