Skip to main content

Human approvals API

This page documents the 11 gateway endpoints tagged human approvals in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.

MethodPathSummary
GET/v1/approvals/listList approval requests
GET/v1/approvals/infoRead one approval request
POST/v1/approvals/linkDecide through a signed approval link
POST/v1/approvals/approveApprove a pending request
POST/v1/approvals/rejectReject a pending request
POST/v1/approvals/cancelWithdraw a pending request
GET/v1/approvals/policies/listList approval policies
GET/v1/approvals/policies/infoRead one approval policy
POST/v1/approvals/policies/newCreate an approval policy
POST/v1/approvals/policies/updateReplace an approval policy
POST/v1/approvals/policies/deleteDelete an approval policy

Endpoints​

GET /v1/approvals/list​

List approval requests

List the approval requests the caller raised or may decide, newest first, optionally by status. Any signed-in user or key may call it, and proxy admins and admin viewers see every request. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/human_approval#decide-a-request)

Parameters:

NameInTypeRequiredDescription
statusqueryenum: "pending", "approved", "rejected", "expired", "cancelled", "consumed" or nullNo

Example request:

curl -X GET "http://localhost:4000/v1/approvals/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The approval requests the caller may seeapplication/json ApprovalPage
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Your Spanway license does not include the 'human_approval' feature. Contact sales@spanway.ai to add it.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
approvalsarray of ApprovalViewYesApprovals

GET /v1/approvals/info​

Read one approval request

Read one approval request with each policy lane's progress and every decision so far. The caller must have raised it, be able to decide it, or be an admin, otherwise it answers 404. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/human_approval#decide-a-request)

Parameters:

NameInTypeRequiredDescription
approval_idquerystringYes

Example request:

curl -X GET "http://localhost:4000/v1/approvals/info?approval_id=approval_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The request with its lanes and decisionsapplication/json ApprovalView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Your Spanway license does not include the 'human_approval' feature. Contact sales@spanway.ai to add it.application/json ErrorDetail
404Approval request not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
approval_idstringYesApproval Id
statusenum: "pending", "approved", "rejected", "expired", "cancelled", "consumed"YesStatus
subjectToolCallSubject or WorkflowStepSubjectYesSubject
organization_idstring or nullYesOrganization Id
team_idstring or nullYesTeam Id
actor_user_idstring or nullYesActor User Id
workflow_run_idstring or nullYesWorkflow Run Id
expires_atstringYesExpires At
resolved_atstring or nullYesResolved At
created_atstringYesCreated At
lanesarray of LaneViewYesLanes
decisionsarray of DecisionViewYesDecisions

POST /v1/approvals/link​

Decide through a signed approval link

Record the approve or reject decision carried by a signed link from an approval email or chat message. The approver must be signed in, and the decision is recorded as theirs with the same checks as the Admin UI and written to the audit log. An expired link answers 410, so decide in the Admin UI instead. Docs (https://docs.spanway.ai/docs/proxy/human_approval#approval-links)

Request body (application/json, schema LinkDecisionRequest):

FieldTypeRequiredDescription
tokenstringYesToken
notestring or nullNoNote

Example request:

curl -X POST "http://localhost:4000/v1/approvals/link" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"token": "eyJ...",
"note": "Approved from the email link"
}'

Responses:

StatusDescriptionBody
200The request after the decisionapplication/json ApprovalView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404Approval request not foundapplication/json ErrorDetail
409The object already exists or is in a state that does not allow this changeapplication/json ErrorDetail
410This approval link has expired. Decide in the Admin UIapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail
503Approval links need SPANWAY_SALT_KEY or a master keyapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
approval_idstringYesApproval Id
statusenum: "pending", "approved", "rejected", "expired", "cancelled", "consumed"YesStatus
subjectToolCallSubject or WorkflowStepSubjectYesSubject
organization_idstring or nullYesOrganization Id
team_idstring or nullYesTeam Id
actor_user_idstring or nullYesActor User Id
workflow_run_idstring or nullYesWorkflow Run Id
expires_atstringYesExpires At
resolved_atstring or nullYesResolved At
created_atstringYesCreated At
lanesarray of LaneViewYesLanes
decisionsarray of DecisionViewYesDecisions

POST /v1/approvals/approve​

Approve a pending request

Approve a pending request in every policy lane where the caller is an approver at the lane's current level. Nobody may approve their own request. Once every lane has its required approvals the gated action goes ahead. The decision and note are written to the audit log. Docs (https://docs.spanway.ai/docs/proxy/human_approval#decide-a-request)

Request body (application/json, schema DecisionRequest):

FieldTypeRequiredDescription
approval_idstringYesApproval Id
notestring or nullNoNote

Example request:

curl -X POST "http://localhost:4000/v1/approvals/approve" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"approval_id": "5f0c...",
"note": "Checked the change ticket"
}'

Responses:

StatusDescriptionBody
200The request after the approvalapplication/json ApprovalView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404Approval request not foundapplication/json ErrorDetail
409The object already exists or is in a state that does not allow this changeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
approval_idstringYesApproval Id
statusenum: "pending", "approved", "rejected", "expired", "cancelled", "consumed"YesStatus
subjectToolCallSubject or WorkflowStepSubjectYesSubject
organization_idstring or nullYesOrganization Id
team_idstring or nullYesTeam Id
actor_user_idstring or nullYesActor User Id
workflow_run_idstring or nullYesWorkflow Run Id
expires_atstringYesExpires At
resolved_atstring or nullYesResolved At
created_atstringYesCreated At
lanesarray of LaneViewYesLanes
decisionsarray of DecisionViewYesDecisions

POST /v1/approvals/reject​

Reject a pending request

Reject a pending request as one of its approvers. One rejection in any lane rejects the whole request, so the gated action does not run. The decision and note are written to the audit log. Docs (https://docs.spanway.ai/docs/proxy/human_approval#decide-a-request)

Request body (application/json, schema DecisionRequest):

FieldTypeRequiredDescription
approval_idstringYesApproval Id
notestring or nullNoNote

Example request:

curl -X POST "http://localhost:4000/v1/approvals/reject" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"approval_id": "5f0c...",
"note": "No change ticket"
}'

Responses:

StatusDescriptionBody
200The request, now rejectedapplication/json ApprovalView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404Approval request not foundapplication/json ErrorDetail
409The object already exists or is in a state that does not allow this changeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
approval_idstringYesApproval Id
statusenum: "pending", "approved", "rejected", "expired", "cancelled", "consumed"YesStatus
subjectToolCallSubject or WorkflowStepSubjectYesSubject
organization_idstring or nullYesOrganization Id
team_idstring or nullYesTeam Id
actor_user_idstring or nullYesActor User Id
workflow_run_idstring or nullYesWorkflow Run Id
expires_atstringYesExpires At
resolved_atstring or nullYesResolved At
created_atstringYesCreated At
lanesarray of LaneViewYesLanes
decisionsarray of DecisionViewYesDecisions

POST /v1/approvals/cancel​

Withdraw a pending request

Withdraw a pending request, for example when the change it gates is no longer needed. Only its requester or a proxy admin may, the gated action does not run, and the note is written to the audit log. Docs (https://docs.spanway.ai/docs/proxy/human_approval#decide-a-request)

Request body (application/json, schema CancelRequest):

FieldTypeRequiredDescription
approval_idstringYesApproval Id
notestringYesNote

Example request:

curl -X POST "http://localhost:4000/v1/approvals/cancel" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"approval_id": "5f0c...",
"note": "Deploy postponed"
}'

Responses:

StatusDescriptionBody
200The request, now withdrawnapplication/json ApprovalView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404Approval request not foundapplication/json ErrorDetail
409Only a pending approval request can be cancelledapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
approval_idstringYesApproval Id
statusenum: "pending", "approved", "rejected", "expired", "cancelled", "consumed"YesStatus
subjectToolCallSubject or WorkflowStepSubjectYesSubject
organization_idstring or nullYesOrganization Id
team_idstring or nullYesTeam Id
actor_user_idstring or nullYesActor User Id
workflow_run_idstring or nullYesWorkflow Run Id
expires_atstringYesExpires At
resolved_atstring or nullYesResolved At
created_atstringYesCreated At
lanesarray of LaneViewYesLanes
decisionsarray of DecisionViewYesDecisions

GET /v1/approvals/policies/list​

List approval policies

List the approval policies the caller can see: global ones, their organizations' and their teams'. Proxy admins and admin viewers see every policy. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/human_approval#create-a-policy)

Example request:

curl -X GET "http://localhost:4000/v1/approvals/policies/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The approval policies in the caller's scopeapplication/json PolicyPage
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Your Spanway license does not include the 'human_approval' feature. Contact sales@spanway.ai to add it.application/json ErrorDetail
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
policiesarray of PolicyViewYesPolicies

GET /v1/approvals/policies/info​

Read one approval policy

Read one approval policy: what it gates, who approves, how many approvals it needs and how it escalates. A policy outside the caller's scope answers 404. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/human_approval#create-a-policy)

Parameters:

NameInTypeRequiredDescription
policy_idquerystringYes

Example request:

curl -X GET "http://localhost:4000/v1/approvals/policies/info?policy_id=policy_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The policyapplication/json PolicyView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403Your Spanway license does not include the 'human_approval' feature. Contact sales@spanway.ai to add it.application/json ErrorDetail
404Approval policy pol_01J... not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
namestringYesName
descriptionstring or nullNoDescription
scopeGlobalScope or OrgScope or TeamScopeYesScope
matchMcpToolMatch or McpWriteToolsMatch or McpFlaggedCallsMatch or WorkflowStepMatchYesMatch
approversarray of UserApprover or TeamAdminsApprover or TeamMembersApprover or ProxyAdminsApprover or RequesterTeamAdminsApproverYesApprovers
required_approvalsintegerNoRequired Approvals
timeout_secondsintegerNoTimeout Seconds
escalationarray of EscalationLevelNoEscalation
enabledbooleanNoEnabled
policy_idstringYesPolicy Id
authorityenum: "team_admin", "org_admin", "proxy_admin"YesAuthority
created_bystringYesCreated By
updated_bystringYesUpdated By
created_atstringYesCreated At
updated_atstringYesUpdated At

POST /v1/approvals/policies/new​

Create an approval policy

Create an approval policy, so matching agent or workflow actions wait for a person to approve them. Proxy admins may use any scope, org admins their organization and team admins their team, and view-only roles may not. Approvers must sit inside the policy's scope. The creation is written to the audit log. Docs (https://docs.spanway.ai/docs/proxy/human_approval#create-a-policy)

Request body (application/json, schema PolicyFields):

FieldTypeRequiredDescription
namestringYesName
descriptionstring or nullNoDescription
scopeGlobalScope or OrgScope or TeamScopeYesScope
matchMcpToolMatch or McpWriteToolsMatch or McpFlaggedCallsMatch or WorkflowStepMatchYesMatch
approversarray of UserApprover or TeamAdminsApprover or TeamMembersApprover or ProxyAdminsApprover or RequesterTeamAdminsApproverYesApprovers
required_approvalsintegerNoRequired Approvals
timeout_secondsintegerNoTimeout Seconds
escalationarray of EscalationLevelNoEscalation
enabledbooleanNoEnabled

Example request:

curl -X POST "http://localhost:4000/v1/approvals/policies/new" \
-H "Authorization: Bearer $SPANWAY_API_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"
}
]
}
]
}'

Responses:

StatusDescriptionBody
200The new policyapplication/json PolicyView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
422Approver user is outside the policy's team scopeapplication/json ErrorDetail
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
namestringYesName
descriptionstring or nullNoDescription
scopeGlobalScope or OrgScope or TeamScopeYesScope
matchMcpToolMatch or McpWriteToolsMatch or McpFlaggedCallsMatch or WorkflowStepMatchYesMatch
approversarray of UserApprover or TeamAdminsApprover or TeamMembersApprover or ProxyAdminsApprover or RequesterTeamAdminsApproverYesApprovers
required_approvalsintegerNoRequired Approvals
timeout_secondsintegerNoTimeout Seconds
escalationarray of EscalationLevelNoEscalation
enabledbooleanNoEnabled
policy_idstringYesPolicy Id
authorityenum: "team_admin", "org_admin", "proxy_admin"YesAuthority
created_bystringYesCreated By
updated_bystringYesUpdated By
created_atstringYesCreated At
updated_atstringYesUpdated At

POST /v1/approvals/policies/update​

Replace an approval policy

Replace every field of an approval policy. Only a caller with authority equal to or above the one that last saved it may change it, so a team admin cannot loosen a policy a proxy admin set. Requests already raised keep their lanes. The change is written to the audit log. Docs (https://docs.spanway.ai/docs/proxy/human_approval#create-a-policy)

Request body (application/json, schema PolicyUpdate):

FieldTypeRequiredDescription
policy_idstringYesPolicy Id
fieldsPolicyFieldsYes

Example request:

curl -X POST "http://localhost:4000/v1/approvals/policies/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"policy_id": "pol_01J...",
"fields": {
"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"
}
]
}
]
}
}'

Responses:

StatusDescriptionBody
200The policy as savedapplication/json PolicyView
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404Approval policy pol_01J... not foundapplication/json ErrorDetail
422Approver user is outside the policy's team scopeapplication/json ErrorDetail
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
namestringYesName
descriptionstring or nullNoDescription
scopeGlobalScope or OrgScope or TeamScopeYesScope
matchMcpToolMatch or McpWriteToolsMatch or McpFlaggedCallsMatch or WorkflowStepMatchYesMatch
approversarray of UserApprover or TeamAdminsApprover or TeamMembersApprover or ProxyAdminsApprover or RequesterTeamAdminsApproverYesApprovers
required_approvalsintegerNoRequired Approvals
timeout_secondsintegerNoTimeout Seconds
escalationarray of EscalationLevelNoEscalation
enabledbooleanNoEnabled
policy_idstringYesPolicy Id
authorityenum: "team_admin", "org_admin", "proxy_admin"YesAuthority
created_bystringYesCreated By
updated_bystringYesUpdated By
created_atstringYesCreated At
updated_atstringYesUpdated At

POST /v1/approvals/policies/delete​

Delete an approval policy

Delete an approval policy, so new matching actions no longer wait for approval. Only a caller with authority equal to or above the one that last saved it may delete it. Requests already raised keep the lanes they were created with. The deletion is written to the audit log. Docs (https://docs.spanway.ai/docs/proxy/human_approval#create-a-policy)

Request body (application/json, schema PolicyRef):

FieldTypeRequiredDescription
policy_idstringYesPolicy Id

Example request:

curl -X POST "http://localhost:4000/v1/approvals/policies/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"policy_id": "pol_01J..."
}'

Responses:

StatusDescriptionBody
200The id of the deleted policyapplication/json PolicyRef
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404Approval policy pol_01J... not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
policy_idstringYesPolicy Id