Authentication & tokens
Every request to the QHR Open API carries an API token in the Authorization header. A token is created by a QHR user in the web app and acts as that user, in one company, with that user's permissions. There are no passwords, cookies or sessions involved.
GET /open/v1/employees HTTP/1.1
Host: qhr-api.example.com
Authorization: Bearer qhr_Ab3dEf7hJk9m_7Gh2…
Accept-Language: en
What a token is
A token looks like qhr_Ab3dEf7hJk9m_7Gh2…. It has three parts:
qhr_so secret scanners (GitHub, GitLab and others) can recognise a leaked QHR token,- a public id (
Ab3dEf7hJk9m) that QHR shows in token lists so you can tell tokens apart, - a long secret. QHR stores only a fingerprint of it, so nobody at QHR can read your token back.
A token always belongs to:
- one person, the user who created it. Everything it does is recorded in the audit log under that person's name, marked as done through the API.
- one company, the company that was active when it was created. If you work in two companies, create one token in each.
A token can never do more than its owner can do in the web app. If your role can't approve leave, neither can your token.
Create a token
- Sign in to QHR and switch to the company you want the token for.
- Open Settings › API & Integrations › My tokens and select Create token.
- Fill in the form:
- Name (up to 60 characters). Name it after where it will be used, for example
ERP syncorClaude, so you know which one to revoke later. - Allow changes. Leave it unticked for a read-only token. Tick it only when the integration must create, update or delete data. See below.
- Expires. Choose 30, 90, 180 or 365 days, or pick a date up to 365 days away. Tokens that never expire are not allowed.
- Name (up to 60 characters). Name it after where it will be used, for example
- Select Create, then copy the token. QHR shows the full token only on this screen. After you close it, you will only see its public id.
If you lose a token, you can't recover it. Revoke it and create a new one.
Note: You can have up to 10 active tokens in each company. Revoke the ones you no longer use to free a slot.
Note: An administrator who is signed in as you (impersonation) cannot create tokens on your behalf. Only you can.
Read or read & write
Each token has one of two access levels.
| Access | In the form | What it can do |
|---|---|---|
read | Allow changes unticked | Call operations that only read data. Any attempt to change something is refused with 403 token_read_only. |
read_write | Allow changes ticked | Call every operation your role allows, including ones that create, update, approve or delete. |
Choose the smallest access that works. A reporting dashboard or a data export only needs read. If a read token leaks, nothing in QHR can be changed with it.
Every endpoint page shows a badge saying whether a read token is enough. Don't guess from the HTTP method: a few POST endpoints only read data (for example, searching the attendance report with a large filter), and those accept read tokens.
Permissions
A token carries its owner's role. Each endpoint page lists the permission it needs, for example employees/view or leave/approve. If your role lacks it, the call fails with 403 forbidden; ask an administrator to add it to your role.
GET /me returns the token's permissions and the features switched on for your company, so an integration can check what it may do before it tries.
Expiry
Every token has an expiry date of at most 365 days. QHR emails the owner 7 days before a token expires. After the expiry date, calls fail with 401 token_expired. Create a new token and replace the old one in your integration; expired tokens cannot be extended.
Plan the swap ahead: create the new token, deploy it, check it with GET /me, then revoke the old one.
Revoke a token
Revoke a token as soon as you no longer need it, or immediately if you think it has leaked.
- Open Settings › API & Integrations › My tokens.
- Find the token by its name or public id and select Revoke.
It stops working on the very next request. Revoking is permanent.
Company owners and administrators with the Manage API tokens permission see a Company tokens tab listing every token in the company, with its owner and when it was last used, and can revoke any of them.
When a token stops working
Besides being revoked or expiring, a token stops working immediately when:
- its owner is deactivated or locked out, or leaves the company,
- the owner's employee record is no longer active,
- the company account is suspended,
- the company's API & Integrations feature is switched off.
The error code tells you which one happened. See Errors.
Keep tokens secret
- Never put a token in source code, a URL, a screenshot, a support ticket or a chat message.
- Store it in your platform's secret store or an environment variable, and read it at run time.
- Only send it to QHR over HTTPS in the
Authorizationheader. QHR never asks for it in a query string. - Use one token per integration, so you can revoke one without breaking the others.
- Never use a token in code that runs in a browser or a mobile app. Anyone could read it there. Call QHR from your server instead.
- If a token might have leaked, revoke it first, then create a replacement.