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.
| Method | Path | Summary |
|---|---|---|
| POST | /v1/workload-identity/token | Exchange 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):
| Field | Type | Required | Description |
|---|---|---|---|
grant_type | string | Yes | Grant Type |
subject_token | string | Yes | Subject Token |
subject_token_type | string | Yes | Subject Token Type |
requested_token_type | string or null | No | Requested Token Type |
scope | string or null | No | Scope |
Example request:
curl -X POST "http://localhost:4000/v1/workload-identity/token"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | A virtual key to use as the bearer token until expires_in seconds have passed | application/json TokenResponse |
| 400 | The 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 |
| 403 | The license does not include the workload_identity feature | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The policy names a team that does not exist, or the gateway has no database. The gateway log has the cause | application/json TokenErrorResponse |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
access_token | string | Yes | Access Token |
issued_token_type | "urn:ietf:params:oauth:token-type:access_token" | No | Issued Token Type |
token_type | "Bearer" | No | Token Type |
expires_in | integer | Yes | Expires In |