Skip to main content

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.

MethodPathSummary
GET/config/pass_through_endpoint/team/{team_id}List the pass-through endpoints a team can call
GET/config/pass_through_endpointList custom pass-through endpoints
POST/config/pass_through_endpointCreate a custom pass-through endpoint
DELETE/config/pass_through_endpointDelete 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:

NameInTypeRequiredDescription
team_idpathstring or nullYes
endpoint_idquerystring or nullNo

Example request:

curl -X GET "http://localhost:4000/config/pass_through_endpoint/team/team_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PassThroughEndpointResponse
403The key is not a proxy admin key.application/json ErrorDetail
404No team has this id.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, so endpoints can only come from the config file.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
endpointsarray of PassThroughGenericEndpointYesEndpoints

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:

NameInTypeRequiredDescription
endpoint_idquerystring or nullNo
team_idquerystring or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PassThroughEndpointResponse
403The key is not a proxy admin key.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, so endpoints can only come from the config file.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
endpointsarray of PassThroughGenericEndpointYesEndpoints

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):

FieldTypeRequiredDescription
idstring or nullNoOptional unique identifier for the pass-through endpoint. If not provided, endpoints will be identified by path for backwards compatibility.
pathstringYesThe route to be added to the Spanway Proxy Server.
targetstringYesThe URL to which requests for this path should be forwarded.
headersobjectNoKey-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_paramsobjectNoKey-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_subpathbooleanNoIf 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_requestnumberNoThe USD cost per request to the target endpoint. This is used to calculate the cost of the request to the target endpoint.
timeoutnumber or nullNoUpstream request timeout in seconds for this pass-through endpoint. If unset, uses general_settings.pass_through_request_timeout (default 600).
authbooleanNoWhether callers need a Spanway key. Set false only for a public forwarder, such as a webhook.
guardrailsobject or nullNoGuardrails 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_configbooleanNoTrue if this endpoint is defined in the config file, False if from DB. Config-defined endpoints cannot be edited via the UI.
methodsarray of string or nullNoList 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:

StatusDescriptionBody
200Successful Responseapplication/json PassThroughEndpointResponse
400A 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
403The key is not a proxy admin key.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
endpointsarray of PassThroughGenericEndpointYesEndpoints

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:

NameInTypeRequiredDescription
endpoint_idquerystringYes

Example request:

curl -X DELETE "http://localhost:4000/config/pass_through_endpoint?endpoint_id=endpoint_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json PassThroughEndpointResponse
400No stored endpoint has this id, no endpoint is stored at all, or the gateway has no database.application/json ErrorDetail
403The key is not a proxy admin key.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
endpointsarray of PassThroughGenericEndpointYesEndpoints

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:

NameInTypeRequiredDescription
endpoint_idpathstringYes

Request body (application/json, schema PassThroughEndpointUpdate):

FieldTypeRequiredDescription
idstring or nullNoNew identifier. Leave out to keep the stored one.
pathstring or nullNoNew route on the gateway. Leave out to keep the stored one.
targetstring or nullNoNew upstream URL. Leave out to keep the stored one.
headersobject or nullNoHeaders to forward. A header sent back with its masked value keeps the stored secret.
default_query_paramsobject or nullNoDefault query parameters sent with every request.
include_subpathboolean or nullNoWhether subpaths of the path are forwarded too.
cost_per_requestnumber or nullNoUSD cost recorded per request.
timeoutnumber or nullNoUpstream request timeout in seconds.
authboolean or nullNoWhether callers need a Spanway API key.
guardrailsobject or nullNoGuardrails to run on this endpoint, keyed by guardrail name.
methodsarray of string or nullNoHTTP 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:

StatusDescriptionBody
200Successful Responseapplication/json PassThroughEndpointResponse
400A 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
403The key is not a proxy admin key.application/json ErrorDetail
404No stored endpoint has this id, no endpoint is stored at all, or the gateway has no database.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
endpointsarray of PassThroughGenericEndpointYesEndpoints