Protocol & API
Everything the server serves and the client sends is a small, self-describing JSON envelope. This page is the practical tour; the specification is the exhaustive normative contract, and the machine-readable JSON Schemas (in the schema/ directory) validate every payload.
Every envelope carries two fields:
wire_version— an integer, currently1. It governs resolution semantics (see Versioning).kind— names the payload shape.
Envelope kinds
kind | What it is |
|---|---|
matrix | the editable matrix snapshot (roles, features-with-defaults, overrides) + editor extras |
me | the caller's own resolved feature → {level, can_read, can_write} |
policy | one /check/ decision — the resolved cell + an allowed boolean |
policy-batch | a batch of /check/ decisions — positional results |
role / roles | a single role / the role collection |
feature / features | a single feature / the feature collection |
group / groups | a single group / the group collection |
org / orgs | a single organization / the org collection (the multi-tenancy picker source) |
assignment / assignments | one role assignment / the assignment collection — the only way a subject gets a role |
member / members | one member / an org's member registry, the subject-picker source |
app / apps | one registered OIDC client / an org's clients |
overrides | the overrides layer alone, for persistence and round-trip |
audit | a page of the append-only change log |
error | the standard error envelope (code + detail) |
The me, policy, and policy-batch envelopes also carry an optional org field (the active tenant's slug). It's additive — a v1 reader that ignores it resolves identically — so it doesn't touch the byte-hashed matrix snapshot. See Organizations.
Access levels on the wire
Levels are the plain integers 0..3 (NONE, VIEW, PARTIAL, FULL). A grid cell is an integer; there's no richer per-cell object. The mapping is fixed for the wire major version.
The management API
The adapters serve the same routes under a host-chosen prefix (shown here as /permissions/). Every response is a versioned envelope and validates against the authoritative JSON Schemas; failures return the error envelope.
In a multi-tenant deployment these paths are unchanged — which org a response carries is resolved server-side (from the OIDC claim, or the X-Archenstack-Org header for a cross-org admin), never encoded as a /orgs/{org}/… path prefix.
| Method + path | Purpose |
|---|---|
GET /permissions/matrix/ | the editable matrix (snapshot + editor conveniences) |
PUT /permissions/matrix/ | bulk cell-override edits — cell-only, delta semantics, validated against the lock-out invariant |
POST /permissions/matrix/reset/ | clear the whole override layer back to defaults |
GET/POST /permissions/roles/ · …/features/ · …/groups/ | list / create |
GET/PATCH /permissions/roles/{slug}/ · …/features/{key}/ · …/groups/{slug}/ | read / update / deactivate |
POST /permissions/roles/reorder/ · …/features/reorder/ · …/groups/reorder/ | reorder |
GET/POST /permissions/assignments/ | list / grant — the only way a subject gets a role |
GET/PATCH/DELETE /permissions/assignments/{subject}/ | read / reassign / revoke, validated against the lock-out invariant |
GET /permissions/members/ | one org's member registry — the subject-picker source |
GET/POST /permissions/orgs/ | list / provision an organization (platform authority) |
GET/PATCH /permissions/orgs/{slug}/ | read / edit an organization (platform authority) |
GET/POST /permissions/orgs/{slug}/apps/ | that org's registered OIDC clients |
GET /permissions/me/ | the caller's own resolved permission map |
POST /permissions/check/ | resolve a feature (+ optional object) — single or batch |
GET /permissions/audit/ | the append-only change log, newest first, paginated |
Management routes require the caller to resolve rbac.manage at FULL — a read of the editable matrix is as sensitive as a write. /me/ and /check/ require only authentication. Both also require the caller to have an assigned role: a role-less caller gets a not_found error, never an invalid body — the host must assign every authenticated user a role.
The /check/ endpoint
POST /permissions/check/ asks the server to decide access — the only place object-level (scoped) access is ever resolved.
Single — send a feature and, optionally, an object:
{ "feature": "records.edit", "object": { "id": 42, "owner": "manager" } }
{
"wire_version": 1,
"kind": "policy",
"role": "manager",
"permissions": { "records.edit": { "level": 2, "scope": { "atom": "own_record" } } },
"allowed": true
}
With an object, allowed is the object-level write decision (the scope is evaluated server-side); without one, it's feature-level read eligibility (level >= VIEW). Reads are never scoped.
Batch check
A PARTIAL-scoped list would otherwise cost one request per row (an N+1). The batch form resolves a whole list in one round-trip — send a checks array:
{ "checks": [
{ "feature": "records.edit", "object": { "id": 1, "owner": "manager" } },
{ "feature": "records.edit", "object": { "id": 2, "owner": "staff" } }
] }
{
"wire_version": 1,
"kind": "policy-batch",
"role": "manager",
"permissions": { "records.edit": { "level": 2, "scope": { "atom": "own_record" } } },
"results": [true, false]
}
The response is positional: results[i] is the decision for checks[i], and results.length == checks.length. Each distinct feature's resolved cell appears once under permissions. Here's how it behaves:
- An unknown feature is denied per item (fail closed) — it doesn't fail the whole batch.
- A structurally malformed item, or a body carrying both
featureandchecks, is rejected with avalidationerror. - The batch is bounded by a server limit (default 200; configurable per deployment). An over-limit batch is rejected with
validation.
policy-batch is a new envelope kind a client only receives when it opts into the batch request, so adding it didn't bump wire_version. Old clients that never send checks never see it.
Canonical JSON
Wherever bytes must match across languages — golden fixtures, signatures, comparisons — Archenstack uses a deterministic canonical JSON: UTF-8, keys sorted by UTF-16 code unit, compact separators, integer levels, lowercase \u00XX control escapes. Every implementation reproduces it byte-for-byte. The exact rules are in the specification.
Errors
Failures return the error envelope — a closed code plus a human detail:
{ "wire_version": 1, "kind": "error", "code": "lockout", "detail": "…", "field": "role" }
Common codes: validation, not_found, duplicate_key, lockout, invalid_slug, and unknown_org (a caller named a tenant that doesn't exist — fail closed). The full taxonomy is in the specification.
See also
- Specification — the exhaustive normative contract and JSON Schemas.
- Resolution, scopes & the authorizer — what the levels and scopes in these payloads mean.
- Versioning — what may change additively vs. what bumps
wire_version.