# API keys and permissions

> Make, scope and revoke organization API keys in Settings → API, and choose what each key may read and change.

An API key lets your software act for your organization. An admin makes keys in **Settings → API**. Each key carries its own list of permissions, so a key holds only what its job needs.

![Settings, API: the list of keys and the form for a new key](https://staffedly.com/docs/img/developers/api-keys.webp)

## Who can make a key

Admins only. Making and revoking a key are both written to the [Audit log](https://staffedly.com/docs/run/audit-log). The organization's plan must include the API: Pro, Agency, Enterprise or the free trial.

## Make a key

1. Open **Settings**, then the **API** tab.
2. Give the key a name that says what uses it, for example "Payroll export".
3. For each area, choose no access, **Read**, or **Read and write**.
4. Choose when it expires: never, in 30 days, in 90 days, or in 1 year.
5. Click **Make key** and copy the key straight away.

The key is shown once. Staffedly stores only a hash of it, so nobody, including Staffedly staff, can show it to you again. If you lose it, revoke it and make a new one.

A key starts with `sfk_`. An organization can have up to 10 active keys.

## The permissions

A key is given areas. Each area has a read permission, and most have a write permission. Write does not include read; choosing **Read and write** on the screen stores both.

| Area | Read (`…:read`) | Write (`…:write`) |
| --- | --- | --- |
| People and sites (`roster`) | Names, roles, contact details, skills, and your list of sites | Add people and update their details |
| Schedule (`schedule`) | Published shifts and call, and open shifts waiting to be filled | Post open shifts to be filled |
| Time off (`leave`) | Leave requests and approved time off | Add time off, as a request or already approved; change, approve and cancel it |
| Hours (`time`) | Clock-in and clock-out records and their approval state | Add clock records, correct and void them. Each one is reviewed before pay |
| Credentials (`credentials`) | Type, state, status and expiry date. License numbers are never returned | Add licenses and certifications, and update one on file |
| Documents (`documents`) | Stored documents and signing requests, and the files themselves, which can include tax forms | Upload documents, send a template for signature, and remind or void a request |
| Onboarding (`onboarding`) | Who is onboarding, how far each person has got and what they are waiting on. Never bank details, addresses or files | Start onboarding for a new hire or someone on the roster; their checklist is emailed to them |
| Recruiting (`recruiting`) | Jobs and applications: the candidate's name, email and phone, the job, the stage and where they came from. Never résumés, screening chats, scorecards or self-identification answers | Add an applicant and move an application between stages. Hiring and not moving forward stay with a person in the app |
| Video calls and booking (`meetings`) | Video calls and call notes with the AI summary of what was said, booking pages and bookings. Never transcripts, recordings or anyone's private link | Schedule and cancel a video call, and email someone a private link to book a call. Guests are emailed, as when your team does it. Needs video calls on your plan |
| Forms and surveys (`forms`) | Forms, their questions and the answers. Answers filed on an applicant also need Recruiting read. Uploaded files are named, not served | Email an open form to providers, facilities or applicants (applicants also need Recruiting write). Email consent applies |
| Handbook (`handbook`) | Handbook pages, who each is for, and who confirmed reading each version | None |
| To-dos (`todos`) | The team's to-dos: title, due day, who it is for and the record it is about | Give a team member a to-do. They are told by email |
| Job offers (`offers`) | Job offers, their status, terms and answers. Never the candidate's private link | Ask for a drafted offer to be sent. Nothing is sent by the key: a person with the Hiring area approves it in Staffedly, and their approval sends it |
| Contacts, notes and email history (`relationships`) | Facility contacts, and the notes and email conversation on facility and provider records. An applicant's record also needs Recruiting read | Add a facility contact, and add a note to a record (an applicant's also needs Recruiting write) |
| Reports (`reports`) | Hours, fill rate, coverage, expiring credentials and fairness summaries. No pay or billing figures | None |
| Pay and billing (`pay`) | Pay rates and amounts: the payroll, invoice and margin reports, pay runs and invoices | None |

The permission each operation needs is listed in the [API reference](https://staffedly.com/docs/api/overview).

### Change the live schedule (`schedule:publish`)

This is a separate permission. It is not part of Schedule read and write, and no key has it unless an admin ticks its own box. A key with it can add a shift to the live schedule and cancel one. Each change takes effect at once and the person is told straight away, the same way a change by your team reaches them. Every scheduling rule still applies.

### Read call transcripts (`meetings:transcript`)

Also a separate box. A transcript is everything everyone said on a call, so it is never part of **Video calls and booking: Read**. A key with it can read `GET /api/v1/meetings/{id}/transcript`. Each read is written to the [Audit log](https://staffedly.com/docs/run/audit-log).

## Use a key

Send it in the `Authorization` header on every request:

```bash
curl "https://app.staffedly.com/api/v1" \
  -H "Authorization: Bearer $STAFFEDLY_API_KEY"
```

`GET /api/v1` answers with the organization the key belongs to and the permissions it holds. It is a good first call. The browser sign-in cookie is never accepted on the API.

## Revoke a key

Use **Revoke** next to the key in the list. It stops working at once. The row stays in the list so the audit trail still makes sense.

The list also shows when each key was last used and how many requests it has made. Both are updated about once a minute.

## Keep keys safe

- Keep a key on a server, never in a web page, a mobile app or a public repository.
- Give each system its own key with only the areas it needs.
- Give **Pay and billing** and **Documents** only to systems that should hold pay figures and tax forms, and **Read call transcripts** only to a system that should hold what was said on calls.
- Set an expiry for keys handed to a contractor or a trial integration.

## Questions

### What happens to keys when our plan changes?

On a plan without the API, calls answer `402 plan_required`. The keys are kept and work again when the plan includes the API.

### What does a wrong key do?

It answers `401 unauthorized`. After 20 refused attempts in a minute from one address, that address is asked to wait a minute.
