- For: anyone building a tool that several groups connect to, such as a district volunteer’s dashboard or a booking system
- You get: an endpoint your tool adds to each group itself, tested, with its signing secret stored
- Time: about twenty minutes
- Scopes:
webhooks:read,webhooks:write, and the read scope of each event you want, such asmembers:readformember.created
webhooks:write on the key, your tool does that itself, the same way for every group.
1. Ask for the right scopes
Tell each group admin which scopes to tick when they create the key for your tool:webhooks:readandwebhooks:write, to manage the endpoint;- the read scope of every event you want. An endpoint can receive only events whose records the key can read:
member.createdneedsmembers:read,event.updatedneedsevents:read. The event list gives each one’s scope. Payment events cannot be chosen with a key: an admin adds those in Scoutworks.
GET /me before you go on:
2. Look for an endpoint you added before
A group may connect your tool twice, or reconnect it. List its endpoints first, and reuse yours if it is there:404.
3. Add the endpoint
secret, which starts whsec_. Store the secret now, against the group, in your tool’s secret store: it is never shown again. If the request times out, send it again with the same Idempotency-Key: you get the same endpoint, without the secret, and no second endpoint is made. Then rotate the secret (step 5) to get one you can store.
Put the group’s id in the address, as above, so your receiver knows which group’s secret checks each message.
4. Check it works
Send a test event:webhook.test message reaches your receiver within a few seconds. Check its signature with the secret you stored. Then read the delivery to see what your receiver answered:
status of delivered means it worked. failed, or a lastHttpStatus other than 2xx, means your receiver refused it: the attempts show what it answered.
5. Rotate the secret
Rotate each group’s secret on a schedule, and at once if you think one has leaked:secret. Store it. The old secret keeps signing beside the new one for 24 hours, and each message carries both signatures, so your receiver can switch over without missing a message.
6. Look after it
-
It stops working with the key’s creator. An endpoint added with a key belongs to the admin who created the key. If they stop being a group admin, the endpoint stops sending (
status: owner_inactive), as the key stops working. Ask the group for a new key, delete the old endpoint and add it again. -
A failing endpoint is switched off after five days of failed tries (
status: disabled,disabledReason: failing). Fix your receiver, then switch it back on: -
When a group disconnects your tool, delete your endpoint with
DELETE /webhook-endpoints/{endpointId}. -
Catch anything you missed. A message can go astray. Run Keep a copy in sync now and then:
GET /changesreports every change, webhook or not.
Switch to your group
Every write here goes toapi.scoutworks.app with the group’s own key, which needs the scopes in step 1. Scoutworks records each change as made by the admin who created the key, and marks it with the key’s name, so the group can see in its webhook settings what your tool did. Webhooks cannot be added in the demo.
If something goes wrong
403 insufficient_scopeon add or change: the key lackswebhooks:write, or the read scope of one of the events. The message names the events.400 invalid_request: the address must starthttps://and use a public domain name, not an IP address.409 conflicton add: the group already has ten endpoints. On a test: the endpoint is switched off.412 stale_write: someone changed the endpoint since you read it. Read it again, then retry with its newETag.