Tools API
This page documents the 9 gateway endpoints tagged 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 |
|---|---|---|
| GET | /v1/tool/list | List the discovered tools and their policies |
| POST | /v1/tool/policy | Set a tool's policy, globally or for one team or key |
| GET | /v1/tool/policy/options | List the input and output policy values |
| GET | /v1/tool/spend | Spend attributed to each tool |
| GET | /v1/tool/{tool_name} | Get one tool |
| DELETE | /v1/tool/{tool_name} | Delete a tool from the registry |
| GET | /v1/tool/{tool_name}/detail | Get a tool with its team and key blocks |
| GET | /v1/tool/{tool_name}/logs | List the requests that called a tool |
| DELETE | /v1/tool/{tool_name}/overrides | Remove a team or key block on a tool |
Endpoints
GET /v1/tool/list
List the discovered tools and their policies
List every tool the gateway has seen, whether a request offered it in its tools list, a model called it or an
MCP client called it, with its input and output policy, optionally only tools with one input policy.
call_count counts the discovery batches in which the tool was seen, not exact calls, so use the logs route
for those. Proxy admins and admin viewers may call it. Nothing changes.
Docs (https://docs.spanway.ai/docs/proxy/tool_registry#set-a-tools-policy)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
input_policy | query | enum: "trusted", "untrusted", "blocked" or null | No |
Example request:
curl -X GET "http://localhost:4000/v1/tool/list" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Every discovered tool with its policies | application/json ToolListResponse |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
tools | array of Spanway_ToolTableRow | Yes | Tools |
total | integer | Yes | Total |
POST /v1/tool/policy
Set a tool's policy, globally or for one team or key
Set how much the gateway trusts a tool. Without team_id or key_hash the input and output policy apply to
every caller. With team_id or key_hash, an input_policy of blocked blocks the tool for that team or key only,
and any other value lifts that block. Only proxy admins may call it. The change is written to the audit log
with the value before and after, takes effect on this gateway on the next request and on other gateways at
their next policy sync. Docs (https://docs.spanway.ai/docs/proxy/tool_registry#set-a-tools-policy)
Request body (application/json, schema ToolPolicyUpdateRequest):
| Field | Type | Required | Description |
|---|---|---|---|
input_policy | enum: "trusted", "untrusted", "blocked" or null | No | Input Policy |
key_alias | string or null | No | Key Alias |
key_hash | string or null | No | Key Hash |
output_policy | enum: "trusted", "untrusted" or null | No | Output Policy |
team_id | string or null | No | Team Id |
tool_name | string | Yes | Tool Name |
Example request:
curl -X POST "http://localhost:4000/v1/tool/policy" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input_policy": "trusted",
"tool_name": "jira-create_issue"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The policy now in force. With team_id or key_hash the answer echoes that scope | application/json ToolPolicyUpdateResponse |
| 400 | Neither policy was sent, both team_id and key_hash were, or output_policy was sent with a scope | application/json ErrorDetail |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
| 404 | team_id or key_hash matches nothing, or a lift names a tool that is not blocked for that scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database, or the database write failed | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
input_policy | enum: "trusted", "untrusted", "blocked" or null | No | Input Policy |
key_hash | string or null | No | Key Hash |
output_policy | enum: "trusted", "untrusted" or null | No | Output Policy |
team_id | string or null | No | Team Id |
tool_name | string | Yes | Tool Name |
updated | boolean | Yes | Updated |
GET /v1/tool/policy/options
List the input and output policy values
List the values a tool's input and output policy can take, with what each one means, for the policy pickers
in the Admin UI. Proxy admins and admin viewers may call it. The list is fixed, so it never reads the database,
and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/tool_registry#policies)
Example request:
curl -X GET "http://localhost:4000/v1/tool/policy/options" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The policy values and meanings | application/json ToolPolicyOptionsResponse |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
input_policies | array of ToolPolicyOption | Yes | Input Policies |
output_policies | array of ToolPolicyOption | Yes | Output Policies |
GET /v1/tool/spend
Spend attributed to each tool
Show how much each tool cost over a date range, for the Cost Optimization dashboard. Proxy admins and admin
viewers may call it, and nothing changes. Only tools a model actually called count, MCP tool calls and tool
calls in responses. A request that called several tools counts its full spend toward each of them, so the
per-tool numbers overlap and do not add up to total spend. The answer lists the most expensive tools and a daily
series for those tools only. Docs (https://docs.spanway.ai/docs/proxy/tool_registry#follow-a-tools-calls-and-spend)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
start_date | query | string or null | No | YYYY-MM-DD (defaults to 30 days ago) |
end_date | query | string or null | No | YYYY-MM-DD (defaults to today) |
Example request:
curl -X GET "http://localhost:4000/v1/tool/spend" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Spend attributed to each tool over the window | application/json ToolSpendResponse |
| 400 | A date is not YYYY-MM-DD | application/json ErrorDetail |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
| 403 | The key is not a proxy admin or admin viewer key | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
by_tool | array of ToolSpendEntry | No | By Tool |
daily | array of ToolSpendDailyEntry | No | Daily |
end_date | string or null | No | End Date |
start_date | string or null | No | Start Date |
GET /v1/tool/{tool_name}
Get one tool
Read one tool's row: where it comes from, its input and output policy, how many discovery batches saw it and
when it was last used. Proxy admins and admin viewers may call it. Nothing changes.
Docs (https://docs.spanway.ai/docs/proxy/tool_registry#set-a-tools-policy)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tool_name | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/v1/tool/tool_name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The tool row | application/json Spanway_ToolTableRow |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
| 404 | The gateway has not seen that tool yet in a request's tools list or an MCP call, and no policy created it | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
assignments | object or null | No | Assignments |
call_count | integer | No | Call Count |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
input_policy | enum: "trusted", "untrusted", "blocked" | No | Input Policy |
key_alias | string or null | No | Key Alias |
key_hash | string or null | No | Key Hash |
last_used_at | string or null | No | Last Used At |
origin | string or null | No | Origin |
output_policy | enum: "trusted", "untrusted" | No | Output Policy |
team_id | string or null | No | Team Id |
tool_id | string | Yes | Tool Id |
tool_name | string | Yes | Tool Name |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated By |
user | ToolDiscoveryUser or null | No | |
user_agent | string or null | No | User Agent |
DELETE /v1/tool/{tool_name}
Delete a tool from the registry
Remove a tool's row from the registry, for example a tool from an MCP server you removed, together with the key
alias and user agent of the request that first saw it. If a model calls the tool again it is registered afresh
with the default untrusted policy, so a blocked tool cannot be deleted: change its input policy first. Team and
key blocks on the tool are kept. Only proxy admins may call it, and the delete is written to the audit log.
Docs (https://docs.spanway.ai/docs/proxy/tool_registry#delete-a-tool)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tool_name | path | string | Yes |
Example request:
curl -X DELETE "http://localhost:4000/v1/tool/tool_name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The tool was removed from the registry | application/json ToolPolicyOverrideDeleted |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
| 404 | No tool has that name | application/json ErrorDetail |
| 409 | The tool is blocked. Deleting it would let it come back unblocked the next time a model calls it | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
deleted | boolean | Yes | Deleted |
tool_name | string | Yes | Tool Name |
GET /v1/tool/{tool_name}/detail
Get a tool with its team and key blocks
Read one tool with the teams and keys it is blocked for, as the tool page in the Admin UI shows it. Proxy
admins and admin viewers may call it. Nothing changes.
Docs (https://docs.spanway.ai/docs/proxy/tool_registry#block-a-tool-for-one-team-or-key)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tool_name | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/v1/tool/tool_name-123/detail" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The tool and the teams or keys it is blocked for | application/json ToolDetailResponse |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
| 404 | The gateway has not seen that tool yet in a request's tools list or an MCP call, and no policy created it | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
overrides | array of ToolPolicyOverrideRow | No | Overrides |
tool | Spanway_ToolTableRow | Yes |
GET /v1/tool/{tool_name}/logs
List the requests that called a tool
List the requests in which a model called this tool, newest first, with model, spend, tokens and the start of
the input. Proxy admins and admin viewers may call it. A tool named in a request but never called by the model
does not appear. Dates are YYYY-MM-DD and any other form answers 400. Because the answer shows the start of
each prompt, a page that carries input text writes an exported row to the audit log.
Docs (https://docs.spanway.ai/docs/proxy/tool_registry#follow-a-tools-calls-and-spend)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tool_name | path | string | Yes | |
page | query | integer | No | |
page_size | query | integer | No | |
start_date | query | string or null | No | YYYY-MM-DD |
end_date | query | string or null | No | YYYY-MM-DD |
Example request:
curl -X GET "http://localhost:4000/v1/tool/tool_name-123/logs" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Requests in which the model called this tool, newest first | application/json ToolUsageLogsResponse |
| 400 | A date is not YYYY-MM-DD | application/json ErrorDetail |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
logs | array of ToolUsageLogEntry | Yes | Logs |
page | integer | Yes | Page |
page_size | integer | Yes | Page Size |
total | integer | Yes | Total |
DELETE /v1/tool/{tool_name}/overrides
Remove a team or key block on a tool
Lift a block on a tool for one team or one key, named by exactly one of team_id or key_hash. Only proxy admins
may call it. The key must be the hashed key, because a raw sk- key in a query string ends up in access logs.
The tool's global policy is unchanged, and the removal is written to the audit log.
Docs (https://docs.spanway.ai/docs/proxy/tool_registry#block-a-tool-for-one-team-or-key)
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tool_name | path | string | Yes | |
team_id | query | string or null | No | Team ID of the override to remove |
key_hash | query | string or null | No | Hashed key of the override to remove. Never put a raw key in a URL |
Example request:
curl -X DELETE "http://localhost:4000/v1/tool/tool_name-123/overrides" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The block was removed | application/json ToolPolicyOverrideDeleted |
| 400 | Neither or both of team_id and key_hash were sent, or key_hash holds a raw sk- key | application/json ErrorDetail |
| 401 | No valid key was presented, or the key is not a proxy admin key | application/json ProxyError |
| 404 | There is no block for that team or key | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway runs without a database | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
deleted | boolean | Yes | Deleted |
tool_name | string | Yes | Tool Name |