> ## Documentation Index
> Fetch the complete documentation index at: https://developers.scoutworks.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Have Scoutworks tell your own tools the moment something happens: set up an endpoint, check each message is really from us, and handle every event once.

The API answers when you ask. A **webhook** works the other way round: when something happens in your group, Scoutworks sends a short message to an address you choose, straight away. Use it to post to Teams when a Direct Debit fails, or to update a spreadsheet when an event changes, without checking every few minutes.

> [!NOTE]
>
> Webhooks are in the beta programme. A group admin turns the programme on in **Settings → Advanced → Beta programme**, then **Webhooks** appears in **Settings → Integrations**.

## Set up an endpoint

You need an address that can receive a message: a Power Automate flow, a Zapier or n8n hook, or your own server. It must start with `https://` and use a public domain name.

**1. Add the webhook**

A group admin opens **Settings → Integrations → Webhooks** and chooses **Add webhook**. Paste the address, add a description so the next admin knows what it is for, and tick the **Events to send**.

**2. Copy the signing secret**

Choose **Add webhook**. Scoutworks shows the **Signing secret**, which starts `whsec_`. Copy it now and keep it with the receiver: it is not shown again. The receiver uses it to [check each message](#check-the-signature).

**3. Send a test**

On the webhook's menu, choose **Deliveries and test…**, then **Send test event**. A `webhook.test` message arrives within a few seconds, and the list shows whether your receiver answered.

A group can have up to ten webhooks. Each one belongs to the admin who added it. If they stop being a group admin, it stops sending and shows **Stopped working**: delete it and add it again.

Building a tool that many groups connect? It can add its own endpoint with the group’s API key, with `webhooks:write`: see [An integration that sets up its own webhooks](https://developers.scoutworks.app/recipes/webhooks-for-your-tool.md).

### Look after it later

From the webhook's menu:

* **Deliveries and test…** lists the latest messages, each with the answer your receiver gave. **Resend** sends one again, with the same `webhook-id`, so a receiver that [handles each event once](#handle-each-event-once) ignores it if it already has it.
* **New signing secret…** makes a new secret. The old one keeps working for 24 hours, so you have time to update the receiver. During that time each message carries both signatures.
* **Switch off** stops sending without losing the settings. **Delete…** removes it.

While tries are failing, a webhook shows **Failing**. If every try fails for 5 days, Scoutworks switches it off, and it shows **Switched off**. Fix the receiver, then choose **Switch on**.

## What we send

Each message is a `POST` with a JSON body and three headers. It follows the [Standard Webhooks](https://www.standardwebhooks.com) specification.

```http theme={null}
POST /your/address HTTP/1.1
content-type: application/json
webhook-id: 6f1c2a9e-3b7d-4c41-9a65-2f0e8d1b7c34
webhook-timestamp: 1795254781
webhook-signature: v1,efcz1xwU2vw0VyhpDPtX14Dvt9D2KtanC6xLJEKJ0ME=

{
  "type": "payment.failed",
  "timestamp": "2026-11-21T09:13:01.000Z",
  "data": {
    "paymentId": "1d0b6c52-8f4e-4b7a-9d3c-5e2a1f6b8c90",
    "status": "failed",
    "amountPence": 2500,
    "currency": "GBP",
    "chargeDate": "2026-11-20T00:00:00.000Z",
    "subscriptionId": null,
    "paymentRequestId": "8a7e5c3b-2d1f-4e6a-b9c8-7f6e5d4c3b2a",
    "parentId": "c4b3a2f1-0e9d-4c8b-a7f6-e5d4c3b2a1f0"
  }
}
```

* **`webhook-id`** is the same every time this message is sent: on a retry, and on a **Resend**.
* **`webhook-timestamp`** is when this try was sent, in seconds since 1970.
* **`type`** is the event, and **`timestamp`** is when it happened.
* **`data`** holds ids and plain facts only, never a name, an email or free text. To learn more, read the record from the API with a key: the ids match the API's. So a webhook address that leaks can never leak more than "something happened".

Answer with any `2xx` status within 10 seconds. Anything else, a redirect included, is a failed try, and we try again later.

## Events

| Event | Sent when | Read more with |
| - | - | - |
| `member.created` | A member was added to the group: by a leader, off the waiting list, or by an import. Not yet sent when a member is shared with your group or transferred in. | `members:read` |
| `member.updated` | A member's record was changed. `changedFields` names what changed. | `members:read` |
| `member.left` | A member left the group: archived, removed or moved back to the waiting list. Not yet sent for a transfer out or a merge of duplicate records. | `members:read` |
| `member.section.transitioned` | A member moved to a different section. | `members:read` |
| `waiting-list.application.received` | A new application arrived on the waiting list. | `waiting-list:read` |
| `badge.awarded` | A member was awarded a badge. `badgeRecordId` is the record to read. | `badges:read` |
| `badge.requirement.completed` | A member completed a badge requirement. | `badges:read` |
| `attendance.recorded` | A register changed: young people were marked present or absent, a mark was taken off, a young person with a mark was removed from the event, or a reply took a pre-ticked mark off. One event for the register, never one for each young person. `data`: `eventId`, `startsAt`, `memberIds` (whose mark was set or taken off) and `source` (`app` or `api`). | `attendance:read` |
| `event.created` | An event was added, as a draft or published. | `events:read` |
| `event.updated` | An event was changed, including being published. `changedFields` names what changed. | `events:read` |
| `event.cancelled` | An event was cancelled. | `events:read` |
| `event.deleted` | An event was deleted. | `events:read` |
| `event.rsvp.changed` | A member's RSVP to an event was set, changed or cleared. `rsvp` is `yes`, `no`, `maybe`, `waitlist`, or `null` for no answer or a place waiting for a deposit. | `events:read` |
| `task.created` | A task was added. | `tasks:read` |
| `task.updated` | A task was changed, moved or completed. `changedFields` names what changed. | `tasks:read` |
| `transaction.created` | A transaction was added to the books. Not yet sent when a treasurer accepts a bank statement line from the inbox. | `accounting:read` |
| `expense-claim.submitted` | An expense claim was submitted for approval. | `expenses:read` |
| `expense-claim.approved` | An expense claim was approved. | `expenses:read` |
| `payment.confirmed` | A Direct Debit payment was collected. | `payments:read` |
| `payment.failed` | A Direct Debit payment failed, was cancelled, was refused by the bank or was charged back. | `payments:read` |
| `hire.booking.created` | A hire booking was made, in Scoutworks or through your public hire page. `data` holds the booking's and the asset's ids. | `hire:read` |
| `refund.created` | A refund was recorded. `kind` is `direct_debit` for a refund through GoCardless, issued in Scoutworks or in the GoCardless dashboard (`"source": "system"`), or `manual` for one paid back by bank transfer and matched to its bank line, in the bank inbox or through `POST /refunds/manual`. A bank line that pays back two payments is two refunds, so two events. Later status changes do not send it again. `refundId` is the refund to read. | `payments:read` |
| `transfer.created` | Money moved between two of your own accounts: from the transfer form, a bank import that pairs the two sides, the bank inbox, or `POST /transfers`. Sent once for each transfer, never once for each of its two lines. `transferId` is the transfer to read. | `accounting:read` |
| `equipment.checked-out` | An item of equipment was checked out, in Scoutworks or through the API. `data` holds the check-out, the item, the adult who has it, the event it went out for and when it is due back. | `equipment:read` |
| `user.invited` | Someone was given a role in your group: a leader, Young Leader, trustee or admin, on the Users screen or through `POST /users`. Not yet sent for a promotion from member to leader, or for a parent linked through a member record. `status` is `invited` while they must accept, else `active`. | `users:read` |
| `user.updated` | A user's person type, roles, sections or status changed, including a suspension and a reinstatement. `changedFields` names what changed. | `users:read` |
| `user.removed` | A user no longer holds any role in your group. `removedPersonType` is the last role that ended. | `users:read` |
| `user.access-changed` | A user's access was saved on the Edit access sheet, by a bulk policy change on the Users list, or through the access endpoints (`PUT /users/{userId}/policies`, `POST` and `DELETE /users/{userId}/overrides`). `changedFields` names what changed: `policies`, `overrides`, `sections` or `personType`. A change through `PATCH /users/{userId}` or the Users list's own edit sends `user.updated` instead, and a change to a policy itself sends none yet. | `access:read` |
| `equipment.overdue` | A check-out passed its due date and the item is still out. Sent once per check-out, by the morning overdue run. | `equipment:read` |

`changedFields` uses the API's own field names and never says what a value was or became. Most events also carry `source`: where the change came from, as `app`, `api` (an API key), `import` (an OSM or file import), `system` (a scheduled job or an automatic rule) or `directory` (your organisation's Microsoft Entra ID or Google Workspace directory). Amounts are strings in pounds with two decimal places, as in the API.

Payment events cover only payments the group collects through Scoutworks.

## Bulk changes

One change can touch many records: an OSM or CSV import, a bulk badge award, a bank statement import, a register or a closing RSVP wave. Up to 100 records of a type, the change sends one event for each. Past 100, it sends that type as a **bulk summary** instead: one message, under the same event type, that names every record it changed.

```json theme={null}
{
  "type": "badge.awarded",
  "timestamp": "2026-11-21T10:15:00.000Z",
  "data": {
    "bulk": true,
    "count": 240,
    "ids": ["9c1d…", "41aa…", "…"],
    "part": 1,
    "parts": 1,
    "source": "import"
  }
}
```

* `ids` name one record each: the member for `member.*`, the application for `waiting-list.*`, the badge record for `badge.*`, the member for `event.rsvp.changed`, the task, the transaction, the claim, the refund or the transfer.
* A summary carries at most 1,000 ids. A bigger change sends several, numbered by `part` out of `parts`, each with the same `count`.
* `source` says where the change came from, as on a single event.
* An `event.rsvp.changed` summary covers one event, named in `data.eventId`, and its `ids` are the members whose answers changed.

Badge sign-offs (`badge.requirement.completed` from an event sign-off or a bulk sign-off) are written one member at a time, so they send one event per requirement however many there are.

Check `data.bulk` first. On a summary, read each record from the API by its id, or re-read the list with `updatedSince` (see [Pagination](https://developers.scoutworks.app/guides/pagination.md#sync-only-what-changed)).

## Check the signature

Anyone who learns your address can send it a message. The signature proves a message came from Scoutworks and was not changed on the way. Check it before you act on anything.

The signature is an HMAC-SHA256 of `webhook-id`, `webhook-timestamp` and the body, joined with full stops, keyed with your secret. Check it against the body **exactly as it arrived**: if your framework turns the JSON into an object and back, the bytes change and the check fails.

> [tab] Node.js
>
> Node 18 or later. Nothing to install.
>
> ```javascript verify.mjs theme={null}
> import crypto from 'node:crypto';
>
> // True when the message came from Scoutworks, unchanged, in the last five minutes.
> export function verifyScoutworks(secret, headers, rawBody) {
>   const id = headers['webhook-id'];
>   const timestamp = headers['webhook-timestamp'];
>   const signatures = headers['webhook-signature'];
>   if (!id || !timestamp || !signatures) return false;
>
>   // Refuse a message more than five minutes old or early: it may be a replay.
>   if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
>
>   const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
>   const expected = crypto
>     .createHmac('sha256', key)
>     .update(`${id}.${timestamp}.${rawBody}`)
>     .digest();
>
>   // During a secret change there are two signatures, space-separated.
>   return signatures.split(' ').some((entry) => {
>     const [version, signature] = entry.split(',');
>     if (version !== 'v1' || !signature) return false;
>     const given = Buffer.from(signature, 'base64');
>     return given.length === expected.length && crypto.timingSafeEqual(given, expected);
>   });
> }
> ```
>
> With Express, read the body raw on this route only:
>
> ```javascript theme={null}
> app.post('/scoutworks', express.raw({ type: 'application/json' }), (req, res) => {
>   const body = req.body.toString('utf8');
>   if (!verifyScoutworks(process.env.SCOUTWORKS_WEBHOOK_SECRET, req.headers, body)) {
>     return res.sendStatus(401);
>   }
>   res.sendStatus(204); // Answer first, then do the work.
>   handle(JSON.parse(body), req.headers['webhook-id']);
> });
> ```

> [tab] Python
>
> Python 3.9 or later. Nothing to install.
>
> ```python verify.py theme={null}
> import base64, hashlib, hmac, time
>
> def verify_scoutworks(secret: str, headers, raw_body: bytes) -> bool:
>     """True when the message came from Scoutworks, unchanged, in the last five minutes."""
>     msg_id = headers.get("webhook-id")
>     timestamp = headers.get("webhook-timestamp")
>     signatures = headers.get("webhook-signature")
>     if not (msg_id and timestamp and signatures):
>         return False
>
>     # Refuse a message more than five minutes old or early: it may be a replay.
>     try:
>         if abs(time.time() - int(timestamp)) > 300:
>             return False
>     except ValueError:
>         return False
>
>     key = base64.b64decode(secret.removeprefix("whsec_"))
>     signed = f"{msg_id}.{timestamp}.".encode() + raw_body
>     expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
>
>     # During a secret change there are two signatures, space-separated.
>     for entry in signatures.split(" "):
>         version, _, signature = entry.partition(",")
>         if version == "v1" and hmac.compare_digest(signature, expected):
>             return True
>     return False
> ```
>
> With Flask, pass `request.get_data()`, the body as it arrived:
>
> ```python theme={null}
> @app.post("/scoutworks")
> def scoutworks():
>     if not verify_scoutworks(os.environ["SCOUTWORKS_WEBHOOK_SECRET"], request.headers, request.get_data()):
>         return "", 401
>     handle(request.get_json(), request.headers["webhook-id"])
>     return "", 204
> ```

> [tab] PowerShell
>
> Windows PowerShell 5.1 or PowerShell 7, for example in an Azure Functions app.
>
> ```powershell Test-ScoutworksSignature.ps1 theme={null}
> # True when the message came from Scoutworks, unchanged, in the last five minutes.
> function Test-ScoutworksSignature {
>     param(
>         [string]$Secret,
>         [string]$Id,
>         [string]$Timestamp,
>         [string]$Signature,
>         [string]$Body
>     )
>     if (-not ($Id -and $Timestamp -and $Signature)) { return $false }
>
>     # Refuse a message more than five minutes old or early: it may be a replay.
>     $sent = 0L
>     if (-not [long]::TryParse($Timestamp, [ref]$sent)) { return $false }
>     $now = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
>     if ([Math]::Abs($now - $sent) -gt 300) { return $false }
>
>     $key = [Convert]::FromBase64String(($Secret -replace '^whsec_', ''))
>     $hmac = New-Object System.Security.Cryptography.HMACSHA256 (,$key)
>     $bytes = [Text.Encoding]::UTF8.GetBytes("$Id.$Timestamp.$Body")
>     $expected = $hmac.ComputeHash($bytes)
>
>     # During a secret change there are two signatures, space-separated.
>     foreach ($entry in $Signature -split ' ') {
>         $version, $given = $entry -split ',', 2
>         if ($version -ne 'v1' -or -not $given) { continue }
>         try { $givenBytes = [Convert]::FromBase64String($given) } catch { continue }
>         if ($givenBytes.Length -ne $expected.Length) { continue }
>         # Compare every byte, so the time taken gives nothing away.
>         $diff = 0
>         for ($i = 0; $i -lt $expected.Length; $i++) { $diff = $diff -bor ($givenBytes[$i] -bxor $expected[$i]) }
>         if ($diff -eq 0) { return $true }
>     }
>     return $false
> }
> ```
>
> In an Azure Functions HTTP trigger, pass the raw body:
>
> ```powershell theme={null}
> $ok = Test-ScoutworksSignature -Secret $env:SCOUTWORKS_WEBHOOK_SECRET `
>     -Id $Request.Headers['webhook-id'] -Timestamp $Request.Headers['webhook-timestamp'] `
>     -Signature $Request.Headers['webhook-signature'] -Body $Request.RawBody
> ```

You can also use any [Standard Webhooks library](https://github.com/standard-webhooks/standard-webhooks/tree/main/libraries), which does the same check.

> [!WARNING]
>
> Keep the signing secret out of your code and out of shared documents. Put it in an environment variable or your platform's secret store. If it leaks, choose **New signing secret…**.

### When you cannot check a signature

Power Automate and Zapier cannot work out an HMAC without code. For them, keep the address secret, and **read the record back from the API** before you act: a forged `payment.failed` names a payment that the API does not list as failed. [Tell the treasurer when a Direct Debit fails](https://developers.scoutworks.app/recipes/direct-debit-failed.md) does this.

## Handle each event once

We send every event **at least once**. A message can arrive twice: when your receiver was slow to answer and we tried again, or when an admin chose **Resend**. Messages can also arrive out of order.

1. **Remember each `webhook-id` you have handled**, for a few days. If a message arrives with one you know, answer `2xx` and do nothing else.
2. **Answer first, work after.** Answer within 10 seconds, then do the slow part, such as sending an email. A receiver that takes too long is counted as failed and gets the message again.
3. **Don't trust the order.** To know where a record stands now, read it from the API rather than replaying the messages in order. For an event, compare `timestamp` with the last one you handled for the same record, and ignore an older one.
4. **Make the action safe to repeat** where you can. "Set the status to failed" is safe twice. "Add a row" is not, unless the row carries the `webhook-id` and you check for it first.

## Next

* [Tell the treasurer when a Direct Debit fails](https://developers.scoutworks.app/recipes/direct-debit-failed.md), with Power Automate or Zapier.
* [Errors](https://developers.scoutworks.app/guides/errors.md), for the codes the API answers when your receiver reads a record back.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.