Authentication
The two credential types the API accepts, how API keys are bound and scoped, and what an auth failure looks like.
The Acreum API accepts two kinds of credential at the same Authorization header.
Downstream behaviour never depends on which one was used.
| Credential | Use case | Format |
|---|---|---|
| Session token | Browser sessions in the Acreum app | eyJ… (JWT) |
| API key | Back-office integrations, agents, scripts, CI | live_<32-char secret> |
Keys issued to Acreum staff start with live_si_ and are not issuable by customers.
The header
Every request to a /v1/* endpoint must carry:
Authorization: Bearer <token>The server inspects the prefix of the token. Tokens that start with live_ resolve as API
keys; everything else is verified as a session JWT (on /v1/portal/*, as an investor-portal
session instead, and an API key is refused there before it is looked up). If neither
verification succeeds you get 401 UNAUTHORIZED.
A small set of routes are public and need no credential, among them GET /health,
GET /metrics, GET /v1/ping, the OpenAPI surface at /api, /api-json and /docs,
the investor sign-in branding at GET /v1/public/portal-branding/{slug}, and the inbound
webhook receivers.
Who am I
GET /v1/me (scope auth:read) describes the credential that made the call: its kind
(user or api_key), org_id, the legal entity it is bound to, its scopes, the
member's role (null for an API key), and an org object with the organization's
id, name and time_zone (an IANA zone such as America/New_York). Use time_zone
to compute the organization's "today" the way the API does; see
Conventions.
API keys
Anatomy
live_<32 random base62 chars>
└─┬─┘
└── stored prefix (12 chars, used for lookup)- The full secret is shown exactly once, at creation. There is no recovery.
- The server stores only an argon2id hash plus the prefix.
- A key belongs to one organization and may optionally be bound to a single legal entity. An entity-bound key cannot read or write resources in any other legal entity of the same organization.
- Every key carries a list of scopes. Requests are checked against them per endpoint.
Issuing, rotating and revoking keys is covered in API keys.
Key constraints
| Constraint | Behaviour |
|---|---|
| Org binding | A key cannot reach resources in another organization. The server answers 404 NOT_FOUND rather than 403, so it never confirms that another org exists. |
| Legal-entity binding | If the key has legal_entity_id set, requests against any other legal entity return 403 LEGAL_ENTITY_NOT_IN_SCOPE. |
| Legacy routes | API keys are valid only against /v1/*. The few pre-v1 routes that remain return 403 API_KEYS_LEGACY_UNSUPPORTED. |
| Expiry | A key with expires_at in the past returns 401 API_KEY_EXPIRED. |
| Revocation | A revoked key returns 401 API_KEY_REVOKED on the next request. There is no soft revoke. |
Scopes
Every endpoint declares the scopes it requires. A request whose credential (an API key or
a session) lacks a required scope returns 403 INSUFFICIENT_SCOPE; the detail names the
missing scope, and errors[] carries one { "field": "scopes", "code": "SCOPE_MISSING" }
entry per missing scope.
Scopes are <namespace>:<action> strings. Most namespaces have a read / write pair:
:read covers GET and read-only actions, :write covers POST, PATCH, PUT,
DELETE and state-changing actions such as POST /v1/documents/{id}/post. A few
namespaces add capability scopes, for example documents:approve,
accounting:periods_override or loans:activate.
Two wildcards are honoured:
<namespace>:*matches every scope in one namespace.documents:*coversdocuments:read,documents:write,documents:approveanddocuments:delete.*matches every scope except the staff-only ones. It is what an owner's or admin's session carries; do not request it on customer keys.
The complete catalog, grouped as the API-key dialog shows it, is on the
Scopes page. GET /v1/permissions/scopes returns the same catalog
as JSON; it needs admin:keys or admin:roles.
When you issue a key, request the minimum scopes the integration needs. A reporting
integration should hold reports:read only; a poller that watches for new invoices should
hold documents:read only. Some writes need reads from other modules to be useful (a
document form looks up accounts, parties, items and tax rates); the key dialog flags those
and offers to add them.
Session tokens (the Acreum app)
The Acreum app signs users in through Supabase Auth and sends the user's JWT to the API on every request. The user's role in the organization (owner, admin, accountant, clerk, viewer or facility) and any custom security groups determine the scope set the token carries; this is invisible to API consumers and not part of the public contract.
The API verifies a session token locally against the auth provider's published signing keys rather than calling the auth server on every request. Signing out therefore does not invalidate a token that was already issued; it stays valid until it expires. Organization membership is still checked against the database, so removing a member from the organization takes effect within about a minute.
If you are building inside the app (an internal tool that acts as the signed-in user), use the session token. If you are building outside it (a back-office integration, an agent, a script), use an API key.
Impersonation tokens (Acreum staff only)
Acreum support engineers can mint a short-lived impersonation token to reproduce a
customer's experience under their own identity. It is a normal API key (live_si_…)
bound to the customer organization, with caller-chosen scopes (default: read-only across
all modules) and an expiry of at most 60 minutes. These tokens are not customer-issuable,
never appear in GET /v1/api-keys, and every request made under one is audited. The
Organization → Impersonations page in the app lists them.
Tenant isolation
Every credential resolves to one organization. Row-level security prevents any query from
crossing that boundary: a credential for org A cannot read, list or mutate anything in
org B regardless of the endpoint, path parameter or body. Crossing attempts return
404 NOT_FOUND.
If you operate against multiple Acreum organizations, for example as a service provider managing several clients, issue one key per organization and route requests by org context in your application.
What an auth failure looks like
| Situation | Status | code |
|---|---|---|
| No credential | 401 | UNAUTHORIZED |
| Bad JWT signature / expired JWT | 401 | UNAUTHORIZED |
| Unknown API key | 401 | UNAUTHORIZED |
| Revoked API key | 401 | API_KEY_REVOKED |
| Expired API key | 401 | API_KEY_EXPIRED |
| Right key, wrong scope | 403 | INSUFFICIENT_SCOPE |
| Key bound to entity A, request targets entity B | 403 | LEGAL_ENTITY_NOT_IN_SCOPE |
| API key against a pre-v1 route | 403 | API_KEYS_LEGACY_UNSUPPORTED |
Full definitions: Error code catalog.
Operational guidance
- Treat keys as secrets. Never commit them, log them, or ship them in browser bundles. The browser uses session tokens, not API keys.
- Rotate on schedule. Calendar a rotation every 90 days at minimum.
POST /v1/api-keys/{id}/rotatemakes it a one-call operation. - Revoke on suspicion. A revoked key stops working on the next request.
- One integration, one key. Separate keys make audit trails, rate limits and rotation tractable.
- Bind to a legal entity when you can. A reporting integration that only needs one entity's data should hold a key bound to it. Misuse becomes structurally impossible instead of merely against policy.
- Watch
last_used_atinGET /v1/api-keys. A key with no recent activity is probably safe to revoke.