Home / Developers
For developers

Team API

Put a Community First Responder team's public events, bookings, figures and public access defibrillators on its own website.

Base URLhttps://{team}.cfrhub.app/api/v1
Overview

What 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.

No website, or no developer? You don't need the API to take bookings. Every team has its own booking page at yourteam.cfrhub.app/book, ready to share on social media and posters.
Get started

Your first call in three steps

  1. Find your team's address. Every team on CFR Hub has its own, like yourteam.cfrhub.app. The API is at https://yourteam.cfrhub.app/api/v1.
  2. 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.
  3. Check it works. This returns the team's name:
Request
curl https://yourteam.cfrhub.app/api/v1/team \
  -H "Authorization: Bearer $CFRHUB_API_KEY"
Not on CFR Hub yet? It's free for Community First Responder teams. Request access for your team, or contact us with questions about the API.
Keys and security

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:

HTTP header
Authorization: Bearer cfrh_your_key_here

The X-Api-Key: cfrh_… header works too. A key only works at its own team's address.

Keep the key on your server. Call the API from your website's server code, never from JavaScript in visitors' browsers. Don't put the key in HTML, in a URL or in a git repository. The API doesn't send CORS headers, so browser calls are refused anyway.
Conventions

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:00 in winter (GMT) and +01:00 in summer (BST).
  • Dates on their own are YYYY-MM-DD.
  • Missing values are null, never left out. A null limit 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.
Errors and limits

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.

Response · 409
{ "error": { "code": "full", "message": "Sorry, that session is fully booked." } }
StatusCodeMeaning
400invalid_jsonThe booking body wasn't a JSON object
401unauthorisedNo key, or the key isn't valid for this team
404not_foundNo team at this address, an unknown endpoint, or an event that isn't public
409fullThe event or session is fully booked
409not_enough_placesFewer places are left than were asked for. The error also has places_left
409no_bookingA drop-in event: there's nothing to book
409not_full, waitlist_fullWaiting list only: there are places, so book instead; or the list has reached 200 people
409closedThe event or session has finished or been cancelled
422invalid_name, invalid_email, session_required, invalid_places, invalid_period, invalid_dates, invalid_monthsSomething in the request needs fixing
429rate_limitedToo many requests: wait and try again

Rate limits

Reading
300 requests a minute per key, and 600 a minute per IP address.
Booking and waiting lists
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.

Events

List upcoming public events

GET/events

Public events that haven't finished and aren't cancelled, soonest first.

QueryDescription
limit optional1 to 100. Default 50.
type optionaltraining (CPR training), awareness, fundraising or other
Request
curl https://yourteam.cfrhub.app/api/v1/events \
  -H "Authorization: Bearer $CFRHUB_API_KEY"
Response · 200
{
  "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

FieldDescription
locationThe venue's name, e.g. "Village hall cabinet, Mill Lane", or null.
address, postcodeFor directions, or null.
latitude, longitudeWorked out from the postcode, for a map pin or directions link, or null.
summaryOne line for listing cards (up to 200 characters), or null.
audienceWho it's for, e.g. "Ages 10 and up", or null.
image_urlA 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.
descriptionText the team wrote for the public, or null. Their internal notes are never included.
booking_requiredfalse for drop-in events: say "No booking needed" instead of showing a form.
max_attendeesPlaces across the whole event, or null for no limit.
booked, places_leftPlaces taken and left. places_left is null when there's no limit.
fulltrue when the event is full, or every session is.
booking_openWhether to offer booking: booking needed, not full, not finished, not cancelled.
max_places_per_bookingThe most places one booking can be for (currently 6).
waitlist_opentrue when the event (or a session) is full but people can join the waiting list.
sessionsGroups or start times within the event. An empty array means people book the event as a whole.
sessions[].places_leftPlaces left in that session, already allowing for the event's overall limit.
Events

Get one event

GET/events/{id}

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.

Bookings

Book a place

POST/events/{id}/bookings

Books one person, or a group such as a family, on to a public event, or on to one of its sessions.

FieldDescription
nameThe person's name, up to 120 characters.
emailWhere their ticket is sent.
session_id when the event has sessionsAn id from the event's sessions.
places optionalHow many people, 1 to 6. Default 1. They share one ticket, which admits that many people, and all count against places_left.
Request
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}'
Response · 201
{
  "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.message to 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_places error includes places_left, so you can offer fewer.
Waiting list

Join the waiting list

POST/events/{id}/waitlist

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.

Response · 201
{
  "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 stats

Team figures

GET/stats

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).

PeriodCovers
monthThis month so far
lastmonthLast calendar month
quarterThis quarter so far
yearThis calendar year so far
last12The 12 full months before this one
allSince the team's records begin
GET /stats?period=year · 200
{
  "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
  }
}
FieldDescription
oncall_hoursHours responders were on call that count towards the ambulance service's figures, rounded.
other_volunteer_hoursOther volunteering, such as training, events and admin.
calls_attendedEmergency calls attended, not counting calls where the responder was stood down.
people_cpr_trainedPeople trained at the team's events that have finished.
events_held, money_raisedFinished 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.

Team stats

Month by month

GET/stats/monthly

The same figures for each month, oldest first and ending with this month so far, for a chart. ?months= 1 to 36, default 12.

GET /stats/monthly?months=12 · 200
{
  "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 …
  ]
}
Defibrillators

Public access defibrillators

GET/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.

Response · 200
{
  "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"
    }
  ]
}
FieldDescription
latitude, longitudeThe cabinet's position (WGS 84), placed by the team on a map. In GeoJSON the order is [longitude, latitude].
location_detailsHow to find it on site, or null.
typeowned by the team, managed by the team for someone else, or other.
access_24htrue when anyone can reach it at any time. available_24_7 is the same value, kept for older websites.
availabilityWhen it can be reached, e.g. "24 hours", or null.
in_servicefalse when its pads or battery have expired. Show it as out of service, or leave it off.
last_checkedDate of the last recorded check, or null.
funded_byWho paid for it, e.g. a local business or appeal, for a credit on the map. Or null.
Cabinet codes are never included. In an emergency, people should call 999: the call handler directs them to the nearest available defibrillator and gives them the code.
Team

Team details

GET/team

The team's name, short name and app address, and which features it uses. It's handy for checking your key works.

Response · 200
{ "team": { "name": "Ridgeway Community First Responders", "short_name": "Ridgeway CFR",
  "app_url": "https://yourteam.cfrhub.app/", "features": { "events": true } } }
For your website

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:

EventWhendata
event.updatedA public event is created, changed, made public or private, booked or a place cancelled{"event_id": 910}
event.cancelledA public event is cancelled{"event_id": 910}
defibrillator.updatedA PAD site is added, changed, removed, or its pads or battery are replaced{"defibrillator_id": 476}, plus "removed": true when it's gone
pingThe test button{"team": "yourteam"}
Request from CFR Hub
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.

PHP
$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.
For your website

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:

Discovery
https://yourteam.cfrhub.app/.well-known/openid-configuration
EndpointUse
GET /oauth/authorizeSend 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/tokenFrom 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/userinfoWith Authorization: Bearer <access_token>. The access token lasts an hour and is only for this endpoint.
POST /oauth/token · 200
{
  "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.

ClaimDescription
subThe member's ID in CFR Hub. It doesn't change, so use it to recognise them.
name, given_nameWith the profile scope.
email, email_verifiedWith the email scope.
teamThe team's address name (e.g. yourteam).
CFR Hub checks that the person is still an active member each time a token is issued or userinfo is called. If someone leaves the team, they can't sign in any more, but a session your website already started lasts as long as you let it. Keep your sessions short, or call userinfo now and then.
Guide

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:

JavaScript
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: '&copy; 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.

Privacy

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.
Guide

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.

HTML
<a href="https://cfrhub.app">Powered by CFR Hub</a>

Or with our logo:

HTML
<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.

What's new

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_by and access_24h
  • Webhooks and Sign in with CFR Hub

15 October 2026

  • First release: events, bookings, team figures and defibrillators.