Skip to main content

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.

MethodPathSummary
POST/access_request/newAsk for a key, model access, a team seat, more budget or higher rate limits
GET/access_request/listList access requests
GET/access_request/infoGet one access request
POST/access_request/cancelWithdraw your own access request
POST/access_request/approveApprove an access request and apply it
POST/access_request/rejectReject 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):

FieldTypeRequiredDescription
payloadVirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayloadYesWhat is asked for, picked by request_type
justificationstring or nullNoWhy 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:

StatusDescriptionBody
200Successful Responseapplication/json Spanway_AccessRequestTable
400The 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 teamapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The license does not cover access requests, or the key, team, budget or rate limit is not one the caller may ask aboutapplication/json ErrorDetail
404The team named in the request does not existapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
request_idstringYesRequest Id
request_typeenum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase"YesRequest Type
statusenum: "pending", "applying", "approved", "rejected", "cancelled", "expired"YesStatus
requester_user_idstringYesRequester User Id
team_idstring or nullNoTeam Id
target_key_tokenstring or nullNoTarget Key Token
payloadVirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayloadYesPayload
justificationstring or nullNoJustification
reviewer_user_idstring or nullNoReviewer User Id
review_notestring or nullNoReview Note
applied_resultAccessRequestAppliedResult or nullNo
created_atstring or nullNoCreated At
updated_atstring or nullNoUpdated At
resolved_atstring or nullNoResolved At
expires_atstring or nullNoExpires 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:

NameInTypeRequiredDescription
statusqueryenum: "pending", "applying", "approved", "rejected", "cancelled", "expired" or nullNo
request_typequeryenum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase" or nullNo
team_idquerystring or nullNo
requester_user_idquerystring or nullNo
pagequeryintegerNo
page_sizequeryintegerNo

Example request:

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

Responses:

StatusDescriptionBody
200Successful Responseapplication/json AccessRequestListResponse
400The caller's key is not bound to a userapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
requestsarray of Spanway_AccessRequestTableYesRequests
totalintegerYesTotal
pageintegerYesPage
page_sizeintegerYesPage Size
total_pagesintegerYesTotal Pages

GET /access_request/info​

Get one access request

One request, under the same visibility rule as /access_request/list.

Parameters:

NameInTypeRequiredDescription
request_idquerystringYes

Example request:

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

Responses:

StatusDescriptionBody
200Successful Responseapplication/json Spanway_AccessRequestTable
400The caller's key is not bound to a userapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No request with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
request_idstringYesRequest Id
request_typeenum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase"YesRequest Type
statusenum: "pending", "applying", "approved", "rejected", "cancelled", "expired"YesStatus
requester_user_idstringYesRequester User Id
team_idstring or nullNoTeam Id
target_key_tokenstring or nullNoTarget Key Token
payloadVirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayloadYesPayload
justificationstring or nullNoJustification
reviewer_user_idstring or nullNoReviewer User Id
review_notestring or nullNoReview Note
applied_resultAccessRequestAppliedResult or nullNo
created_atstring or nullNoCreated At
updated_atstring or nullNoUpdated At
resolved_atstring or nullNoResolved At
expires_atstring or nullNoExpires At

POST /access_request/cancel​

Withdraw your own access request

The requester withdraws a pending request.

Request body (application/json, schema CancelAccessRequest):

FieldTypeRequiredDescription
request_idstringYesRequest 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:

StatusDescriptionBody
200Successful Responseapplication/json Spanway_AccessRequestTable
400The request is no longer pendingapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403Only the requester can cancel a requestapplication/json ErrorDetail
404No request with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
request_idstringYesRequest Id
request_typeenum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase"YesRequest Type
statusenum: "pending", "applying", "approved", "rejected", "cancelled", "expired"YesStatus
requester_user_idstringYesRequester User Id
team_idstring or nullNoTeam Id
target_key_tokenstring or nullNoTarget Key Token
payloadVirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayloadYesPayload
justificationstring or nullNoJustification
reviewer_user_idstring or nullNoReviewer User Id
review_notestring or nullNoReview Note
applied_resultAccessRequestAppliedResult or nullNo
created_atstring or nullNoCreated At
updated_atstring or nullNoUpdated At
resolved_atstring or nullNoResolved At
expires_atstring or nullNoExpires 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):

FieldTypeRequiredDescription
request_idstringYesRequest Id
review_notestring or nullNoReview 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:

StatusDescriptionBody
200Successful Responseapplication/json Spanway_AccessRequestTable
400The 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 pendingapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not review this request, or is a team admin approving their own requestapplication/json ErrorDetail
404No request with that id is visible to the callerapplication/json ErrorDetail
409Another approval of the same request is already runningapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
request_idstringYesRequest Id
request_typeenum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase"YesRequest Type
statusenum: "pending", "applying", "approved", "rejected", "cancelled", "expired"YesStatus
requester_user_idstringYesRequester User Id
team_idstring or nullNoTeam Id
target_key_tokenstring or nullNoTarget Key Token
payloadVirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayloadYesPayload
justificationstring or nullNoJustification
reviewer_user_idstring or nullNoReviewer User Id
review_notestring or nullNoReview Note
applied_resultAccessRequestAppliedResult or nullNo
created_atstring or nullNoCreated At
updated_atstring or nullNoUpdated At
resolved_atstring or nullNoResolved At
expires_atstring or nullNoExpires At

POST /access_request/reject​

Reject an access request

Decline a pending request without changing anything else.

Request body (application/json, schema ReviewAccessRequest):

FieldTypeRequiredDescription
request_idstringYesRequest Id
review_notestring or nullNoReview 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:

StatusDescriptionBody
200Successful Responseapplication/json Spanway_AccessRequestTable
400The request is no longer pendingapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not review this requestapplication/json ErrorDetail
404No request with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
request_idstringYesRequest Id
request_typeenum: "virtual_key", "model_access", "team_membership", "budget_increase", "rate_limit_increase"YesRequest Type
statusenum: "pending", "applying", "approved", "rejected", "cancelled", "expired"YesStatus
requester_user_idstringYesRequester User Id
team_idstring or nullNoTeam Id
target_key_tokenstring or nullNoTarget Key Token
payloadVirtualKeyPayload or ModelAccessPayload or TeamMembershipPayload or BudgetIncreasePayload or RateLimitIncreasePayloadYesPayload
justificationstring or nullNoJustification
reviewer_user_idstring or nullNoReviewer User Id
review_notestring or nullNoReview Note
applied_resultAccessRequestAppliedResult or nullNo
created_atstring or nullNoCreated At
updated_atstring or nullNoUpdated At
resolved_atstring or nullNoResolved At
expires_atstring or nullNoExpires At