Developers

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.

ToThe token needsThe role needs
GET /meany valid tokennothing
Read anything elseany valid tokendata.read
POST /calculateany valid token (it stores nothing)data.read
Record values, readings and evidenceread and writedata.enter
Create tasksread and writetasks.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_off until 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.