Skip to main content

Search tools API

This page documents the 7 gateway endpoints tagged search_tools 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/search_toolsCreate a search tool
GET/search_tools/listList the search tools stored in the database and the config file
POST/search_tools/test_connectionTest a search provider configuration
GET/search_tools/ui/available_providersList the search providers a search tool can use
GET/search_tools/{search_tool_id}Get a search tool
PUT/search_tools/{search_tool_id}Update a search tool
DELETE/search_tools/{search_tool_id}Delete a search tool

Endpoints​

POST /search_tools​

Create a search tool

Adds a web search tool, such as a Perplexity or Tavily account, that keys can then call by name through the search route. Send the tool name, the provider and its key in spanway_params, and an optional description. The provider key is stored encrypted and masked in the response, and the gateway starts using the tool right away. Only proxy admins may call it. The change is written to the audit log.

Request body (application/json, schema CreateSearchToolRequest):

FieldTypeRequiredDescription
search_toolSearchToolYesThe search tool to add: its name, provider settings and description

Example request:

curl -X POST "http://localhost:4000/search_tools" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"search_tool": {
"search_tool_info": {
"description": "Perplexity web search"
},
"search_tool_name": "web-search",
"spanway_params": {
"api_key": "pplx-...",
"search_provider": "perplexity"
}
}
}'

Responses:

StatusDescriptionBody
200The stored search tool with its key maskedapplication/json SearchToolInfoResponse
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
403An admin viewer tried to change something, and admin viewers can only readapplication/json ProxyError
409Another search tool already uses that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, or saving the tool failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
created_atstring or nullNoCreated At
is_from_configboolean or nullNoIs From Config
search_tool_idstring or nullNoSearch Tool Id
search_tool_infoobject or nullNoSearch Tool Info
search_tool_namestringNoSearch Tool Name
spanway_paramsobjectNoSpanway Params
updated_atstring or nullNoUpdated At

GET /search_tools/list​

List the search tools stored in the database and the config file

Lists the web search tools the gateway can use, from the database and from the config file, with provider keys masked. A tool defined in both places is shown once, from the database, and is_from_config tells you where each one lives. Keys only see the tools their key, team or user grants allow, and proxy admins see all of them. Any valid key may call it. Nothing is changed.

Example request:

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

Responses:

StatusDescriptionBody
200Successful Responseapplication/json ListSearchToolsResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
search_toolsarray of SearchToolInfoResponseYesSearch Tools

POST /search_tools/test_connection​

Test a search provider configuration

Checks a search provider configuration before you save it, by running one small test query with the settings you send. A rejected key or an unreachable provider comes back as status error with the reason, so you can fix it before creating the tool. Only proxy admins may call it. Nothing is stored.

Request body (application/json, schema TestSearchToolConnectionRequest):

FieldTypeRequiredDescription
spanway_paramsobjectYesThe provider settings to test, with search_provider and api_key

Example request:

curl -X POST "http://localhost:4000/search_tools/test_connection" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"spanway_params": {
"api_key": "pplx-...",
"search_provider": "perplexity"
}
}'

Responses:

StatusDescriptionBody
200The outcome of one test query. A rejected key answers 200 with status error and the reasonapplication/json SearchToolTestConnectionResponse
400The body names no providerapplication/json ErrorDetail
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
403An admin viewer tried to change something, and admin viewers can only readapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage
results_countintegerNoResults Count
statusstringYesStatus
test_querystringNoTest Query

GET /search_tools/ui/available_providers​

List the search providers a search tool can use

Lists every search provider a search tool can use, with the name the Admin UI shows for it, so you can pick the right search_provider value. Any valid key may call it. Nothing is changed.

Example request:

curl -X GET "http://localhost:4000/search_tools/ui/available_providers" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Every supported search providerapplication/json AvailableSearchProviderList
401No valid key or Admin UI session was presentedapplication/json ProxyError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
providersarray of AvailableSearchProviderYesEvery search provider a search tool can use

GET /search_tools/{search_tool_id}​

Get a search tool

Returns one search tool stored in the database, with its provider key masked. Only proxy admins may call it. Nothing is changed. Answers 404 when no tool has that id.

Parameters:

NameInTypeRequiredDescription
search_tool_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/search_tools/search_tool_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json any
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

PUT /search_tools/{search_tool_id}​

Update a search tool

Changes a stored search tool's name, provider settings or description. Send masked key values back unchanged to keep the stored key. The gateway starts using the new settings right away. Only proxy admins may call it. The change is written to the audit log. Answers 404 when no tool has that id.

Parameters:

NameInTypeRequiredDescription
search_tool_idpathstringYes

Request body (application/json, schema UpdateSearchToolRequest):

FieldTypeRequiredDescription
search_toolSearchToolYesThe new settings, send masked keys back unchanged to keep them

Example request:

curl -X PUT "http://localhost:4000/search_tools/search_tool_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"search_tool": {
"search_tool_info": {
"description": "Perplexity web search"
},
"search_tool_name": "web-search",
"spanway_params": {
"api_key": "pplx-...",
"search_provider": "perplexity"
}
}
}'

Responses:

StatusDescriptionBody
200Successful Responseapplication/json any
400The api_base changed but the stored api_key was left out or sent back maskedapplication/json ErrorDetail
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
403An admin viewer tried to change something, and admin viewers can only readapplication/json ProxyError
404No object with that id is visible to the callerapplication/json ErrorDetail
409Another search tool already uses that nameapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

DELETE /search_tools/{search_tool_id}​

Delete a search tool

Deletes a search tool stored in the database, so keys can no longer call it. Tools defined in the config file are not affected. Only proxy admins may call it. The change is written to the audit log. Answers 404 when no tool has that id.

Parameters:

NameInTypeRequiredDescription
search_tool_idpathstringYes

Example request:

curl -X DELETE "http://localhost:4000/search_tools/search_tool_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The search tool that was deletedapplication/json SearchToolDeleted
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
403An admin viewer tried to change something, and admin viewers can only readapplication/json ProxyError
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesWhat was deleted
search_tool_namestringYesThe name of the deleted search tool