Authentication and security
One kind of credential: a personal access token made on the profile, sent in a header.
Send the token in the header
Authorization: Bearer cnp_…Only there. A token or access_token in the address or in the body is refused with 400 token_in_url and never used, because addresses end up in logs. The API sends no CORS headers and answers OPTIONS with 405: it is for servers and scripts, not for web pages on other sites, which would expose the token.
What a token can see and do
A token acts as the person who made it, looked up afresh on every call: their role, their properties and their status now, not when the token was made. Anything at a property outside their scope answers 404 not_found, exactly as something that does not exist, so a token cannot learn what it may not see.
| To | The token needs | The role needs |
|---|---|---|
GET /me | any valid token | nothing |
| Read anything else | any valid token | data.read |
POST /calculate | any valid token (it stores nothing) | data.read |
| Record values, readings and evidence | read and write | data.enter |
| Create tasks | read and write | tasks.assign |
A read-only token on a write answers 403 read_only_token; a role without the permission answers 403 forbidden.
When a token stops working
- It reaches the end date chosen when it was made, or goes 90 days unused.
- Its person revokes it on their profile, or their account is deactivated.
- A group administrator switches Apps and AI tools off in Settings: every call then answers
403 access_offuntil it is switched on again.
A missing, wrong, revoked or expired token answers 401 invalid_token. The phone app's sign-ins are not API tokens and are refused here too.
Keeping tokens safe
- Canoprise keeps only a hash of each token, once the ten minutes in which it can be copied are over.
- Give each integration its own token, named for it, with the shortest end date that works, and read-only unless it writes. The profile shows when each was last used.
- Every write is in the audit log under the person's name, marked "through the API" with the token's name.
- Calls are limited per token (see limits), and request bodies are capped.