API reference

Authorization checks

Ask whether a user may do something, filter queries to what they may see, and enforce at a proxy.

Call these from your backend with the app key or an M2M token. Each check is written to the app's decision log. The signed-in user's own checks and the gateway take the user's access token instead.

A resource is sent in one of three forms:

FormMeaning
"document"The resource type. Only app-wide roles count
"document:42"One instance. Roles held on it, directly or through relationships, count too
{ "type": "document", "key": "42", "attributes": { "amount": 1200 } }One instance with attributes for conditions. Sent attributes win over stored ones

The action plus the resource type make the permission: edit on document is document:edit. With no resource, action is used as a custom permission slug.

Check one action#

Check#

Answers one question for one user. When the permission requires verification or approval, pass the proof in the same call.

POST/v1/auth/:app_id/authz/checkApp key or M2M token
app_idstringrequired
Path. The app's ID.
user_idstring
The user's ID in the app. An unknown or missing user is denied with reason unknown_user.
actionstringrequired
The action, like edit, or a custom permission slug when resource is left out.
resourcestring or object
type, type:key, or an object with type, key and attributes.
contextobject
Values conditions read as context.*. Scute adds now, hour_utc and weekday_utc. Set impersonated: true when someone is signed in as the user.
challengestring
The token of a completed challenge, for a permission that requires verification. Spent only on a plain allow.
approvalstring
The ID of an approved access request, for a permission that requires approval. Spent only on a plain allow.
Requestbash
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/authz/check \  -H "Authorization: Bearer $SCUTE_APP_SECRET" \  -H "Content-Type: application/json" \  -d '{    "user_id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee",    "action": "edit",    "resource": "document:42"  }'
Response 200json
{  "decision": "allow",  "allowed": true,  "reason": "role_grant",  "permission": "document:edit",  "roles": ["editor"],  "explanation": "alice@example.com can edit document 42 (Editor role)."}
FieldMeaning
decisionallow, allow_with_step_up, allow_with_approval or deny
allowedtrue only for allow
reasonWhy. See the table below
permissionThe permission slug that was checked
rolesThe roles that grant it. A resource role is written type#role
pathFor a role held through relationships, the chain that gives it
conditionsThe conditions that held, for a conditional grant
step_upFor allow_with_step_up: method, ttl, authorizes_action, and error and detail when a sent challenge was not usable
approvalFor allow_with_approval: permission, resource, and error approval_not_usable when a sent approval was not usable
explanationOne sentence for logs and support
reasondecision
role_grantallow: an app-wide role grants it
resource_roleallow: a role held on the instance grants it
derived_roleallow: a role on the instance, held through a relationship, grants it
verifiedallow: the challenge sent with this call proved the step-up
verified_recentlyallow: the user verified for this permission within its verification_ttl
approvedallow: the approval sent with this call was spent
verification_requiredallow_with_step_up
approval_requiredallow_with_approval
unknown_userdeny: no user with that ID in this app
unknown_permissiondeny: the permission is not defined
permission_disableddeny: the permission is turned off for everyone
condition_faileddeny: every grant that could apply has a condition that does not hold
no_role_grants_permissiondeny: no role the user holds grants it
impersonatingdeny: the permission is blocked while someone is signed in as the user

Step up a check#

When the answer is allow_with_step_up, create a challenge for the user with purpose step_up and metadata.authorizes_action set to the permission in step_up.authorizes_action. When it is completed, repeat the check with its token:

Requestbash
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/authz/check \  -H "Authorization: Bearer $SCUTE_APP_SECRET" \  -H "Content-Type: application/json" \  -d '{    "user_id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee",    "action": "refund",    "resource": "invoice:881",    "challenge": "ch_zN4kP2qX9wT5aB3xY9QkLm7RsT2uVw8E"  }'
Response 200json
{  "decision": "allow",  "allowed": true,  "reason": "verified",  "permission": "invoice:refund",  "roles": ["billing_admin"],  "explanation": "alice@example.com can refund invoice 881 (Billing admin role), verified just now."}

Check a batch#

Up to 100 checks in one call. The policy is read once and each user's roles are looked up once.

POST/v1/auth/:app_id/authz/check-batchApp key or M2M token
checksarrayrequired
Up to 100 objects, each with user_id, action, resource, and optionally context, challenge and approval.
Requestbash
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/authz/check-batch \  -H "Authorization: Bearer $SCUTE_APP_SECRET" \  -H "Content-Type: application/json" \  -d '{    "checks": [      { "user_id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee", "action": "read", "resource": "document:42" },      { "user_id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee", "action": "delete", "resource": "document:42" }    ]  }'
Response 200json
{  "results": [    {      "decision": "allow",      "allowed": true,      "reason": "role_grant",      "permission": "document:read",      "roles": ["viewer"],      "explanation": "alice@example.com can read document 42 (Viewer role)."    },    {      "decision": "deny",      "allowed": false,      "reason": "no_role_grants_permission",      "permission": "document:delete",      "roles": [],      "explanation": "alice@example.com can't delete document 42: no role they hold allows it."    }  ]}

results is in the order of checks.

Errors#

Statuserror_codeWhen
422invalidaction is missing, or checks is not a list of objects
422batch_too_largeMore than 100 checks
422dry_run_requiredagent was sent without dry_run. Agent checks here are dashboard dry runs
403dry_run_not_alloweddry_run: true was sent. Dry runs are for the dashboard
403insufficient_scopeThe M2M token lacks the read scope
403app_not_in_scopeThe M2M token's app is not in this app's workspace or a workspace above it
404app_not_foundNo app with that ID

Filter a query#

Filter#

Answers "which rows of this type may the user act on" as a filter you apply to your own query, instead of checking rows one by one.

POST/v1/auth/:app_id/authz/filterApp key or M2M token
user_idstring
The user's ID in the app.
actionstringrequired
The action, like read.
resource_typestringrequired
The resource type, like document.
contextobject
Values conditions read as context.*.
Requestbash
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/authz/filter \  -H "Authorization: Bearer $SCUTE_APP_SECRET" \  -H "Content-Type: application/json" \  -d '{    "user_id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee",    "action": "read",    "resource_type": "document"  }'
Response 200json
{  "permission": "document:read",  "filter": {    "any": [      { "in": [{ "var": "resource.key" }, ["42", "43"]] },      { "lt": [{ "var": "resource.amount" }, 5000] }    ]  }}

filter is one of:

  • "all": every row. An app-wide role grants the permission without a condition.
  • "none": no row. Also the answer for an unknown user, an unknown or disabled permission, or an unknown resource type.
  • A condition tree over your own fields. resource.key is the row's key and resource.<field> its columns. User and context values are already filled in.

The answer can also carry step_up or approval when the permission requires them, and truncated: true when Scute stopped following relationships at its limit of 10,000 objects.

Read permissions#

List a user's permissions#

Everything the user can do in the app, and on one instance when resource is given.

GET/v1/auth/:app_id/authz/users/:user_id/permissionsApp key or M2M token
user_idstringrequired
Path. The user's ID in the app.
resourcestring
Query. One instance, as type:key.
Requestbash
curl "https://api.scute.io/v1/auth/$SCUTE_APP_ID/authz/users/0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee/permissions?resource=document:42" \  -H "Authorization: Bearer $SCUTE_APP_SECRET"
Response 200json
{  "roles": ["viewer"],  "resource": "document:42",  "resource_roles": ["owner"],  "permissions": ["document:delete", "document:edit", "document:read", "invoice:refund"],  "step_up": ["invoice:refund"],  "conditional": [    { "permission": "invoice:approve", "when": ["resource.amount < 5000"] }  ],  "approval": [],  "verified_until": { "invoice:refund": "2026-11-19T15:30:00.000Z" },  "user_id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee"}
FieldMeaning
rolesApp roles the user holds now, default roles included
resource_rolesRoles held on the instance, directly or through relationships
permissionsPermissions granted now
step_upOf those, the ones that require verification
approvalOf those, the ones that require approval
conditionalGrants whose condition depends on attributes Scute does not have yet, with the condition in words
verified_untilFor step-up permissions the user verified recently, when that proof ends

Returns 404 with error_code user_not_found for an unknown user.

List authorized users#

Who can do an action. With an instance, holders of a granting role on it are included.

GET/v1/auth/:app_id/authz/authorized-usersApp key or M2M token
actionstringrequired
Query. The action, like edit.
resourcestring
Query. type or type:key.
limitinteger
Query. Default 100, at most 200.
offsetinteger
Query. Default 0.
Requestbash
curl "https://api.scute.io/v1/auth/$SCUTE_APP_ID/authz/authorized-users?action=edit&resource=document:42" \  -H "Authorization: Bearer $SCUTE_APP_SECRET"
Response 200json
{  "permission": "document:edit",  "resource": "document:42",  "everyone": false,  "total": 2,  "users": [    { "id": "0193f900-aaaa-bbbb-cccc-eeeeeeeeeeee", "email": "alice@example.com" },    { "id": "0193f900-1111-2222-3333-444444444444", "email": "bob@example.com" }  ]}

everyone is true when a default role grants the permission without a condition: every user of the app can. conditions lists the roles that grant it only under a condition. Returns 422 with error_code invalid when action is missing or limit and offset are not whole numbers.

The signed-in user's own checks#

These calls take the user's access token in X-Authorization and answer only about that user. They are off until the app turns on client_checks in policy settings, since the answers name roles and permissions. They never spend a challenge: settle step-ups on your backend.

Check as the user#

POST/v1/auth/:app_id/authz/me/checkAccess token
actionstringrequired
The action or custom permission slug.
resourcestring or object
As on check.
contextobject
Values conditions read as context.*.
Requestbash
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/authz/me/check \  -H "X-Authorization: Bearer $ACCESS_TOKEN" \  -H "Content-Type: application/json" \  -d '{ "action": "edit", "resource": "document:42" }'

The response is a decision, as on check.

Check a batch as the user#

POST/v1/auth/:app_id/authz/me/check-batchAccess token

Takes checks, up to 100 objects with action, resource and context. Returns results.

List the user's permissions#

GET/v1/auth/:app_id/authz/me/permissionsAccess token

Takes an optional resource query parameter. Returns the same object as List a user's permissions.

Statuserror_codeWhen
401authentication_requiredNo access token, or a token of another app
403client_checks_disabledThe app has client_checks off
422invalidaction is missing, or checks is not a list of objects
422batch_too_largeMore than 100 checks

The user's own access requests (/v1/auth/:app_id/authz/me/requests and /me/reviews) are on Access requests.

Gateway enforcement#

One endpoint answers the auth subrequest of a proxy, so routes are enforced without app code. The app's route rules map a method and path to an action and resource. It is off until the app sets gateway: true in policy settings.

GET/v1/auth/:app_id/authz/gatewayAccess token

The endpoint accepts every method, and any path after /authz/gateway.

ProxyConfigurationOriginal request read from
Envoy ext_authz (HTTP)path_prefix /v1/auth/<app_id>/authz/gatewayThe method and the path after the prefix
Traefik ForwardAuthaddress https://api.scute.io/v1/auth/<app_id>/authz/gatewayX-Forwarded-Method, X-Forwarded-Uri
NGINX auth_requestProxy to https://api.scute.io/v1/auth/<app_id>/authz/gatewayX-Original-Method, X-Original-URI

The user is the Scute session in Authorization: Bearer, X-Authorization, or the sc-access-token cookie.

StatusMeaning
200Allowed. Headers X-Scute-User-Id, X-Scute-Decision and X-Scute-Permission are set for the upstream
401No valid session of this app (error_code authentication_required)
403Not allowed. The body is the decision. Step-up and approval answers are refused too, since a proxy can't complete them
403no_route: no rule matches. Returns 200 instead when the app sets gateway_unmatched to allow
403gateway_disabled: the gateway is off for this app
400invalid_path: the path has an encoded /, a . or .. segment, or invalid encoding

Rules are matched in order and the first match wins.