Skip to main content

Workload identity API

This page documents the 1 gateway endpoint tagged workload identity 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/v1/workload-identity/tokenExchange a workload's OIDC token for a short-lived virtual key

Endpoints​

POST /v1/workload-identity/token​

Exchange a workload's OIDC token for a short-lived virtual key

Exchange a trusted workload's OIDC token for a short-lived virtual key, following RFC 8693 token exchange.

The route takes no API key: the OIDC token in subject_token is the credential. It must be signed by the issuer of a trust policy under general_settings.workload_identity, carry that policy's audience, and match its subjects and claims. The answer is a virtual key scoped to the policy's team, routes, models and budget that expires after expires_in seconds. Send scope with a policy name when several policies match.

Docs (https://docs.spanway.ai/docs/proxy/workload_identity)

Request body (application/x-www-form-urlencoded, schema ExchangeForm):

FieldTypeRequiredDescription
grant_typestringYesGrant Type
subject_tokenstringYesSubject Token
subject_token_typestringYesSubject Token Type
requested_token_typestring or nullNoRequested Token Type
scopestring or nullNoScope

Example request:

curl -X POST "http://localhost:4000/v1/workload-identity/token"

Responses:

StatusDescriptionBody
200A virtual key to use as the bearer token until expires_in seconds have passedapplication/json TokenResponse
400The token failed a check (invalid_grant), the grant type is wrong (unsupported_grant_type) or a form field is not accepted (invalid_request)application/json TokenErrorResponse
403The license does not include the workload_identity featureapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The policy names a team that does not exist, or the gateway has no database. The gateway log has the causeapplication/json TokenErrorResponse

Response fields (200):

FieldTypeRequiredDescription
access_tokenstringYesAccess Token
issued_token_type"urn:ietf:params:oauth:token-type:access_token"NoIssued Token Type
token_type"Bearer"NoToken Type
expires_inintegerYesExpires In