Skip to main content

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.

MethodPathSummary
GET/v1/tool/listList the discovered tools and their policies
POST/v1/tool/policySet a tool's policy, globally or for one team or key
GET/v1/tool/policy/optionsList the input and output policy values
GET/v1/tool/spendSpend 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}/detailGet a tool with its team and key blocks
GET/v1/tool/{tool_name}/logsList the requests that called a tool
DELETE/v1/tool/{tool_name}/overridesRemove 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:

NameInTypeRequiredDescription
input_policyqueryenum: "trusted", "untrusted", "blocked" or nullNo

Example request:

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

Responses:

StatusDescriptionBody
200Every discovered tool with its policiesapplication/json ToolListResponse
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
toolsarray of Spanway_ToolTableRowYesTools
totalintegerYesTotal

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

FieldTypeRequiredDescription
input_policyenum: "trusted", "untrusted", "blocked" or nullNoInput Policy
key_aliasstring or nullNoKey Alias
key_hashstring or nullNoKey Hash
output_policyenum: "trusted", "untrusted" or nullNoOutput Policy
team_idstring or nullNoTeam Id
tool_namestringYesTool 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:

StatusDescriptionBody
200The policy now in force. With team_id or key_hash the answer echoes that scopeapplication/json ToolPolicyUpdateResponse
400Neither policy was sent, both team_id and key_hash were, or output_policy was sent with a scopeapplication/json ErrorDetail
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError
404team_id or key_hash matches nothing, or a lift names a tool that is not blocked for that scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a database, or the database write failedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
input_policyenum: "trusted", "untrusted", "blocked" or nullNoInput Policy
key_hashstring or nullNoKey Hash
output_policyenum: "trusted", "untrusted" or nullNoOutput Policy
team_idstring or nullNoTeam Id
tool_namestringYesTool Name
updatedbooleanYesUpdated

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:

StatusDescriptionBody
200The policy values and meaningsapplication/json ToolPolicyOptionsResponse
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError

Response fields (200):

FieldTypeRequiredDescription
input_policiesarray of ToolPolicyOptionYesInput Policies
output_policiesarray of ToolPolicyOptionYesOutput 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:

NameInTypeRequiredDescription
start_datequerystring or nullNoYYYY-MM-DD (defaults to 30 days ago)
end_datequerystring or nullNoYYYY-MM-DD (defaults to today)

Example request:

curl -X GET "http://localhost:4000/v1/tool/spend" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Spend attributed to each tool over the windowapplication/json ToolSpendResponse
400A date is not YYYY-MM-DDapplication/json ErrorDetail
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError
403The key is not a proxy admin or admin viewer keyapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
by_toolarray of ToolSpendEntryNoBy Tool
dailyarray of ToolSpendDailyEntryNoDaily
end_datestring or nullNoEnd Date
start_datestring or nullNoStart 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:

NameInTypeRequiredDescription
tool_namepathstringYes

Example request:

curl -X GET "http://localhost:4000/v1/tool/tool_name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The tool rowapplication/json Spanway_ToolTableRow
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError
404The gateway has not seen that tool yet in a request's tools list or an MCP call, and no policy created itapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
assignmentsobject or nullNoAssignments
call_countintegerNoCall Count
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
input_policyenum: "trusted", "untrusted", "blocked"NoInput Policy
key_aliasstring or nullNoKey Alias
key_hashstring or nullNoKey Hash
last_used_atstring or nullNoLast Used At
originstring or nullNoOrigin
output_policyenum: "trusted", "untrusted"NoOutput Policy
team_idstring or nullNoTeam Id
tool_idstringYesTool Id
tool_namestringYesTool Name
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated By
userToolDiscoveryUser or nullNo
user_agentstring or nullNoUser 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:

NameInTypeRequiredDescription
tool_namepathstringYes

Example request:

curl -X DELETE "http://localhost:4000/v1/tool/tool_name-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The tool was removed from the registryapplication/json ToolPolicyOverrideDeleted
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError
404No tool has that nameapplication/json ErrorDetail
409The tool is blocked. Deleting it would let it come back unblocked the next time a model calls itapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
deletedbooleanYesDeleted
tool_namestringYesTool 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:

NameInTypeRequiredDescription
tool_namepathstringYes

Example request:

curl -X GET "http://localhost:4000/v1/tool/tool_name-123/detail" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The tool and the teams or keys it is blocked forapplication/json ToolDetailResponse
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError
404The gateway has not seen that tool yet in a request's tools list or an MCP call, and no policy created itapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
overridesarray of ToolPolicyOverrideRowNoOverrides
toolSpanway_ToolTableRowYes

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:

NameInTypeRequiredDescription
tool_namepathstringYes
pagequeryintegerNo
page_sizequeryintegerNo
start_datequerystring or nullNoYYYY-MM-DD
end_datequerystring or nullNoYYYY-MM-DD

Example request:

curl -X GET "http://localhost:4000/v1/tool/tool_name-123/logs" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Requests in which the model called this tool, newest firstapplication/json ToolUsageLogsResponse
400A date is not YYYY-MM-DDapplication/json ErrorDetail
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
logsarray of ToolUsageLogEntryYesLogs
pageintegerYesPage
page_sizeintegerYesPage Size
totalintegerYesTotal

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:

NameInTypeRequiredDescription
tool_namepathstringYes
team_idquerystring or nullNoTeam ID of the override to remove
key_hashquerystring or nullNoHashed 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:

StatusDescriptionBody
200The block was removedapplication/json ToolPolicyOverrideDeleted
400Neither or both of team_id and key_hash were sent, or key_hash holds a raw sk- keyapplication/json ErrorDetail
401No valid key was presented, or the key is not a proxy admin keyapplication/json ProxyError
404There is no block for that team or keyapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
deletedbooleanYesDeleted
tool_namestringYesTool Name