Sign in

Authentication and scopes

View as Markdown

Keys

Every request carries your business's API key:

Text
Authorization: Bearer ocost_sk_<id>_<secret>
  • Made under Settings › API by the owner or the accountant, and shown once. Ocost keeps only a fingerprint: revoke and replace a lost key.
  • The start, ocost_sk_<id>_, isn't secret. Settings lists keys by it, with their scopes and last use; secret scanners spot the ocost_sk_ prefix in a leak.
  • One business per key, and never people's papers (pay slips, payroll, health). One Odoo company is one business with its own key.
  • Revoking refuses the very next request. A key may also expire on a date.
  • At most 10 live keys per business. To rotate, make a new key, switch to it, revoke the old one.
  • Server only: never in a browser, a mobile app or a log.

Scopes

Settings › API ticks all three by default.

ScopeRoutes
documents:writePOST /public/v1/files, DELETE /public/v1/files/{file_id}
documents:readGET /public/v1/files, GET /public/v1/files/{file_id}, GET /public/v1/files/{file_id}/content, GET /public/v1/files/{file_id}/document, GET /public/v1/documents/{document_id}
search:readGET /public/v1/search

Refusals

AnswerWhen
401 urn:ocost:key:invalidNo key, or a malformed, wrong, revoked or expired one, or a deleted business's. Always the same answer.
403 urn:ocost:key:scopeThe key lacks the route's scope.
429 urn:ocost:key:rateToo many requests, or too many wrong keys from one address. Wait Retry-After seconds.
400An Ocost-View… header, which only Ocost's web app sends.

Example

curl -sS https://api.ocost.io/public/v1/files \
  -H "Authorization: Bearer $OCOST_KEY"