---
title: "Webhooks for developers | TheBusinessApp"
description: "Signed webhooks from TheBusinessApp: events, payloads, HMAC-SHA256 signatures, retries, delivery logs and verify code for Node, Python and PHP."
url: https://thebusinessapp.co.uk/developers/webhooks
---

# Webhooks: hear about it as it happens.

Tell us a URL and the events you care about. When a quote is accepted, a job is done or an invoice is paid, we POST signed JSON to you within a minute, and keep trying if you’re down.

## Setting up

In the app go to **Settings → Developers → Webhooks** and add an endpoint. It must be a public `https://` URL. Pick the events to receive, or *All events* to include ones we add later. You’ll see a signing secret starting `whsec_`; you can reveal or rotate it later.

Use **Send test event** to fire a `ping` at your receiver. Each endpoint has a delivery log showing every attempt, the response code and time taken, and the payload, with a **Resend** button.

Reply with any `2xx` status within 10 seconds to acknowledge a delivery. Do slow work after replying. Redirects are not followed.

## Events

Events are recorded by the database itself, so they fire whichever way a change was made: in the app, the field app, the customer portal, a booking page, an automation or the API.

| Event | When it fires |
| --- | --- |
| customer.created | A customer was added, from the app, portal, a booking or the API. |
| customer.updated | Any detail on a customer changed. |
| enquiry.created | A new lead arrived: website form, booking, inbound email or the API. |
| quote.sent | A quote was sent to the customer. |
| quote.accepted | The customer accepted and signed a quote. |
| quote.declined | The customer declined a quote. |
| job.created | A job was created. |
| job.updated | A job changed: status, schedule, assignee or details. |
| job.completed | A job was marked done. |
| invoice.created | An invoice was created, usually as a draft. |
| invoice.sent | An invoice was sent to the customer. |
| invoice.paid | An invoice was paid in full. |
| invoice.overdue | A sent invoice passed its due date unpaid. Sent once per invoice. |
| payment.received | A payment was recorded against an invoice. |
| booking.created | A customer booked online. |
| survey.responded | A customer answered a satisfaction survey. |

## Payload

Every delivery is an `event` envelope. `data.object` is the record in the same shape the REST API returns, captured when the event is first delivered. Retries and resends carry the same `id`, so use it to ignore duplicates.

example delivery

```
POST /webhooks/thebusinessapp HTTP/1.1
Content-Type: application/json
webhook-id: evt_3911095004dfa4d0ba885102a83057519
webhook-timestamp: 1792249801
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
TBA-Event-Type: invoice.paid
TBA-Delivery-Id: 2f1c0b9e-…
TBA-Delivery-Attempt: 1

{
  "id": "evt_3911095004dfa4d0ba885102a83057519",
  "object": "event",
  "type": "invoice.paid",
  "api_version": "2026-10-17",
  "created_at": "2026-10-17T14:35:02Z",
  "data": {
    "object": {
      "id": "55613e31-d939-483a-8b84-6345408641d7",
      "object": "invoice",
      "number": "INV-0018",
      "status": "paid",
      "total": 114,
      "amount_paid": 114,
      "customer_id": "6e48692e-69f2-4d1c-86f9-8047000df7e2"
    }
  }
}
```

## Verifying signatures

We sign with the [Standard Webhooks](https://www.standardwebhooks.com/) scheme. Work out HMAC-SHA256 over `{webhook-id}.{webhook-timestamp}.{raw body}`, keyed with the base64-decoded part of your secret after `whsec_`, then base64 it. It must match one of the space-separated `v1,…` values in `webhook-signature`. Reject timestamps more than five minutes old to stop replays, and always compare in constant time.

node.js (express)

```
import crypto from 'node:crypto'
import express from 'express'

const SECRET = process.env.TBA_WEBHOOK_SECRET // whsec_…
const app = express()

// Keep the raw body: the signature covers the exact bytes we sent.
app.post('/webhooks/thebusinessapp', express.raw({ type: 'application/json' }), (req, res) => {
  const id = req.header('webhook-id')
  const ts = req.header('webhook-timestamp')
  const sigs = (req.header('webhook-signature') || '').split(' ')

  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return res.status(400).send('stale')

  const key = Buffer.from(SECRET.replace(/^whsec_/, ''), 'base64')
  const expected = crypto.createHmac('sha256', key).update(`${id}.${ts}.${req.body}`).digest('base64')
  const ok = sigs.some((s) => {
    const [, v] = s.split(',')
    return v && v.length === expected.length && crypto.timingSafeEqual(Buffer.from(v), Buffer.from(expected))
  })
  if (!ok) return res.status(401).send('bad signature')

  const event = JSON.parse(req.body)
  // Dedupe on event.id: you may receive the same event more than once.
  console.log(event.type, event.data.object.id)
  res.sendStatus(200)
})
```

python (flask)

```
import base64, hashlib, hmac, json, os, time
from flask import Flask, request, abort

SECRET = os.environ["TBA_WEBHOOK_SECRET"]  # whsec_…
app = Flask(__name__)

@app.post("/webhooks/thebusinessapp")
def receive():
    msg_id = request.headers["webhook-id"]
    ts = request.headers["webhook-timestamp"]
    body = request.get_data()  # raw bytes
    if abs(time.time() - int(ts)) > 300:
        abort(400)
    key = base64.b64decode(SECRET.removeprefix("whsec_"))
    expected = base64.b64encode(hmac.new(key, f"{msg_id}.{ts}.".encode() + body, hashlib.sha256).digest()).decode()
    sigs = [s.split(",", 1)[1] for s in request.headers["webhook-signature"].split() if "," in s]
    if not any(hmac.compare_digest(s, expected) for s in sigs):
        abort(401)
    event = json.loads(body)
    print(event["type"], event["data"]["object"]["id"])
    return "", 200
```

php

```
<?php
$secret = getenv('TBA_WEBHOOK_SECRET'); // whsec_…
$body = file_get_contents('php://input');
$id = $_SERVER['HTTP_WEBHOOK_ID'];
$ts = $_SERVER['HTTP_WEBHOOK_TIMESTAMP'];
if (abs(time() - (int) $ts) > 300) { http_response_code(400); exit; }

$key = base64_decode(preg_replace('/^whsec_/', '', $secret));
$expected = base64_encode(hash_hmac('sha256', "$id.$ts.$body", $key, true));
$ok = false;
foreach (explode(' ', $_SERVER['HTTP_WEBHOOK_SIGNATURE']) as $sig) {
  $parts = explode(',', $sig, 2);
  if (isset($parts[1]) && hash_equals($expected, $parts[1])) { $ok = true; }
}
if (!$ok) { http_response_code(401); exit; }

$event = json_decode($body, true);
http_response_code(200);
```

standard webhooks library

```
// Or use any Standard Webhooks library, e.g. npm i standardwebhooks
import { Webhook } from 'standardwebhooks'
const wh = new Webhook(process.env.TBA_WEBHOOK_SECRET.replace(/^whsec_/, ''))
const event = wh.verify(rawBody, {
  'webhook-id': req.header('webhook-id'),
  'webhook-timestamp': req.header('webhook-timestamp'),
  'webhook-signature': req.header('webhook-signature'),
})
```

### Rotating the secret

Rotate from the endpoint screen. For the next 24 hours each delivery is signed with both the new and the old secret, so `webhook-signature` carries two values. Deploy the new secret to your receiver within that window.

## Retries and failures

Anything other than a `2xx`, including timeouts, counts as a failure. We retry after:

- Retry 11 minute
- Retry 25 minutes
- Retry 330 minutes
- Retry 42 hours
- Retry 56 hours
- Retry 612 hours
- Retry 724 hours
- Retry 824 hours

That is nine attempts over about three days, with a little random jitter. After that the delivery is marked failed; you can resend it from the log at any time.

If an endpoint fails 20 attempts in a row, or answers `410 Gone`, we switch it off and show why on the endpoint. Fix your receiver and switch it back on; the failure count resets.

Events can arrive out of order and, rarely, more than once. Use `created_at` and the event `id`, or fetch the latest record from the API when order matters.

## Plug your business app into everything else.

14 days free, no card. Bring your customers and price list across from a CSV, switch on what you need, and invite the team when you’re ready.

[Start free trial](https://app.thebusinessapp.co.uk/signup?utm_source=marketing&utm_medium=web&utm_campaign=start-free&utm_content=webhooks-foot) [See pricing](https://thebusinessapp.co.uk/pricing)

No card. Monthly, no contract. Cancel any time and take your data with you.
