Pass-through management API
This page documents the 5 gateway endpoints tagged pass-through management 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 |
|---|---|---|
| GET | /config/pass_through_endpoint/team/{team_id} | List the pass-through endpoints a team can call |
| GET | /config/pass_through_endpoint | List custom pass-through endpoints |
| POST | /config/pass_through_endpoint | Create a custom pass-through endpoint |
| DELETE | /config/pass_through_endpoint | Delete a custom pass-through endpoint |
| POST | /config/pass_through_endpoint/{endpoint_id} | Update a custom pass-through endpoint |
Endpoints
GET /config/pass_through_endpoint/team/{team_id}
List the pass-through endpoints a team can call
List the custom pass-through endpoints that keys of one team reach, after the team's allowed_passthrough_routes and denied_passthrough_routes are applied. The denied list only removes endpoints that require a Spanway key. Header values come back masked. Proxy admin keys only. The Settings tab of a team shows this list under Pass-through endpoints this team can call.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
team_id | path | string or null | Yes | |
endpoint_id | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/config/pass_through_endpoint/team/team_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PassThroughEndpointResponse |
| 403 | The key is not a proxy admin key. | application/json ErrorDetail |
| 404 | No team has this id. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, so endpoints can only come from the config file. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
endpoints | array of PassThroughGenericEndpoint | Yes | Endpoints |
GET /config/pass_through_endpoint
List custom pass-through endpoints
List every custom pass-through endpoint the gateway serves, from the config file and from the database. Pass endpoint_id to fetch one stored endpoint. Credential-like header values such as Authorization or x-api-key come back masked, and sending a masked value back on an update keeps the stored secret. Proxy admin keys only. The Pass-Through Endpoints tab of the Models + Endpoints page reads this list.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
endpoint_id | query | string or null | No | |
team_id | query | string or null | No |
Example request:
curl -X GET "http://localhost:4000/config/pass_through_endpoint" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PassThroughEndpointResponse |
| 403 | The key is not a proxy admin key. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, so endpoints can only come from the config file. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
endpoints | array of PassThroughGenericEndpoint | Yes | Endpoints |
POST /config/pass_through_endpoint
Create a custom pass-through endpoint
Add a route that forwards requests to a target URL, stored in the database and live on this instance at once. auth defaults to true, so callers need a Spanway virtual key unless you set it to false for a public forwarder. Header values may reference gateway environment variables with os.environ/, but only the variables listed in general_settings.pass_through_env_var_allowlist. Proxy admin keys only. The Add Pass-Through Endpoint dialog calls this route.
Request body (application/json, schema PassThroughGenericEndpoint):
| Field | Type | Required | Description |
|---|---|---|---|
id | string or null | No | Optional unique identifier for the pass-through endpoint. If not provided, endpoints will be identified by path for backwards compatibility. |
path | string | Yes | The route to be added to the Spanway Proxy Server. |
target | string | Yes | The URL to which requests for this path should be forwarded. |
headers | object | No | Key-value pairs of headers to be forwarded with the request. You can set any key value pair here and it will be forwarded to your target endpoint |
default_query_params | object | No | Key-value pairs of default query parameters to be sent with every request to this endpoint. These can be overridden by client-provided query parameters. For example: {'key': 'default_value', 'api_version': '2023-01'} |
include_subpath | boolean | No | If True, requests to subpaths of the path will be forwarded to the target endpoint. For example, if the path is /images and include_subpath is True, requests to /images/v1/generate will be forwarded to the target endpoin |
cost_per_request | number | No | The USD cost per request to the target endpoint. This is used to calculate the cost of the request to the target endpoint. |
timeout | number or null | No | Upstream request timeout in seconds for this pass-through endpoint. If unset, uses general_settings.pass_through_request_timeout (default 600). |
auth | boolean | No | Whether callers need a Spanway key. Set false only for a public forwarder, such as a webhook. |
guardrails | object or null | No | Guardrails configuration for this passthrough endpoint. Dict keys are guardrail names, values are optional settings for field targeting. When set, all org/team/key level guardrails will also execute. Defaults to None (no |
is_from_config | boolean | No | True if this endpoint is defined in the config file, False if from DB. Config-defined endpoints cannot be edited via the UI. |
methods | array of string or null | No | List of HTTP methods this endpoint handles (e.g., ['GET', 'POST']). If None or empty, all methods (GET, POST, PUT, DELETE, PATCH) are supported for backward compatibility. This allows the same path to have different targ |
Example request:
curl -X POST "http://localhost:4000/config/pass_through_endpoint" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"path": "/v1/rerank-internal",
"target": "https://rerank.internal.example.com/v1/rerank",
"headers": {
"Authorization": "bearer os.environ/INTERNAL_RERANK_KEY"
},
"default_query_params": {},
"include_subpath": false,
"cost_per_request": 0.002,
"auth": true,
"is_from_config": false,
"methods": [
"POST"
]
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PassThroughEndpointResponse |
| 400 | A header reads a gateway environment variable outside general_settings.pass_through_env_var_allowlist. Or the gateway has no database, so endpoints can only come from the config file. | application/json ErrorDetail |
| 403 | The key is not a proxy admin key. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
endpoints | array of PassThroughGenericEndpoint | Yes | Endpoints |
DELETE /config/pass_through_endpoint
Delete a custom pass-through endpoint
Remove a pass-through endpoint stored in the database by its endpoint_id and unregister its route on this instance. The response carries the deleted endpoint. Endpoints defined in the config file cannot be deleted here. Proxy admin keys only. The Delete action of the Pass-Through Endpoints tab calls this route.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
endpoint_id | query | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/config/pass_through_endpoint?endpoint_id=endpoint_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PassThroughEndpointResponse |
| 400 | No stored endpoint has this id, no endpoint is stored at all, or the gateway has no database. | application/json ErrorDetail |
| 403 | The key is not a proxy admin key. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
endpoints | array of PassThroughGenericEndpoint | Yes | Endpoints |
POST /config/pass_through_endpoint/{endpoint_id}
Update a custom pass-through endpoint
Change a pass-through endpoint stored in the database. Only the fields you send change, so leaving auth out keeps its stored value, and a header sent back with its masked value keeps the stored secret. The route is re-registered at once on this instance. Endpoints defined in the config file cannot be updated here. Proxy admin keys only. The Edit Settings form of the endpoint detail view calls this route.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
endpoint_id | path | string | Yes |
Request body (application/json, schema PassThroughEndpointUpdate):
| Field | Type | Required | Description |
|---|---|---|---|
id | string or null | No | New identifier. Leave out to keep the stored one. |
path | string or null | No | New route on the gateway. Leave out to keep the stored one. |
target | string or null | No | New upstream URL. Leave out to keep the stored one. |
headers | object or null | No | Headers to forward. A header sent back with its masked value keeps the stored secret. |
default_query_params | object or null | No | Default query parameters sent with every request. |
include_subpath | boolean or null | No | Whether subpaths of the path are forwarded too. |
cost_per_request | number or null | No | USD cost recorded per request. |
timeout | number or null | No | Upstream request timeout in seconds. |
auth | boolean or null | No | Whether callers need a Spanway API key. |
guardrails | object or null | No | Guardrails to run on this endpoint, keyed by guardrail name. |
methods | array of string or null | No | HTTP methods this endpoint handles. |
Example request:
curl -X POST "http://localhost:4000/config/pass_through_endpoint/endpoint_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"guardrails": {
"pii-block": {
"request_fields": [
"query",
"documents[*].text"
],
"response_fields": [
"results[*].text"
]
}
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json PassThroughEndpointResponse |
| 400 | A header reads a gateway environment variable outside general_settings.pass_through_env_var_allowlist. Or the target changed while a stored header secret was left out or sent back masked. | application/json ErrorDetail |
| 403 | The key is not a proxy admin key. | application/json ErrorDetail |
| 404 | No stored endpoint has this id, no endpoint is stored at all, or the gateway has no database. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
endpoints | array of PassThroughGenericEndpoint | Yes | Endpoints |