Human approval
Human approval lets an admin mark workflow runner steps as needing a person to sign off before they run, and mark MCP tools that no key may call until that sign-off exists. You write an approval policy that says what is gated and who may approve it. The gateway then enforces it at the one place every tool call passes through, so the same key cannot get around a policy by calling the tool through /mcp, the Responses API MCP bridge or A2A instead.
Human approval needs a Spanway enterprise license that includes the human_approval feature to create policies and to decide requests. Policies that already exist keep being enforced when the license lapses, because a safety control that switches itself off would let anyone wait for the license to expire. Pending requests still expire on time.
Scenario
A deployment agent can roll out to production, and the platform team is happy to let it prepare everything but wants two humans to say yes before it deploys. An approval policy on the team gates every workflow step that calls the deploy agent. When a run reaches that step the team admins get a request, two of them approve from the Approvals tab or from the link in the notification, and the step runs. If nobody answers within an hour the request escalates to the on-call lead, and if it still expires the step fails safely.
Steps
-
In the Admin UI open Workflow Runs under Agentic, switch to the Approvals tab, open Policies and click New policy. Fill the name, the scope, what needs approval, the approvers, how many approvals are needed, the time limit and the escalation levels. The same policy from the API looks like this.
curl -X POST http://localhost:4000/v1/approvals/policies/new \-H "Authorization: Bearer sk-admin-key" -H "Content-Type: application/json" \-d '{"name": "Production deploys","scope": {"kind": "team", "team_id": "platform"},"match": {"kind": "workflow_step", "target_ids": ["deploy-agent"]},"approvers": [{"kind": "team_admins", "team_id": "platform"}],"required_approvals": 2,"timeout_seconds": 3600,"escalation": [{"after_seconds": 900, "approvers": [{"kind": "user", "user_id": "oncall-lead"}]}]}' -
Start the workflow run as usual. When it reaches the deploy step, the step status becomes
awaiting_approvaland the approvers are notified. -
As an approver, open the Requests view on the Approvals tab, read what the request gates, and click approve or reject with an optional note. From the API list the pending requests and approve one.
curl "http://localhost:4000/v1/approvals/list?status=pending" -H "Authorization: Bearer sk-approver-key"curl -X POST http://localhost:4000/v1/approvals/approve \-H "Authorization: Bearer sk-approver-key" -H "Content-Type: application/json" \-d '{"approval_id": "5f0c...", "note": "Checked the change ticket"}' -
Back on the Runs tab, the step continues once the second approval lands, and the run drawer shows who approved.
Expected result
The policy call answers 200 with the policy and its id. The approve call answers 200 with the request, its lanes and the decisions so far.
{
"approval_id": "5f0c...",
"status": "approved",
"subject": {"kind": "workflow_step", "run_id": "run_01J...", "step_id": "stp_01J...", "step_key": "deploy", "target_id": "deploy-agent", "workflow_type": "production-deploy", "message_digest": "sha256:...", "message_preview": "Deploy checkout 2.4.0 to production"},
"team_id": "platform",
"workflow_run_id": "run_01J...",
"expires_at": "2026-11-21T11:00:00Z",
"lanes": [{"policy_id": "pol_01J...", "policy_name": "Production deploys", "status": "approved", "level": 0, "required_approvals": 2, "approvals": 2}],
"decisions": [{"policy_id": "pol_01J...", "approver_user_id": "alice", "decision": "approve", "via": "api", "note": "Checked the change ticket"}, {"policy_id": "pol_01J...", "approver_user_id": "bob", "decision": "approve", "via": "ui", "note": null}]
}
The gated step runs after the last required approval, and a single rejection in any lane fails the step with the rejection recorded in the run ledger.
What a policy gates
A policy matches one kind of action.
match.kind | Gates |
|---|---|
mcp_tool | Calls to the named tools on one MCP server, or every tool on it when tool_names is empty |
mcp_write_tools | Every tool on one MCP server that does not declare readOnlyHint: true |
mcp_flagged_calls | MCP tool calls that a guardrail flagged for a person to look at, on one server when server_id is set or on every server when it is left out. The write action alignment guardrail raises these flags |
workflow_step | Workflow runner steps sent to the listed target agents or in the listed workflow types, or every step when both lists are empty |
A tool policy never matches a workflow step, and a step policy never matches a tool call.
A flagged calls policy is how a guardrail hands a doubtful call to a person instead of blocking it. With it, an agent's email that looks aimed at the wrong person waits for a yes or no rather than failing outright. Without it, a flagged call is blocked with 403 flagged_call_blocked, so a flag is never quietly ignored. In the Admin UI choose Tool calls a guardrail flagged under What needs approval. The approver sees why the call was flagged in the request detail, under Why a guardrail sent this call here.
curl -X POST http://localhost:4000/v1/approvals/policies/new \
-H "Authorization: Bearer sk-admin-key" -H "Content-Type: application/json" \
-d '{
"name": "Doubtful agent writes",
"scope": {"kind": "global"},
"match": {"kind": "mcp_flagged_calls"},
"approvers": [{"kind": "requester_team_admins"}],
"timeout_seconds": 3600
}'
Create a policy
curl -X POST http://localhost:4000/v1/approvals/policies/new \
-H "Authorization: Bearer sk-admin-key" -H "Content-Type: application/json" \
-d '{
"name": "Production deploys",
"scope": {"kind": "team", "team_id": "platform"},
"match": {"kind": "workflow_step", "target_ids": ["deploy-agent"]},
"approvers": [{"kind": "team_admins", "team_id": "platform"}],
"required_approvals": 2,
"timeout_seconds": 3600,
"escalation": [{"after_seconds": 900, "approvers": [{"kind": "user", "user_id": "oncall-lead"}]}]
}'
| Field | Meaning |
|---|---|
scope | {"kind": "global"}, {"kind": "org", "organization_id": ...} or {"kind": "team", "team_id": ...}. A policy applies only to keys inside its scope |
approvers | Who may decide at the first level. user, team_admins, team_members, proxy_admins or requester_team_admins |
required_approvals | Distinct people who must approve, 1 to 3. Set it to 2 for a two-person rule |
timeout_seconds | How long a request waits, 60 seconds to 7 days. A request that times out is rejected, never approved |
escalation | Up to three later levels, each adding approvers after after_seconds. Earlier approvers can still decide |
enabled | Set to false to stop matching without deleting the policy |
Proxy admins may create policies in any scope, org admins in their organization and team admins in their team. On Spanway Cloud global policies are refused, so one tenant's policy never gates another tenant. Every approver must sit inside the policy's scope, so a team policy cannot name someone outside the team.
The policy remembers the authority that saved it. Only someone with the same or a higher authority can change or delete it, so a team admin cannot switch off a policy a proxy admin put on their team. When several policies match the same action, each one becomes its own lane and every lane must approve. A team admin can add a lane but never remove one an org or proxy admin added. More than five matching policies is treated as a configuration error and the action is refused.
What happens when an action is gated
A workflow step that a policy matches pauses before the agent is called. The step moves to awaiting_approval, the run moves to paused, and the step holds no lease, spends nothing and does not use up one of its attempts. A step that is waiting still counts against the run's max_parallel. When the request is approved the step goes back to pending and runs on the next tick with exactly the message that was approved. The request is marked consumed when the step starts. An approval covers the run's current attempt at the step, including its retries, and nothing more, so resuming a failed or cancelled run always asks again. Rejection, expiry or cancellation fails the step with approval_rejected, approval_expired or approval_cancelled, and the run fails like any other failed step. Cancelling the run or tripping the agent's kill switch cancels its pending requests. A request that was already approved keeps its approved status, and the step still asks again if the run is resumed.
A gated MCP tool call raises an approval request and is refused until a person approves it. Any caller, including a custom agent or a workflow step's agent, gets 403 with {"detail": {"error": "approval_required", "message": "...", "policies": ["..."], "approval_id": "5f0c..."}}, which carries the names of the matching policies and the approval_id. The agent's run waits at that point. Calling the same tool again with the same arguments before anyone decides returns the same approval_id instead of opening a second request. Once the request is approved, the caller retries the exact same call with the x-spanway-approval-id header set to that id and the tool runs once.
curl -X POST http://localhost:4000/mcp-rest/tools/call \
-H "Authorization: Bearer sk-agent-key" -H "x-spanway-approval-id: 5f0c..." \
-H "Content-Type: application/json" \
-d '{"server_id": "jira", "name": "create_issue", "arguments": {"title": "Rotate the deploy key"}}'
An approval covers only the key that raised it, that one tool and those exact arguments, and it can be spent once. Changing any argument, using another key or retrying a second time is refused with detail.error set to approval_grant_rejected. A rejected, expired or cancelled request is never spent, so the call stays refused. A key with 25 requests already waiting gets no new request until some are decided. The check runs after every other tool check and the guardrails, so a call a guardrail blocks never reaches it, and the approval is bound to the arguments the caller sent, not a guardrail's rewrite. If the gateway cannot read the policies the call is refused with 503 and detail.error set to approval_unavailable, never allowed.
The approver sees the tool name, the server and a preview of the arguments. For a workflow step the approver sees the message the step will send. Values under secret-looking keys such as api_key, token or password, bearer tokens, credentials in URLs and strings shaped like provider keys are masked before the preview is saved, and the preview is capped at 4,000 characters. The digest that binds the approval is computed from the unmasked arguments, so masking never lets a different call through.
Decide a request
curl "http://localhost:4000/v1/approvals/list?status=pending" -H "Authorization: Bearer sk-approver-key"
curl -X POST http://localhost:4000/v1/approvals/approve \
-H "Authorization: Bearer sk-approver-key" -H "Content-Type: application/json" \
-d '{"approval_id": "5f0c...", "note": "Checked the change ticket"}'
/v1/approvals/list shows the requests the caller raised or may decide, and admins see every request. It returns the newest 100 requests and has no paging, so filter by status to find older ones. Approving records your decision in every lane where you are an approver at the lane's current level. One rejection in any lane rejects the whole request.
Only a signed-in person can decide. Keys without a user, agent keys and the master key cannot, and the person whose key raised the request can never approve it, even as a proxy admin. On Spanway Cloud an approver must belong to the request's organization. A custom role with approvals.write opens the decision routes but does not make anyone an approver, because that authority always comes from the policy.
The requester or a proxy admin can withdraw a pending request with POST /v1/approvals/cancel and a required note.
Decisions and cancellations are audited as the person who made them, with the decision, the new status and the note. Creating, changing and deleting a policy is audited too, and the row keeps the whole policy before and after the change: what it matches, the approvers, how many approvals it needs, the time limit, the escalation levels and whether it is on. So if someone lowers required_approvals from 2 to 1 or swaps the approvers, the audit log shows exactly what changed and who did it.
What the gateway does by itself is audited too, with system:approvals as the actor and an approval_event field on the request's audit row. request_created is written when a workflow step or an MCP tool call raises a request, with the guardrail name and category of each flag when a guardrail sent the call, escalated when a lane moves to its next level, expired when the sweep closes a request at its deadline, consumed when a workflow step or an MCP tool call spends an approved request, links_sent when approval links go out, and cancelled when a pending request is cancelled because its run was cancelled (cause run_cancelled), its run failed (run_failed) or the agent's kill switch fired (kill_switch). A cancelled row is written only after the run change is saved, so if that change fails and is undone, the request stays pending and the log shows no cancellation. That holds for every path that fails a run, including a rejection, a withdrawal and the expiry sweep. The rows carry ids, tool names, policy names and levels only, never the step message or tool arguments. They need audit logging to be on.
Expiry and escalation run in a background sweep every 15 seconds that handles up to 100 requests per pass, so a request can close or escalate up to about 15 seconds after its deadline.
Approval links
When a request is raised, the gateway sends an approval_requested alert with an approve link and a reject link to the Slack, Microsoft Teams and webhook destinations in general_settings.alerting. With email in alerting, the users named directly as approvers at the first level also get the links by email. Links are only sent when PROXY_BASE_URL is set, and never on Spanway Cloud, where the alerting destinations belong to the operator.
A link opens the Approvals tab of the Admin UI, which asks you to sign in and confirm before anything is recorded, so a link preview or mail scanner that follows it decides nothing. The gateway then checks that the link is signed with a key derived from SPANWAY_SALT_KEY (or the master key), that it has not expired, and that you are an approver at the request's current level, exactly like a decision made in the UI. Holding a link without being an approver does nothing. A link works until the request expires and for 24 hours at most, and each approver can use it once, so a second click or the other link afterwards is refused with 409. An expired link answers 410 and a forged or changed one 403.
Decisions made through a link are recorded with via set to link and audited with the link id. A refused link click is audited as blocked with the reason, and sending the links writes a links_sent row with the channels used.
Admin UI
The Approvals tab of the Workflow Runs page under Agentic is open to every role that can see that page, so a team admin or a named approver decides from the same screen as a proxy admin. It has two views.
Requests lists the requests you raised or may decide, filtered by status, from the default of waiting for a decision to approved, rejected, expired, cancelled, used or all. Proxy admins and admin viewers see every request. Each request shows what it gates and every lane's progress, and a pending one can be approved or rejected with an optional note. Details opens who asked, when it expires, the masked tool arguments or step message and every decision so far. The requester and proxy admins can withdraw a pending request there with a reason, which is kept in the audit log, and the waiting step or tool call is then refused.
Policies lists the policies in your scope in plain words, such as "Workflow steps calling deployer" and "2 of Admins of team platform". New policy and Edit open a form for the name, the scope, what needs approval (workflow steps, named MCP tools or every write tool on a server), the approvers as a JSON list, how many approvals are needed, the time limit and up to three escalation levels. Delete asks for a confirmation. Proxy admins manage any policy, org admins the policies of their organization and team admins the policies of their team, and the form shows the gateway's refusal when you pick a scope you do not administer. A policy last saved by an org admin can only be changed by an org admin or a proxy admin, and the row says who that is. Read-only roles see the policies without any button. The form explains each approver kind and what the On switch does: a policy is on by default, and turning it off pauses it without deleting it, so matching actions run without waiting while requests already raised keep their lanes. Both views link to this page.
Without the human_approval feature, the tab says so.
Retention and data subject requests
Settled requests with their lanes and decisions are deleted after maximum_approval_request_retention_period when you set it in the compliance settings. A data subject export includes the requests a user raised, the decisions they made and the policies and request lanes that name them as an approver. Erasure replaces their user id with the pseudonym in requests, decisions, the policies they saved and every approver list that names them, clears decision notes and cancels their pending requests.
API
| Method | Path | Summary |
|---|---|---|
| GET | /v1/approvals/list | List approval requests |
| GET | /v1/approvals/info | Read one approval request |
| POST | /v1/approvals/link | Decide through a signed approval link |
| POST | /v1/approvals/approve | Approve a pending request |
| POST | /v1/approvals/reject | Reject a pending request |
| POST | /v1/approvals/cancel | Withdraw a pending request |
| GET | /v1/approvals/policies/list | List approval policies |
| GET | /v1/approvals/policies/info | Read one approval policy |
| POST | /v1/approvals/policies/new | Create an approval policy |
| POST | /v1/approvals/policies/update | Replace an approval policy |
| POST | /v1/approvals/policies/delete | Delete an approval policy |
Errors
| Status | What it means | Fix |
|---|---|---|
403 human_approval license message | The license lacks the human_approval feature. | Add the feature to the license or ask sales@spanway.ai. |
| 403 "You are not an approver for this request at its current level" | The caller is not in the lane's approver list, or the request escalated to other approvers. | Ask a listed approver, or wait for the escalation level that names you. |
| 403 "The requester cannot decide their own approval request" | The key that raised the request tried to approve it. | A different person must decide. |
| 403 "Your role can read approvals but not change them" | A view-only role tried to decide, cancel or change a policy. | Ask someone with a write role. |
| 403 "Only the requester or a proxy admin can cancel this request" | Someone other than the person who raised the request tried to withdraw it. | Ask the requester or a proxy admin. |
| 403 "You cannot manage approval policies in this scope" | An org or team admin picked a scope they do not administer. | Pick your own organization or team. |
| 403 "Only a team_admin or above can change this policy" or "... can delete this policy" | The policy was last saved by a higher authority than yours, for example a proxy admin. | Ask someone with that authority. |
403 approval_required on an MCP tool call | A policy matched the tool call, and a request was raised. The body carries approval_id and the policy names. | Wait for an approver, then retry the same call with the x-spanway-approval-id header. See approval_required. |
403 flagged_call_blocked on an MCP tool call | A guardrail flagged the call for a person, but no approval policy covers flagged calls for this key. The call was blocked rather than run unchecked. | Add a policy with match.kind set to mcp_flagged_calls, or set the guardrail to block. See flagged_call_blocked. |
403 approval_grant_rejected on an MCP tool call | The approval id does not cover this key, tool and arguments, or was already used. | Retry the exact call that was approved, or raise a new request. |
| 403 "This approval link is not valid" or 410 "This approval link has expired" | The signed link was altered or is past its lifetime. | Decide from the Approvals tab instead. |
| 404 "Approval request not found" | The id is wrong or the request is outside your scope. | Copy the id from the Requests view. |
404 "Approval policy <id> not found" | The policy id is wrong, was deleted or is outside your scope. | Copy the id from the Policies view. |
| 409 "The approval request is ..., not pending" or "You already decided this request" | The request was already decided, expired or cancelled, or you decided it once. | Nothing to do, read its state in the list. |
| 409 "Only a pending approval request can be cancelled" | The request was decided, expired or cancelled before the withdrawal. | Nothing to do. |
| 422 "Approver ... is outside the policy's ... scope" | A team policy named an approver from another team. | Name approvers inside the scope. |
| 422 "escalation after_seconds must strictly increase" or "every escalation level must start before timeout_seconds" | The escalation levels are out of order or start after the time limit. | Order the levels by after_seconds and keep each one below timeout_seconds. |
| 500 "DB not connected" | The gateway has no database, so approvals cannot be stored. | Connect the database. |
503 approval_unavailable on an MCP tool call | The gateway could not read the approval policies, or a guardrail flagged the call and the gateway has no approvals database, so it refused the call instead of letting it run. | Check the database, then retry. |
| 503 "Approval links need SPANWAY_SALT_KEY or a master key" | The gateway cannot sign links. | Set SPANWAY_SALT_KEY and restart. |
A workflow step that an approval stops fails with approval_rejected, approval_expired, approval_cancelled or approval_unavailable, which the error reference explains.
Logs
These lines come from the Spanway Proxy logger. None of them carries a step message, tool arguments or a link token.
| Level | Line | What it means | Action |
|---|---|---|---|
| WARNING | approval check for MCP tool <tool> failed: <error> | The gateway could not read the approval policies for a tool call, so the call was refused with 503. | Check the database. Repeated lines mean every gated tool is refused. |
| WARNING | approval gate for workflow step <step> failed: <error> | The same for a workflow step, which fails with approval_unavailable or retries if its retry policy allows. | Check the database. |
| WARNING | approval sweep failed: <error> | The background sweep could not expire or escalate requests on this pass. It tries again 15 seconds later. | None if it is rare. If it repeats, check the database. |
| INFO | approval sweep expired <n> and escalated <m> | The sweep closed n requests at their deadline and moved m lanes to their next level. | None. This is normal. |
| WARNING | approval <id> links were not sent: <error> | The approve and reject links for a new request could not be delivered. The request still waits in the Admin UI. | Check the alerting destinations and email settings. |
| WARNING | expired approval link opened by <user> | Someone opened a link after it expired and got 410. | None. They can decide in the Admin UI. |
| WARNING | invalid approval link opened by <user> | Someone opened a forged or changed link and got 403. | If it repeats for one user, look at where the link came from. |
Related
- Workflow Runs page describes the Approvals tab.
- Workflow runner covers the
awaiting_approvalstep state andapproval_unavailableretries. - MCP tool calls are the other thing a policy can gate.
- Write action alignment flags agent writes that do not match the user's request.
- Alerting and email deliver approval notifications.
- Audit logs keep every decision.
- Error reference and log reference list these errors and lines next to the rest of the gateway's.