API reference

Policy

Read the compiled policy, keep it in git, track its versions, set authorization settings and read the decision log.

These endpoints work on the app's policy as a whole. They take the app key (or a workspace key above the app). Writes are kept in the version history as one row each.

Compiled policy#

Get the compiled policy#

The policy as the engine uses it: permissions with their flags, roles with their grants and conditions, resources with roles, relations and derivations, and route rules.

GET/v1/apps/:app_id/authz/policyApp key
Requestbash
curl https://api.scute.io/v1/apps/$SCUTE_APP_ID/authz/policy \  -H "Authorization: Bearer $SCUTE_APP_SECRET"
Response 200json
{  "app_id": "0193f8aa-2222-7333-8444-555555555555",  "version": 14,  "permissions": {    "document:read": {      "id": "0193f8ab-0000-7000-8000-000000000001",      "enabled": true,      "resource": "document",      "action": "read",      "requires_verification": false,      "verification_method": null,      "verification_ttl": null,      "requires_approval": false,      "autonomous_allowed": false    }  },  "roles": {    "viewer": {      "id": "0193f8ab-0000-7000-8000-000000000002",      "name": "Viewer",      "default": true,      "permissions": ["document:read"],      "conditions": {}    }  },  "resources": {    "document": { "id": "0193f8ab-0000-7000-8000-000000000003", "roles": {}, "relations": {}, "derivations": [] }  },  "routes": []}

Get a signed snapshot#

The compiled policy as a signed JWS, for decisions made locally by an SDK or an edge function. It is signed with the app's keys; verify it with the JWKS at the jwks path. The token is valid for one hour.

GET/v1/apps/:app_id/authz/snapshotApp key

The response carries an ETag of the policy version. Send it back in If-None-Match and an unchanged policy answers 304.

Requestbash
curl https://api.scute.io/v1/apps/$SCUTE_APP_ID/authz/snapshot \  -H "Authorization: Bearer $SCUTE_APP_SECRET"
Response 200json
{  "version": 14,  "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6...",  "expires_at": "2026-11-19T15:30:00Z",  "jwks": "/v1/auth/app_3mxZRrzWxhPZ08dXvqq6/jwks"}

Returns 409 with error_code keys_missing when the app has no signing keys yet.

Route rules#

Route rules map a request to an action and resource for gateway enforcement.

List route rules#

GET/v1/apps/:app_id/authz/routesApp key
Response 200json
{  "routes": [    { "method": "GET", "path": "/documents/:id", "action": "read", "resource_type": "document", "key_param": "id" },    { "method": "*", "path": "/admin/*", "action": "admin.access" }  ]}

Replace route rules#

Replaces the whole list. The order is the match order: the first match wins. Needs a plan with the authorization feature.

PUT/v1/apps/:app_id/authz/routesApp key
routesarrayrequired
The rules, in order.
routes[].methodstringrequired
GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, or * for any.
routes[].pathstringrequired
Segments, :name placeholders, and a trailing * for any rest of the path.
routes[].actionstringrequired
The action, or a custom permission slug when there is no resource_type.
routes[].resource_typestring
The resource type.
routes[].key_paramstring
The placeholder whose value is the instance key.
Requestbash
curl -X PUT https://api.scute.io/v1/apps/$SCUTE_APP_ID/authz/routes \  -H "Authorization: Bearer $SCUTE_APP_SECRET" \  -H "Content-Type: application/json" \  -d '{    "routes": [      { "method": "GET", "path": "/documents/:id", "action": "read", "resource_type": "document", "key_param": "id" }    ]  }'

Returns 200 with routes, or 422 invalid.

Policy as code#

Export the policy document#

The policy as a document you can keep in git.

GET/v1/apps/:app_id/authz/policy/documentApp key
Response 200json
{  "scute_policy": 1,  "resources": {    "document": {      "name": "Document",      "actions": ["edit", "read"],      "relations": { "parent": "folder" },      "roles": {        "editor": { "name": "Editor", "permissions": ["edit", "read"], "granted_via": [{ "relation": "parent", "role": "owner" }] }      }    }  },  "permissions": {    "invoice:refund": { "requires_verification": true, "verification_ttl": 300 },    "billing.export": { "custom": true, "name": "Export billing" }  },  "roles": {    "viewer": { "name": "Viewer", "default": true, "permissions": ["document:read"] }  },  "routes": []}

permissions lists only custom permissions and settings that differ from the defaults.

Import a policy document#

Applies a document to the app. It is a dry run by default: the answer lists the changes without making them.

POST/v1/apps/:app_id/authz/policy/importApp key
documentobjectrequired
A document in the export format.
dry_runboolean
Default true. Send false to apply.
pruneboolean
Default false. Also delete what the document does not have.
Requestbash
curl -X POST https://api.scute.io/v1/apps/$SCUTE_APP_ID/authz/policy/import \  -H "Authorization: Bearer $SCUTE_APP_SECRET" \  -H "Content-Type: application/json" \  -d @policy.json
Response 200json
{  "dry_run": true,  "prune": false,  "changes": [    { "op": "create", "kind": "role", "key": "auditor" }  ],  "applied": false}

An invalid document returns 422 with error_code invalid_document. Needs a plan with the authorization feature.

Promote from another app#

Copies another app's policy into this one, for example from a development app to production. The key must reach both apps. Same dry_run and prune as import, and the same response.

POST/v1/apps/:app_id/authz/policy/promoteApp key
from_app_idstringrequired
The source app's ID.
dry_runboolean
Default true.
pruneboolean
Default false.

Returns 404 app_not_found when the source app does not exist or the key can't reach it, and 422 invalid when it is the same app.

Versions#

List versions#

Newest first, without the documents.

GET/v1/apps/:app_id/authz/policy/versionsApp key
limitinteger
Query. Default 50, at most 200.
beforeinteger
Query. A version number. Pass the next value for the following page.
Response 200json
{  "current": 14,  "versions": [    {      "version": 14,      "from_version": 13,      "created_at": "2026-11-18T10:02:11.000Z",      "updated_at": "2026-11-18T10:02:11.000Z",      "actor": "alice@example.com",      "changes": [{ "op": "update", "kind": "role", "key": "editor" }],      "changes_total": 1    }  ],  "next": 13}

A row covers from_version to version: one write can move the version more than once.

Get a version#

GET/v1/apps/:app_id/authz/policy/versions/:versionApp key

Returns the version's fields plus document, the policy document at that version. 404 version_not_found when no document is kept for it.

Compare versions#

GET/v1/apps/:app_id/authz/policy/versions/diffApp key
fromintegerrequired
Query. The older version.
tointeger
Query. Default: the current version.
Response 200json
{  "from": 12,  "to": 14,  "changes": [    { "op": "create", "kind": "role", "key": "auditor" }  ]}

Settings#

Get settings#

GET/v1/apps/:app_id/authz/settingsApp key
Response 200json
{  "log_allow_rate": 0.1,  "log_retention_days": 30,  "client_checks": false,  "access_requests": false,  "gateway": false,  "gateway_unmatched": "deny",  "impersonation": false,  "impersonation_max_minutes": 60,  "impersonation_protected_roles": [],  "session_trust": false,  "session_trust_minutes": 15,  "export_event": "app.authz.decisions"}

Update settings#

Send only the fields to change.

PATCH/v1/apps/:app_id/authz/settingsApp key
log_allow_ratenumber
0 to 1. The share of plain allows from app-wide or object roles that the decision log keeps. Every other decision is kept. Default 0.1.
log_retention_daysinteger
1 to 400. Default 30.
client_checksboolean
Let signed-in users check their own permissions with /authz/me/*. Default false.
access_requestsboolean
Let signed-in users file access requests. Default false.
gatewayboolean
Turn on the gateway endpoint. Default false.
gateway_unmatchedstring
deny or allow, for a request no route rule matches. Default deny.
impersonationboolean
Allow signing in as a user for support. Default false.
impersonation_max_minutesinteger
5 to 240. Default 60.
impersonation_protected_rolesstring[]
Role slugs whose holders can't be signed in as.
session_trustboolean
Session trust for agents. Default false.
session_trust_minutesinteger
1 to 480. Default 15.
Requestbash
curl -X PATCH https://api.scute.io/v1/apps/$SCUTE_APP_ID/authz/settings \  -H "Authorization: Bearer $SCUTE_APP_SECRET" \  -H "Content-Type: application/json" \  -d '{ "client_checks": true, "access_requests": true }'

Returns 200 with all settings. A value out of range returns 422 invalid.

Decision log#

List decisions#

End-user decisions, newest first.

GET/v1/apps/:app_id/authz/decisionsApp key
user_idstring
Query. One user.
agent_idstring
Query. One agent.
task_idstring
Query. One agent task.
decisionstring
Query. allow, allow_with_step_up, allow_with_approval or deny.
permissionstring
Query. A permission slug.
resourcestring
Query. type or type:key.
reasonstring
Query. A reason, like condition_failed.
sincestring
Query. ISO 8601 time, inclusive.
untilstring
Query. ISO 8601 time, exclusive.
limitinteger
Query. Default 50, at most 200.
beforestring
Query. A decision ID. Pass next for the following page.
Requestbash
curl "https://api.scute.io/v1/apps/$SCUTE_APP_ID/authz/decisions?decision=deny&limit=20" \  -H "Authorization: Bearer $SCUTE_APP_SECRET"
Response 200json
{  "decisions": [    {      "id": "0193f9a0-1111-7222-8333-444444444444",      "at": "2026-11-19T14:02:11.120Z",      "kind": "end_user",      "user_id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee",      "permission": "document:delete",      "resource": "document:42",      "decision": "deny",      "reason": "no_role_grants_permission",      "roles": [],      "policy_version": 14,      "latency_ms": 1.204,      "explanation": "alice@example.com can't delete document 42: no role they hold allows it.",      "person": { "id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee", "email": "alice@example.com" },      "seq": 5821,      "row_hash": "9f2c..."    }  ],  "next": "0193f9a0-1111-7222-8333-444444444444"}

Rows are hash-chained: seq and row_hash let you check the log was not changed.

Verify the decision log#

Checks that the app's decision log chain is intact. Keep the returned head somewhere else to compare later.

GET/v1/apps/:app_id/authz/decisions/verifyApp key
fromstring
Query. ISO 8601 time.
tostring
Query. ISO 8601 time.
Response 200json
{  "ok": true,  "chain": "app:0193f8aa-2222-7333-8444-555555555555",  "checked": 5821,  "head": { "seq": 5821, "row_hash": "9f2c...", "at": "2026-11-19T14:02:11.120000Z" }}

A broken chain answers ok: false with first_break: id, seq, at and reason (changed or missing_or_moved).

Suggestions and backtests#

Nothing here changes the policy.

Get suggestions#

Proposed changes drawn from the decision log, such as a grant nobody used. Each carries a change you can backtest.

GET/v1/apps/:app_id/authz/policy/suggestionsApp key
daysinteger
Query. Default 30.
Response 200json
{  "suggestions": [    {      "kind": "unused_grant",      "title": "Billing admin can invoice:approve, and nobody holding it did in 30 days",      "evidence": { "role": "billing_admin", "permission": "invoice:approve", "holders": 3 },      "change": [{ "op": "revoke", "role": "billing_admin", "permission": "invoice:approve" }]    }  ]}

Backtest a change#

Replays recent decisions under the current policy and under the changed one, and reports the ones whose outcome differs. Roles are today's. Request context is not logged, so conditions that read it are judged without it.

POST/v1/apps/:app_id/authz/policy/backtestApp key
changearrayrequired
1 to 50 edits. op grant or revoke with role and permission, or op set with permission and one or more of enabled, requires_verification, requires_approval, requester_only.
daysinteger
Default 30, at most 90.
limitinteger
Decisions to replay. Default 2000, at most 5000.
Requestbash
curl -X POST https://api.scute.io/v1/apps/$SCUTE_APP_ID/authz/policy/backtest \  -H "Authorization: Bearer $SCUTE_APP_SECRET" \  -H "Content-Type: application/json" \  -d '{ "change": [{ "op": "set", "permission": "invoice:refund", "requires_verification": true }] }'

The answer has days, checked, changed, summary (counts per before -> after, where an outcome is allow, verify, approve or deny), people_affected, up to 50 examples and allow_sample_rate. An invalid change returns 422 invalid.