Team API
Put a Community First Responder team's public events, bookings, figures and public access defibrillators on its own website.
https://{team}.cfrhub.app/api/v1What the API is for
CFR Hub is the members' app that Community First Responder teams use for their hours, calls, events and equipment. Each team has its own address, such as yourteam.cfrhub.app, and the same address serves its API.
The API shares only what a team chooses to make public:
- Public events, such as CPR training sessions, with their sessions and places left
- Bookings from your website, for up to 6 people at once: CFR Hub emails a ticket with a QR code, which the team scans at the door
- Waiting lists for full events: CFR Hub emails people when a place comes free
- Team figures: on-call hours, calls attended and people trained in CPR, for different periods
- Public access defibrillators with their exact positions, ready for a map
Two extras help a team's website: webhooks tell it straight away when something changes, and Sign in with CFR Hub lets the team's members sign in to it with their CFR Hub account.
It never shares anything about individual members, the names or email addresses of people who booked, or defibrillator cabinet codes.
yourteam.cfrhub.app/book, ready to share on social media and posters.Your first call in three steps
- Find your team's address. Every team on CFR Hub has its own, like
yourteam.cfrhub.app. The API is athttps://yourteam.cfrhub.app/api/v1. - Ask a team admin for a key. They create one in the team's app under Settings → Website & API and send it to you securely. It's shown to them once.
- Check it works. This returns the team's name:
curl https://yourteam.cfrhub.app/api/v1/team \ -H "Authorization: Bearer $CFRHUB_API_KEY"
Getting and using a key
A team admin creates keys in CFR Hub under Settings → Website & API. A key starts with cfrh_ and is shown once, so copy it into your website's configuration straight away. Keys can be removed there at any time.
Send the key with every request:
Authorization: Bearer cfrh_your_key_here
The X-Api-Key: cfrh_… header works too. A key only works at its own team's address.
Requests and responses
- Everything is HTTPS and JSON (UTF-8). Bookings accept a JSON body or an ordinary form-encoded one.
- Times are ISO 8601 in UK time with its offset:
2026-11-07T10:00:00+00:00in winter (GMT) and+01:00in summer (BST). - Dates on their own are
YYYY-MM-DD. - Missing values are
null, never left out. Anulllimit means there's no limit. - Responses aren't cached by CFR Hub (
Cache-Control: no-store). Cache on your own server: see limits. - Endpoints for a feature the team has switched off (events, or the asset register) return 404.
When something goes wrong
Errors use the matching HTTP status and this body. The message is written so you can show it to visitors as it is.
{ "error": { "code": "full", "message": "Sorry, that session is fully booked." } }| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_json | The booking body wasn't a JSON object |
| 401 | unauthorised | No key, or the key isn't valid for this team |
| 404 | not_found | No team at this address, an unknown endpoint, or an event that isn't public |
| 409 | full | The event or session is fully booked |
| 409 | not_enough_places | Fewer places are left than were asked for. The error also has places_left |
| 409 | no_booking | A drop-in event: there's nothing to book |
| 409 | not_full, waitlist_full | Waiting list only: there are places, so book instead; or the list has reached 200 people |
| 409 | closed | The event or session has finished or been cancelled |
| 422 | invalid_name, invalid_email, session_required, invalid_places, invalid_period, invalid_dates, invalid_months | Something in the request needs fixing |
| 429 | rate_limited | Too many requests: wait and try again |
Rate limits
300 requests a minute per key, and 600 a minute per IP address.
200 an hour per key for each, and 5 an hour for any one email address.
All your visitors share your key's limits. Cache GET responses on your server (events for a few minutes; stats and defibrillators for an hour), and protect your booking form against spam, for example with a CAPTCHA, before it calls CFR Hub.
List upcoming public events
Public events that haven't finished and aren't cancelled, soonest first.
| Query | Description |
|---|---|
limit optional | 1 to 100. Default 50. |
type optional | training (CPR training), awareness, fundraising or other |
curl https://yourteam.cfrhub.app/api/v1/events \ -H "Authorization: Bearer $CFRHUB_API_KEY"
{
"events": [
{
"id": 910,
"title": "CPR training – Scouts and Guides",
"type": "training",
"type_label": "CPR training",
"starts_at": "2026-11-07T10:00:00+00:00",
"ends_at": "2026-11-07T13:00:00+00:00",
"location": "Village hall cabinet, Mill Lane",
"address": "Mill Lane, Ridgeway",
"postcode": "AN1 2TW",
"latitude": 51.19563,
"longitude": 0.27391,
"summary": "Learn CPR in an hour",
"audience": "Ages 10 and up",
"image_url": "https://yourteam.cfrhub.app/event-photo/910-3121.jpg",
"description": "Learn CPR and how to use a defibrillator in an hour.",
"cancelled": false,
"booking_required": true,
"max_attendees": 30,
"booked": 14,
"places_left": 16,
"full": false,
"booking_open": true,
"max_places_per_booking": 6,
"waitlist_open": false,
"sessions": [
{
"id": 1,
"name": "10am Group 1",
"starts_at": "2026-11-07T10:00:00+00:00",
"ends_at": "2026-11-07T11:00:00+00:00",
"max_attendees": 12,
"booked": 12,
"places_left": 0,
"full": true,
"booking_open": false
}
]
}
]
}Event fields
| Field | Description |
|---|---|
location | The venue's name, e.g. "Village hall cabinet, Mill Lane", or null. |
address, postcode | For directions, or null. |
latitude, longitude | Worked out from the postcode, for a map pin or directions link, or null. |
summary | One line for listing cards (up to 200 characters), or null. |
audience | Who it's for, e.g. "Ages 10 and up", or null. |
image_url | A photo the organiser uploaded (JPEG, landscape works best), or null. It can be used directly in an <img> without a key. The address changes when the photo does, so it can be cached for a long time. |
description | Text the team wrote for the public, or null. Their internal notes are never included. |
booking_required | false for drop-in events: say "No booking needed" instead of showing a form. |
max_attendees | Places across the whole event, or null for no limit. |
booked, places_left | Places taken and left. places_left is null when there's no limit. |
full | true when the event is full, or every session is. |
booking_open | Whether to offer booking: booking needed, not full, not finished, not cancelled. |
max_places_per_booking | The most places one booking can be for (currently 6). |
waitlist_open | true when the event (or a session) is full but people can join the waiting list. |
sessions | Groups or start times within the event. An empty array means people book the event as a whole. |
sessions[].places_left | Places left in that session, already allowing for the event's overall limit. |
Get one event
Returns { "event": { … } } in the same shape as the list. Unlike the list, it also returns public events that have finished or been cancelled, so check booking_open. Events that aren't public return 404.
Fetch the event again just before showing a booking form, so the places left are current.
Book a place
Books one person, or a group such as a family, on to a public event, or on to one of its sessions.
| Field | Description |
|---|---|
name | The person's name, up to 120 characters. |
email | Where their ticket is sent. |
session_id when the event has sessions | An id from the event's sessions. |
places optional | How many people, 1 to 6. Default 1. They share one ticket, which admits that many people, and all count against places_left. |
curl https://yourteam.cfrhub.app/api/v1/events/910/bookings \
-H "Authorization: Bearer $CFRHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Jane Smith", "email": "[email protected]", "session_id": 2, "places": 3}'{
"booking": {
"already_booked": false,
"message": "Your place is booked. We've emailed your ticket."
},
"event": { … the event, with updated numbers … }
}- 201 means a new booking. 200 means that email address had already booked that session: CFR Hub emails a fresh ticket and the old QR code stops working.
- Show
booking.messageto the person, and suggest they check their spam folder if the email doesn't arrive. - The ticket email comes from CFR Hub in the team's branding. The ticket page lets the person cancel their place, which frees it for someone else.
- About 24 hours before their event or session, CFR Hub emails a reminder with the same ticket (unless they booked within that time).
- Team members can also book people on in the CFR Hub app, for example by phone or at the door. Those places count towards the same limits.
- If the team cancels the event, CFR Hub emails everyone who booked.
- If there are fewer places left than asked for, the 409
not_enough_placeserror includesplaces_left, so you can offer fewer.
Join the waiting list
For a full event (when waitlist_open is true). The same fields as a booking: name, email, session_id when the event has sessions, and optional places.
{
"waitlist": {
"already_waiting": false,
"position": 3,
"message": "You're on the waiting list. We'll email you if a place comes free."
}
}- 201 means they've joined; 200 means that email was already waiting (their name and places are updated). Show
waitlist.message. - CFR Hub emails them straight away with a link to see their place in the queue or leave the list.
- When places come free, CFR Hub emails the people waiting in the order they joined, with a link to book. The place is held for 12 hours, then offered to the next person.
- If there's room after all, you get 409
not_full: book instead. The list closes when the event starts, and everyone waiting is told if it's cancelled. - Names and emails on the list are deleted with the bookings, 90 days after the event.
Team figures
With no query, you get every standard period. Choose one with ?period=, or give your own dates with ?from=2026-01-01&to=2026-06-30 (both inclusive).
| Period | Covers |
|---|---|
month | This month so far |
lastmonth | Last calendar month |
quarter | This quarter so far |
year | This calendar year so far |
last12 | The 12 full months before this one |
all | Since the team's records begin |
{
"stats": {
"label": "This year",
"from": "2026-01-01",
"to": "2026-10-15",
"oncall_hours": 2334,
"other_volunteer_hours": 369,
"calls_attended": 534,
"people_cpr_trained": 917,
"events_held": 25,
"money_raised": 5901.94
}
}| Field | Description |
|---|---|
oncall_hours | Hours responders were on call that count towards the ambulance service's figures, rounded. |
other_volunteer_hours | Other volunteering, such as training, events and admin. |
calls_attended | Emergency calls attended, not counting calls where the responder was stood down. |
people_cpr_trained | People trained at the team's events that have finished. |
events_held, money_raised | Finished events, and money raised at them (GBP). |
A figure is null when the team doesn't use that part of CFR Hub. Hide it rather than showing 0.
Month by month
The same figures for each month, oldest first and ending with this month so far, for a chart. ?months= 1 to 36, default 12.
{
"months": [
{ "month": "2025-11", "oncall_hours": 241, "calls_attended": 47, "people_cpr_trained": 60,
"other_volunteer_hours": 31, "events_held": 2, "money_raised": 180.5 },
… one entry per month …
]
}Public access defibrillators
The team's defibrillators marked as public access that have a map position. Add ?format=geojson for a GeoJSON FeatureCollection, which Leaflet, Mapbox, OpenLayers and Google Maps' data layer read directly.
{
"defibrillators": [
{
"id": 476,
"name": "Village hall cabinet, Mill Lane",
"type": "owned",
"address": "Village Hall, Mill Lane, Ridgeway",
"postcode": "AN1 3VH",
"latitude": 51.21458,
"longitude": 0.23781,
"location_details": "On the wall to the left of the front door",
"what3words": "///filled.count.soap",
"available_24_7": true,
"access_24h": true,
"availability": "24 hours",
"make": "ZOLL",
"model": "AED Plus",
"in_service": true,
"last_checked": "2026-09-30",
"funded_by": "Village hall defib replacement appeal"
}
]
}| Field | Description |
|---|---|
latitude, longitude | The cabinet's position (WGS 84), placed by the team on a map. In GeoJSON the order is [longitude, latitude]. |
location_details | How to find it on site, or null. |
type | owned by the team, managed by the team for someone else, or other. |
access_24h | true when anyone can reach it at any time. available_24_7 is the same value, kept for older websites. |
availability | When it can be reached, e.g. "24 hours", or null. |
in_service | false when its pads or battery have expired. Show it as out of service, or leave it off. |
last_checked | Date of the last recorded check, or null. |
funded_by | Who paid for it, e.g. a local business or appeal, for a credit on the map. Or null. |
Team details
The team's name, short name and app address, and which features it uses. It's handy for checking your key works.
{ "team": { "name": "Ridgeway Community First Responders", "short_name": "Ridgeway CFR",
"app_url": "https://yourteam.cfrhub.app/", "features": { "events": true } } }Webhooks
Instead of waiting for your cache to run out, your website can be told the moment something changes. A team admin adds your website's address under Settings → Website & API → Webhook and copies the signing secret (starting whsec_), which is shown once. There's a Send a test button too.
CFR Hub sends a POST with a JSON body:
| Event | When | data |
|---|---|---|
event.updated | A public event is created, changed, made public or private, booked or a place cancelled | {"event_id": 910} |
event.cancelled | A public event is cancelled | {"event_id": 910} |
defibrillator.updated | A PAD site is added, changed, removed, or its pads or battery are replaced | {"defibrillator_id": 476}, plus "removed": true when it's gone |
ping | The test button | {"team": "yourteam"} |
POST /hooks/cfrhub
Content-Type: application/json
X-CfrHub-Event: event.updated
X-CfrHub-Delivery: 1234
X-CfrHub-Timestamp: 1792338769
X-CfrHub-Signature: sha256=5d41402abc4b2a76…
{"event":"event.updated","data":{"event_id":910}}Check the signature before trusting the call: it's the HMAC-SHA256 of the timestamp, a full stop and the raw body, keyed with the secret. Reject calls more than 5 minutes old.
$body = file_get_contents('php://input'); $ts = (int) ($_SERVER['HTTP_X_CFRHUB_TIMESTAMP'] ?? 0); $expected = 'sha256=' . hash_hmac('sha256', $ts . '.' . $body, getenv('CFRHUB_WEBHOOK_SECRET')); if (abs(time() - $ts) > 300 || !hash_equals($expected, $_SERVER['HTTP_X_CFRHUB_SIGNATURE'] ?? '')) { http_response_code(401); exit; } // Clear your cached copy, then fetch it again from the API when it's next needed
- Reply with any 2xx status within 8 seconds. Do the slow work afterwards.
- If your website doesn't answer, CFR Hub tries again after 5, 10, 20, 40 and 80 minutes, then gives up. The settings page shows the last result.
- Calls carry IDs only, never personal details. Fetch the latest from the API. A call can arrive twice, so handle repeats.
- The address must be
https://. Redirects aren't followed.
Sign in with CFR Hub
Lets the team's members sign in to your website with their CFR Hub account, using OAuth 2.0 and OpenID Connect (authorisation code flow, with PKCE supported). Any active member of the team can sign in. CFR Hub only tells you who they are: your website decides what each person can do, such as who can edit it.
A team admin registers your website under Settings → Website & API → Sign in with CFR Hub, with its return address (for example https://yourwebsite.org/auth/callback). They get a client ID (cfrhc_…) and a client secret (cfrhs_…, shown once). Most OpenID Connect libraries only need the discovery address:
https://yourteam.cfrhub.app/.well-known/openid-configuration
| Endpoint | Use |
|---|---|
GET /oauth/authorize | Send the person here with response_type=code, client_id, redirect_uri (exactly as registered), scope=openid profile email, state, and optionally nonce and code_challenge with code_challenge_method=S256. They sign in to CFR Hub if they need to, then confirm. You get ?code=…&state=…, or ?error=access_denied. |
POST /oauth/token | From your server: grant_type=authorization_code, code, redirect_uri and code_verifier if you sent a challenge. Authenticate with HTTP Basic (client ID and secret) or client_id and client_secret in the form. Codes last 10 minutes and work once. |
GET /oauth/userinfo | With Authorization: Bearer <access_token>. The access token lasts an hour and is only for this endpoint. |
{
"access_token": "…",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "openid profile email",
"id_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9…"
}The id_token is a JWT signed with HS256 using your client secret. Check the signature, that iss is the team's address (e.g. https://yourteam.cfrhub.app), that aud is your client ID, that it hasn't expired (10 minutes), and the nonce if you sent one.
| Claim | Description |
|---|---|
sub | The member's ID in CFR Hub. It doesn't change, so use it to recognise them. |
name, given_name | With the profile scope. |
email, email_verified | With the email scope. |
team | The team's address name (e.g. yourteam). |
A defibrillator map in a few lines
Your server fetches /defibrillators?format=geojson with the key, caches it for an hour, and serves it from your own site, e.g. /data/defibs.geojson. The page then draws it with Leaflet:
const map = L.map('defib-map').setView([51.19, 0.27], 11); L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19, attribution: '© OpenStreetMap contributors' }).addTo(map); fetch('/data/defibs.geojson').then(r => r.json()).then(data => { L.geoJSON(data, { onEachFeature: (f, layer) => { const p = f.properties, el = document.createElement('div'); el.textContent = [p.name, p.location_details, p.availability, p.in_service ? '' : 'Temporarily out of service'].filter(Boolean).join(' · '); layer.bindPopup(el); } }).addTo(map); });
Put text from the API on the page as text (textContent, or escape it on the server), never as HTML. If you use OpenStreetMap's tiles, keep the credit visible and follow their tile usage policy.
Bookings and personal data
- Your booking and waiting list forms should say that the name and email are passed to CFR Hub so the team can send a ticket (or tell them a place is free) and run the event. For example: "We pass your name and email to CFR Hub, our booking system, to send your ticket and a reminder the day before. They're deleted 90 days after the event."
- Only the event's organiser and the team's admins see names in CFR Hub. Volunteers at the event see numbers, and the first name and initial of the person whose ticket they scan.
- CFR Hub deletes names and email addresses 90 days after the event, and keeps only the numbers.
- Your website doesn't need to store bookings, so it's best not to.
Powered by CFR Hub
If your website uses CFR Hub for events, bookings, figures or defibrillators, we'd be grateful for a small credit, for example in your footer or under your events list. It's optional, but it helps other CFR teams find CFR Hub, which keeps it free for everyone.
<a href="https://cfrhub.app">Powered by CFR Hub</a>Or with our logo:
<a href="https://cfrhub.app" style="display:inline-flex;align-items:center;gap:6px"> <img src="https://cfrhub.app/assets/brand/cfrhub-mark.svg" alt="" width="18" height="23"> Powered by CFR Hub </a>
Please use a plain link like these, without rel="nofollow", and style it to suit your site.
Changes to the API
We only ever add to version 1: new fields and endpoints, never removing or renaming what's there. Ignore fields you don't use.
18 October 2026
- Monthly figures in one call:
GET /stats/monthly - Bookings for up to 6 people on one ticket:
places - Event photo, summary, audience, address, postcode and map position, and drop-in events (
booking_required) - Waiting lists for full events
- Defibrillators:
funded_byandaccess_24h - Webhooks and Sign in with CFR Hub
15 October 2026
- First release: events, bookings, team figures and defibrillators.