API keys, scopes and authentication
Creating keys, what they may do, and keeping them safe.
API keys
An API key identifies one integration. Create them in Admin › Integrations › API keys (administrators only).
| Setting | Meaning |
|---|---|
| Name | The system that will use it, for example “Payroll sync”. It appears in the activity log as system:api:Payroll sync on everything the key does, so you can always tell who made a change. |
| Scopes | What the key may do. Tick the least it needs. |
| Allowed addresses | Optional. IP addresses or ranges (such as 203.0.113.5 or 198.51.100.0/24, IPv4 or IPv6), separated by commas. The key is refused from anywhere else. Empty means any address. |
| Expires on | Optional. The key stops working at the end of that day. |
| Requests per minute | 10 to 6000. Default 120. |
The key looks like cc_1a2b3c4d_ followed by 48 more characters. It is shown once, when you create it. Care Core keeps only a one-way hash, so a lost key cannot be recovered: revoke it and create another. The list shows the first part (cc_1a2b3c4d…), the scopes, when it was last used and when it expires.
Using a key
Send it as a bearer token on every request:
Authorization: Bearer cc_1a2b3c4d_0123456789abcdef0123456789abcdef0123456789abcdef
- Always use HTTPS. The API refuses plain HTTP on a real host (
403 https_required). Onlylocalhostis allowed over HTTP, for development. - Keep keys on your server, in a secrets store or environment variable. Never put one in a web page, mobile app or code repository. The API sends no CORS headers, because it is for server-to-server use.
- Give each system its own key, so you can revoke one without disturbing the others.
Scopes
Every endpoint names the scope it needs. A call without it gets 403 forbidden, with a message naming the missing scope.
| Scope | Allows |
|---|---|
people.read | Read people (names, contact details, whether staff or supported). |
people.write | Create and edit people. |
staff.read | Read employments, employment terms, the non-sensitive staff profile and pending profile changes. |
staff.write | Start, change and end employments (joiner, mover, leaver); edit terms and the staff profile. |
staff.sensitive | Read and write National Insurance and bank details. Grant to as few keys as possible. |
compliance.read | Read registrations, supervisions, appraisals and learning, and what is due. |
compliance.write | Add and remove registrations, supervisions, appraisals and learning records. |
teams.read | Read teams and their members. |
teams.write | Create, edit and close teams; add and end team places. |
care.read | Read support episodes, care needs, contacts and key workers. |
care.write | Start and end support; manage care needs, contacts and key workers. |
recruitment.read | Read job roles, vacancies, candidates and their checks. |
recruitment.write | Create roles and vacancies, add and move candidates, record offers and checks, and hire. |
referrals.read | Read referrals: who was referred, why, what they need and the decision. |
referrals.write | Record referrals, move them through assessment, decide them and link them to a person. |
tasks.read | Read tasks. |
tasks.write | Mark tasks done or skipped. |
events.read | Read the event feed. |
webhooks.manage | Create, change and delete webhook endpoints and read their deliveries. |
audit.read | Read the activity log. |
admin.read | Read the logins list and the consistency checks. |
Least privilege is built in
- Without
care.read, people who only receive support are invisible: they are not listed, a direct request for them returns404, andis_supportedisnull. A payroll system never learns who receives care. - Without
people.write, the free-textnoteson a person are left out. - National Insurance and bank details are in the profile only for keys with
staff.sensitive, and only such keys can change them. They are encrypted at rest, and never written to the activity log or to events. - Webhook secrets are returned once, when the endpoint is created.
Any valid key can call GET /ping and GET /scopes (which lists every scope and whether this key has it).
Rotating and revoking
- Rotate: create a new key with the same scopes, switch the integration over, then revoke the old one. Both work in the meantime.
- Revoke on the same page: the key stops working at once (
401). - Set an expiry on keys for short-lived projects, and put a reminder in your calendar for the others.
- A key that has not been used for a long time shows “never” or an old date under Last used: revoke it.
Authentication errors
| Status | Code | Cause |
|---|---|---|
| 401 | unauthorized | No Authorization header, a malformed or unknown key, or a revoked or expired key. The response carries WWW-Authenticate: Bearer. |
| 403 | forbidden | The key lacks the scope, or is used from an address it is not allowed from. |
| 403 | https_required | The request was not sent over HTTPS. |
Every use of a key by a system is attributed to it in the activity log. Creating and revoking keys is logged too (never the key itself).
Next: Conventions.