Access requests API
This page documents the 6 gateway endpoints tagged access requests 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.
| Method | Path | Summary |
|---|---|---|
| POST | /access_request/new | Ask for a key, model access, a team seat, more budget or higher rate limits |
| GET | /access_request/list | List access requests |
| GET | /access_request/info | Get one access request |
| POST | /access_request/cancel | Withdraw your own access request |
| POST | /access_request/approve | Approve an access request and apply it |
| POST | /access_request/reject | Reject an access request |
Endpoints
POST /access_request/new
Ask for a key, model access, a team seat, more budget or higher rate limits
Raise a request for the calling user. The target key must be the caller's own and the target team one
the caller may ask about. A budget or rate limit raise can carry expires_after, after which the old limit
comes back. Alerting destinations get an access_request_created notice naming ids and amounts only.
Request body (application/json, schema NewAccessRequest):
| Field | Type | Required | Description |
|---|---|---|---|
payload | VirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayload | Yes | What is asked for, picked by request_type |
justification | string or null | No | Why the requester needs it |
Example request:
curl -X POST "http://localhost:4000/access_request/new" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"payload": "string"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json Spanway_AccessRequestTable |
| 400 | The key has no user, the request names both or neither of key and team_id, the budget or rate limit does not go up, or the caller is already in the team | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The license does not cover access requests, or the key, team, budget or rate limit is not one the caller may ask about | application/json ErrorDetail |
| 404 | The team named in the request does not exist | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Request Id |
request_type | enum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase" | Yes | Request Type |
status | enum: "pending", "applying", "approved", "rejected", "cancelled", "expired" | Yes | Status |
requester_user_id | string | Yes | Requester User Id |
team_id | string or null | No | Team Id |
target_key_token | string or null | No | Target Key Token |
payload | VirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayload | Yes | Payload |
justification | string or null | No | Justification |
reviewer_user_id | string or null | No | Reviewer User Id |
review_note | string or null | No | Review Note |
applied_result | AccessRequestAppliedResult or null | No | |
created_at | string or null | No | Created At |
updated_at | string or null | No | Updated At |
resolved_at | string or null | No | Resolved At |
expires_at | string or null | No | Expires At |
GET /access_request/list
List access requests
Requests the caller may see: their own, every request for proxy admins and admin viewers, plus requests targeting teams the caller administers.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
status | query | enum: "pending", "applying", "approved", "rejected", "cancelled", "expired" or null | No | |
request_type | query | enum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase" or null | No | |
team_id | query | string or null | No | |
requester_user_id | query | string or null | No | |
page | query | integer | No | |
page_size | query | integer | No |
Example request:
curl -X GET "http://localhost:4000/access_request/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json AccessRequestListResponse |
| 400 | The caller's key is not bound to a user | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
requests | array of Spanway_AccessRequestTable | Yes | Requests |
total | integer | Yes | Total |
page | integer | Yes | Page |
page_size | integer | Yes | Page Size |
total_pages | integer | Yes | Total Pages |
GET /access_request/info
Get one access request
One request, under the same visibility rule as /access_request/list.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
request_id | query | string | Yes |
Example request:
curl -X GET "http://localhost:4000/access_request/info?request_id=request_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json Spanway_AccessRequestTable |
| 400 | The caller's key is not bound to a user | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 404 | No request with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Request Id |
request_type | enum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase" | Yes | Request Type |
status | enum: "pending", "applying", "approved", "rejected", "cancelled", "expired" | Yes | Status |
requester_user_id | string | Yes | Requester User Id |
team_id | string or null | No | Team Id |
target_key_token | string or null | No | Target Key Token |
payload | VirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayload | Yes | Payload |
justification | string or null | No | Justification |
reviewer_user_id | string or null | No | Reviewer User Id |
review_note | string or null | No | Review Note |
applied_result | AccessRequestAppliedResult or null | No | |
created_at | string or null | No | Created At |
updated_at | string or null | No | Updated At |
resolved_at | string or null | No | Resolved At |
expires_at | string or null | No | Expires At |
POST /access_request/cancel
Withdraw your own access request
The requester withdraws a pending request.
Request body (application/json, schema CancelAccessRequest):
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Request Id |
Example request:
curl -X POST "http://localhost:4000/access_request/cancel" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_id": "req-6a1f"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json Spanway_AccessRequestTable |
| 400 | The request is no longer pending | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | Only the requester can cancel a request | application/json ErrorDetail |
| 404 | No request with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Request Id |
request_type | enum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase" | Yes | Request Type |
status | enum: "pending", "applying", "approved", "rejected", "cancelled", "expired" | Yes | Status |
requester_user_id | string | Yes | Requester User Id |
team_id | string or null | No | Team Id |
target_key_token | string or null | No | Target Key Token |
payload | VirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayload | Yes | Payload |
justification | string or null | No | Justification |
reviewer_user_id | string or null | No | Reviewer User Id |
review_note | string or null | No | Review Note |
applied_result | AccessRequestAppliedResult or null | No | |
created_at | string or null | No | Created At |
updated_at | string or null | No | Updated At |
resolved_at | string or null | No | Resolved At |
expires_at | string or null | No | Expires At |
POST /access_request/approve
Approve an access request and apply it
Apply the requested change as the approver, then mark the request approved. A change the management code refuses leaves the request pending and returns that refusal.
Request body (application/json, schema ReviewAccessRequest):
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Request Id |
review_note | string or null | No | Review Note |
Example request:
curl -X POST "http://localhost:4000/access_request/approve" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_id": "req-6a1f",
"review_note": "Approved for Q4 evals"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json Spanway_AccessRequestTable |
| 400 | The request is no longer pending, or the change was refused. A refused change keeps the status the management route answered with, for example 403 or 404, and the request stays pending | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not review this request, or is a team admin approving their own request | application/json ErrorDetail |
| 404 | No request with that id is visible to the caller | application/json ErrorDetail |
| 409 | Another approval of the same request is already running | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Request Id |
request_type | enum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase" | Yes | Request Type |
status | enum: "pending", "applying", "approved", "rejected", "cancelled", "expired" | Yes | Status |
requester_user_id | string | Yes | Requester User Id |
team_id | string or null | No | Team Id |
target_key_token | string or null | No | Target Key Token |
payload | VirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayload | Yes | Payload |
justification | string or null | No | Justification |
reviewer_user_id | string or null | No | Reviewer User Id |
review_note | string or null | No | Review Note |
applied_result | AccessRequestAppliedResult or null | No | |
created_at | string or null | No | Created At |
updated_at | string or null | No | Updated At |
resolved_at | string or null | No | Resolved At |
expires_at | string or null | No | Expires At |
POST /access_request/reject
Reject an access request
Decline a pending request without changing anything else.
Request body (application/json, schema ReviewAccessRequest):
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Request Id |
review_note | string or null | No | Review Note |
Example request:
curl -X POST "http://localhost:4000/access_request/reject" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_id": "req-6a1f",
"review_note": "Use the shared evals key instead"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json Spanway_AccessRequestTable |
| 400 | The request is no longer pending | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The caller may not review this request | application/json ErrorDetail |
| 404 | No request with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
request_id | string | Yes | Request Id |
request_type | enum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase" | Yes | Request Type |
status | enum: "pending", "applying", "approved", "rejected", "cancelled", "expired" | Yes | Status |
requester_user_id | string | Yes | Requester User Id |
team_id | string or null | No | Team Id |
target_key_token | string or null | No | Target Key Token |
payload | VirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayload | Yes | Payload |
justification | string or null | No | Justification |
reviewer_user_id | string or null | No | Reviewer User Id |
review_note | string or null | No | Review Note |
applied_result | AccessRequestAppliedResult or null | No | |
created_at | string or null | No | Created At |
updated_at | string or null | No | Updated At |
resolved_at | string or null | No | Resolved At |
expires_at | string or null | No | Expires At |