Jwt mappings API
This page documents the 5 gateway endpoints tagged jwt_mappings 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 | /jwt/key/mapping/delete | Delete a JWT key mapping |
| GET | /jwt/key/mapping/info | Get one JWT key mapping |
| GET | /jwt/key/mapping/list | List JWT key mappings |
| POST | /jwt/key/mapping/new | Map a JWT claim value to a virtual key |
| POST | /jwt/key/mapping/update | Change a JWT key mapping |
Endpoints
POST /jwt/key/mapping/delete
Delete a JWT key mapping
Remove the mapping. Tokens that carried its claim stop resolving to the key right away. Proxy admins only.
Request body (application/json, schema DeleteJWTKeyMappingRequest):
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Id |
Example request:
curl -X POST "http://localhost:4000/jwt/key/mapping/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "jkm-01J8Z"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json JWTKeyMappingDeleted |
| 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 object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
status | "success" | Yes | Status |
GET /jwt/key/mapping/info
Get one JWT key mapping
One mapping by id, without the hashed key. Proxy admins and admin viewers.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
id | query | string | Yes |
Example request:
curl -X GET "http://localhost:4000/jwt/key/mapping/info?id=id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json JWTKeyMappingResponse |
| 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 object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
created_at | string | Yes | Created At |
created_by | string or null | No | Created By |
description | string or null | No | Description |
id | string | Yes | Id |
is_active | boolean | Yes | Is Active |
jwt_claim_name | string | Yes | Jwt Claim Name |
jwt_claim_value | string | Yes | Jwt Claim Value |
jwt_issuer | string or null | No | Jwt Issuer |
updated_at | string | Yes | Updated At |
updated_by | string or null | No | Updated By |
GET /jwt/key/mapping/list
List JWT key mappings
Mappings newest first, without the hashed key. Proxy admins and admin viewers.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
page | query | integer | No | Page number |
size | query | integer | No | Page size |
Example request:
curl -X GET "http://localhost:4000/jwt/key/mapping/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json any |
| 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 |
POST /jwt/key/mapping/new
Map a JWT claim value to a virtual key
Make requests whose JWT carries jwt_claim_name equal to jwt_claim_value run as the given virtual key, with that key's models, budget and spend attribution. Pass exactly one of key (the plaintext key) or token (its SHA-256 hash). jwt_issuer limits the mapping to tokens from one issuer, and leaving it out matches every configured issuer. Proxy admins only, and the gateway needs a license that includes JWT auth.
Request body (application/json, schema CreateJWTKeyMappingRequest):
| Field | Type | Required | Description |
|---|---|---|---|
description | string or null | No | Description |
jwt_claim_name | string | Yes | Jwt Claim Name |
jwt_claim_value | string | Yes | Jwt Claim Value |
jwt_issuer | string or null | No | Jwt Issuer |
key | string or null | No | Key |
token | string or null | No | Token |
Example request:
curl -X POST "http://localhost:4000/jwt/key/mapping/new" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"description": "Billing service",
"jwt_claim_name": "azp",
"jwt_claim_value": "billing-service",
"jwt_issuer": "https://login.example.com",
"key": "sk-9f3a2c7e41b8d605"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json JWTKeyMappingResponse |
| 400 | The request is malformed or breaks a rule named in the detail | 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 |
| 409 | The object already exists or is in a state that does not allow this change | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
created_at | string | Yes | Created At |
created_by | string or null | No | Created By |
description | string or null | No | Description |
id | string | Yes | Id |
is_active | boolean | Yes | Is Active |
jwt_claim_name | string | Yes | Jwt Claim Name |
jwt_claim_value | string | Yes | Jwt Claim Value |
jwt_issuer | string or null | No | Jwt Issuer |
updated_at | string | Yes | Updated At |
updated_by | string or null | No | Updated By |
POST /jwt/key/mapping/update
Change a JWT key mapping
Point the mapping at another key, change its issuer or description, or pause it with is_active: false. The claim name and value cannot change, so delete and recreate a mapping to move it to another claim. Cached lookups for the old and new claim are dropped once the change is written. Proxy admins only.
Request body (application/json, schema UpdateJWTKeyMappingRequest):
| Field | Type | Required | Description |
|---|---|---|---|
description | string or null | No | Description |
id | string | Yes | Id |
is_active | boolean or null | No | Is Active |
jwt_issuer | string or null | No | Jwt Issuer |
key | string or null | No | Key |
token | string or null | No | Token |
Example request:
curl -X POST "http://localhost:4000/jwt/key/mapping/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"description": "Billing service, rotated key",
"id": "jkm-01J8Z",
"key": "sk-9876wxyz5432stuv"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json JWTKeyMappingResponse |
| 400 | The request is malformed or breaks a rule named in the detail | 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 object with that id is visible to the caller | application/json ErrorDetail |
| 409 | The object already exists or is in a state that does not allow this change | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
created_at | string | Yes | Created At |
created_by | string or null | No | Created By |
description | string or null | No | Description |
id | string | Yes | Id |
is_active | boolean | Yes | Is Active |
jwt_claim_name | string | Yes | Jwt Claim Name |
jwt_claim_value | string | Yes | Jwt Claim Value |
jwt_issuer | string or null | No | Jwt Issuer |
updated_at | string | Yes | Updated At |
updated_by | string or null | No | Updated By |