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.
| Method | Path | Summary |
|---|---|---|
| POST | /search_tools | Create a search tool |
| GET | /search_tools/list | List the search tools stored in the database and the config file |
| POST | /search_tools/test_connection | Test a search provider configuration |
| GET | /search_tools/ui/available_providers | List 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):
| Field | Type | Required | Description |
|---|---|---|---|
search_tool | SearchTool | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | The stored search tool with its key masked | application/json SearchToolInfoResponse |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 409 | Another search tool already uses that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, or saving the tool failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
created_at | string or null | No | Created At |
is_from_config | boolean or null | No | Is From Config |
search_tool_id | string or null | No | Search Tool Id |
search_tool_info | object or null | No | Search Tool Info |
search_tool_name | string | No | Search Tool Name |
spanway_params | object | No | Spanway Params |
updated_at | string or null | No | Updated 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json ListSearchToolsResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 500 | The gateway hit an internal error, usually the database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
search_tools | array of SearchToolInfoResponse | Yes | Search 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):
| Field | Type | Required | Description |
|---|---|---|---|
spanway_params | object | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | The outcome of one test query. A rejected key answers 200 with status error and the reason | application/json SearchToolTestConnectionResponse |
| 400 | The body names no provider | application/json ErrorDetail |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
results_count | integer | No | Results Count |
status | string | Yes | Status |
test_query | string | No | Test 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:
| Status | Description | Body |
|---|---|---|
| 200 | Every supported search provider | application/json AvailableSearchProviderList |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 500 | The gateway hit an internal error, usually the database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
providers | array of AvailableSearchProvider | Yes | Every 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
search_tool_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/search_tools/search_tool_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json any |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway hit an internal error, usually the database is not connected | application/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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
search_tool_id | path | string | Yes |
Request body (application/json, schema UpdateSearchToolRequest):
| Field | Type | Required | Description |
|---|---|---|---|
search_tool | SearchTool | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json any |
| 400 | The api_base changed but the stored api_key was left out or sent back masked | application/json ErrorDetail |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 409 | Another search tool already uses that name | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway hit an internal error, usually the database is not connected | application/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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
search_tool_id | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/search_tools/search_tool_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The search tool that was deleted | application/json SearchToolDeleted |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 403 | An admin viewer tried to change something, and admin viewers can only read | application/json ProxyError |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway hit an internal error, usually the database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | What was deleted |
search_tool_name | string | Yes | The name of the deleted search tool |