A permission that requires approval answers allow_with_approval. The agent files an approval request for that exact call, a reviewer approves or denies it, and the agent passes the approval's id as approval on the next check. An agent can also file a plan: every step it means to take, for one review.
The agent files requests with its task token. The task must act for a person.
Request approval for one call#
/v1/auth/:app_id/agent/approvalsTask tokencurl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/agent/approvals \ -H "Authorization: Bearer $TASK_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "action": "refund", "resource": "invoice:42", "details": { "amount": 400 }, "reason": "Customer was charged twice" }'Scute first runs the check, then answers by what it says:
| Check says | Answer |
|---|---|
| allow_with_approval | 201 with the request: id, status: "pending", permission, resource, details, expires_at, say |
| allow | 200 with status: "not_needed" and the decision |
| allow_with_step_up | 200 with status: "verify_first": verify the person first |
| deny | 403 with not_permitted |
A pending request expires after 72 hours.
Wait for the answer#
/v1/auth/:app_id/agent/approvals/:idTask token{ "id": "REQUEST_ID", "status": "approved", "permission": "invoice:refund", "resource": "invoice:42", "details": { "amount": 400 }, "expires_at": "2026-11-19T11:05:00Z", "say": "It's approved."}status is pending, approved, denied, used, or another closed state. A denied request's say includes the reviewer's note.
Spend the approval#
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/agent/check \ -H "Authorization: Bearer $TASK_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "action": "refund", "resource": "invoice:42", "details": { "amount": 400 }, "approval": "REQUEST_ID" }'An approval is spent once, by the person the task acts for, on the same permission, object and details, within 1 hour of being approved. A check that answers allow uses it up; it then reads used.
Approve a plan#
/v1/auth/:app_id/agent/plansTask tokenScute checks every step now, without using anything up:
- A step that would be denied fails the whole plan: 403 with step_not_permitted, naming the step.
- A step that needs approval goes to the reviewer.
- A step that needs verification is marked verify; the person verifies when the agent runs it.
- When no step needs approval, the answer is 200 with status: "not_needed" and the steps.
Otherwise Scute answers 201 with the plan request, its steps (each with permission, resource, details and needs: approval, verify or none) and a say line.
/v1/auth/:app_id/agent/plans/:idTask tokenThe plan's status, with each step's used once it has been run.
Run an approved plan#
Pass the plan's id as plan on each step's check, with the step's exact resource and details. The step that matches supplies the approval. Plan steps are exact and used once; they never carry over through session trust.
curl -X POST https://api.scute.io/v1/auth/$SCUTE_APP_ID/agent/check \ -H "Authorization: Bearer $TASK_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "action": "refund", "resource": "invoice:42", "details": { "amount": 400 }, "plan": "PLAN_ID" }'Who reviews#
Reviewers are the app's users whose roles grant the custom permission access_requests.review, or your backend with the app key. Nobody reviews their own request.
/v1/apps/:app_id/authz/requestsApp keyLists requests. Query: status, user_id, agent (a slug), limit, before.
/v1/apps/:app_id/authz/requests/:id/approveApp key/v1/apps/:app_id/authz/requests/:id/denyApp keyBoth take note and optionally reviewer_id (the app user reviewing). A signed-in reviewer uses GET /v1/auth/:app_id/authz/me/reviews and POST /v1/auth/:app_id/authz/me/reviews/:id/approve or /deny with their session token.
Errors#
| Status | error_code | When |
|---|---|---|
| 409 | needs_human | The task acts for nobody |
| 403 | not_permitted | The check denies the call |
| 403 | step_not_permitted | A plan step would be denied |
| 422 | invalid | No action, or steps is not a list of 1 to 20 |
| 404 | not_found | The approval or plan is not this task's |