Skip to main content

Tag management API

This page documents the 20 gateway endpoints tagged tag 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/tag/daily/activity/aggregatedDaily activity per tag
GET/tag/daily/activity/aggregated/keysKeys ranked by spend for a tag
GET/tag/daily/activity/aggregated/searchSearch the keys with activity for a tag
GET/tag/daily/activity/aggregated/model_top_keysTop keys for one model in a tag
GET/tag/daily/activity/exportDownload tag daily activity as CSV or JSON
POST/tag/newCreate a tag
POST/tag/updateUpdate a tag
POST/tag/infoRead tags by name
GET/tag/listList tags
POST/tag/deleteDelete a tag
GET/tag/daily/activityDaily spend and usage per tag
GET/tag/distinctList the user agent tags the gateway has seen
GET/tag/dauDaily active users per user agent, last 7 days
GET/tag/wauWeekly active users per user agent, last 7 weeks
GET/tag/mauMonthly active users per user agent, last 7 months
GET/tag/summaryUsers, requests, tokens and spend per tag in a date range
GET/tag/user-agent/per-user-analyticsPer user requests, tokens and spend by user agent, last 30 days
GET/tag/mcp/active-usersDaily, weekly or monthly active users per MCP server, tool or MCP client label
GET/tag/mcp/toolsCalls, failures, spend, users and latency per MCP tool in a date range
GET/tag/mcp/agentsMCP tool calls per agent, split by MCP server, tool or MCP client label

Endpoints​

GET /tag/daily/activity/aggregated​

Daily activity per tag

Spend, tokens and requests per day for each tag between start_date and end_date (YYYY-MM-DD), with a breakdown by model, provider, endpoint and key. Every day in the range is returned in one answer, so there is nothing to page. This is the query behind the tag usage view of the Admin UI. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)

Parameters:

NameInTypeRequiredDescription
api_key_limitqueryintegerNoHow many top keys to return
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
tagsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/tag/daily/activity/aggregated" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json SpendAnalyticsPaginatedResponse
400The date range is invalidapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
resultsarray of DailySpendDataYesResults
metadataDailySpendMetadataNo

GET /tag/daily/activity/aggregated/keys​

Keys ranked by spend for a tag

One page of the virtual keys that spent the most inside the tag scope and date range, with the spend, tokens and request counts of each. offset and limit page through the list and total_api_keys says how many keys there are in all. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)

Parameters:

NameInTypeRequiredDescription
offsetqueryintegerNoHow many rows to skip, for paging
limitqueryintegerNoHow many rows to return
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
tagsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/tag/daily/activity/aggregated/keys" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json DailyActivityKeyPageResponse
400The date range is invalidapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
api_keysarray of KeySpendActivityRowYesApi Keys
total_api_keysintegerYesTotal Api Keys
offsetintegerYesOffset
limitintegerYesLimit

Search the keys with activity for a tag

Find virtual keys with activity inside the tag scope and date range whose alias, hash, user id or email matches the search text, each with its spend, tokens and request counts. This is the key search box of the Usage page. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)

Parameters:

NameInTypeRequiredDescription
searchquerystringYesText to find in key aliases and key hashes
limitqueryintegerNoHow many rows to return
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
tagsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/tag/daily/activity/aggregated/search?search=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json DailyActivityKeySearchResponse
400The date range is invalidapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
api_keysarray of KeyActivityRowYesApi Keys

GET /tag/daily/activity/aggregated/model_top_keys​

Top keys for one model in a tag

The virtual keys that spent the most on one model inside the tag scope and date range. by_model_group tells whether model was matched as the public model group or as the individual deployment. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)

Parameters:

NameInTypeRequiredDescription
model_groupquerystringYesThe model or model group to rank keys for
by_model_groupquerybooleanNoMatch model_group as a model group, not a model
limitqueryintegerNoHow many rows to return
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
tagsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/tag/daily/activity/aggregated/model_top_keys?model_group=claude-sonnet-5-5" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful Responseapplication/json ModelTopKeysResponse
400The date range is invalidapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
modelstringYesModel
by_model_groupbooleanYesBy Model Group
api_keysarray of KeySpendActivityRowYesApi Keys

GET /tag/daily/activity/export​

Download tag daily activity as CSV or JSON

Stream one row per day for each tag in the range, with requests, tokens and spend. export_type picks the breakdown: daily, daily_with_keys, daily_with_models or daily_with_users. format is csv (the default) or json. The file name carries the entity, the range and the breakdown. This is the Export Data dialog of the Usage page. Docs (https://docs.spanway.ai/docs/proxy/spend_logs_export)

Parameters:

NameInTypeRequiredDescription
export_typequeryExportTypeNoThe breakdown of each row
formatqueryenum: "csv", "json"Nocsv or json
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
tagsquerystring or nullNo
timezonequeryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/tag/daily/activity/export" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Streamed daily activity exporttext/csv string
400Bad Requestapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The caller may not read this scopeapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The analytics query failed, the gateway log has the causeapplication/json ErrorDetail

POST /tag/new​

Create a tag

Define a request tag. models lists deployment ids or model names, and each database deployment among them gets the tag added to its tags once, now, so tag routing finds it. Deployments defined in config.yaml are skipped and keep the tags config.yaml gives them. Leave models empty to allow every model. Pass budget_id to attach an existing budget, or max_budget, budget_duration, soft_budget, tpm_limit, rpm_limit, max_parallel_requests and model_max_budget to create one for the tag. Proxy admins only.

Request body (application/json, schema TagNewRequest):

FieldTypeRequiredDescription
namestringYesName
descriptionstring or nullNoDescription
modelsarray of string or nullNoModels
model_infoobject or nullNoModel Info
budget_idstring or nullNoBudget Id
max_budgetnumber or nullNoMax Budget
soft_budgetnumber or nullNoSoft Budget
max_parallel_requestsinteger or nullNoMax Parallel Requests
tpm_limitinteger or nullNoTpm Limit
rpm_limitinteger or nullNoRpm Limit
model_max_budgetobject or nullNoModel Max Budget
budget_durationstring or nullNoBudget Duration

Example request:

curl -X POST "http://localhost:4000/tag/new" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "eu-only",
"description": "Regulated traffic that must stay on EU deployments",
"models": [
"claude-sonnet-5-5-eu"
],
"max_budget": 200,
"budget_duration": "30d"
}'

Responses:

StatusDescriptionBody
200The stored tag.application/json TagWriteResponse
400Tag eu-only already existsapplication/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
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keys or No models configured on proxyapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesConfirmation naming the tag that was created or updated
tagTagConfigYesThe stored tag after the write

POST /tag/update​

Update a tag

Change the description, allowed models or budget of an existing tag. The name cannot change because keys, teams and spend logs refer to it. Fields that are sent replace the stored ones, an explicit null clears a budget field, and fields left out keep their value. Changing models updates the tag's list only and does not add or remove the tag on deployments. Proxy admins only.

Request body (application/json, schema TagUpdateRequest):

FieldTypeRequiredDescription
namestringYesName
descriptionstring or nullNoDescription
modelsarray of string or nullNoModels
model_infoobject or nullNoModel Info
budget_idstring or nullNoBudget Id
max_budgetnumber or nullNoMax Budget
soft_budgetnumber or nullNoSoft Budget
max_parallel_requestsinteger or nullNoMax Parallel Requests
tpm_limitinteger or nullNoTpm Limit
rpm_limitinteger or nullNoRpm Limit
model_max_budgetobject or nullNoModel Max Budget
budget_durationstring or nullNoBudget Duration

Example request:

curl -X POST "http://localhost:4000/tag/update" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "eu-only",
"description": "EU traffic",
"models": [
"claude-sonnet-5-5-eu"
]
}'

Responses:

StatusDescriptionBody
200The tag after the update.application/json TagWriteResponse
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
404Tag eu-only not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Database not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesConfirmation naming the tag that was created or updated
tagTagConfigYesThe stored tag after the write

POST /tag/info​

Read tags by name

Return the stored definition of each named tag, keyed by tag name, with its budget row when it has one. Every name must exist or the whole call is a 404. Proxy admins and admin viewers.

Request body (application/json, schema TagInfoRequest):

FieldTypeRequiredDescription
namesarray of stringYesNames

Example request:

curl -X POST "http://localhost:4000/tag/info" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"names": [
"eu-only"
]
}'

Responses:

StatusDescriptionBody
200The requested tags keyed by name.application/json object
401No valid key was sent, or the key belongs to someone who is not a proxy adminapplication/json ProxyError
404Tags not found: ['eu-only']application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Database not connectedapplication/json ErrorDetail

GET /tag/list​

List tags

List every stored tag and, after them, the tags requests passed in on the fly without a definition. A dynamic tag has no models and a fixed description saying it only records spend. Internal users see only the tags their own keys used.

Parameters:

NameInTypeRequiredDescription
start_datequerystring or nullNoOptional start date (YYYY-MM-DD). When provided together with end_date, dynamic tags are limited to those active in the window. Stored tags are always returned.
end_datequerystring or nullNoOptional end date (YYYY-MM-DD). Must be given with start_date.

Example request:

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

Responses:

StatusDescriptionBody
200Stored tags first, then dynamic spend tags.application/json array of TagConfig
400start_date and end_date must be provided together or start_date must be on or before end_dateapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500Database not connectedapplication/json ErrorDetail

POST /tag/delete​

Delete a tag

Remove a tag definition. Its budget stops applying at once, requests may still carry the name as a plain spend tag, deployments keep the tag in their tags until you remove it there, and the delete is written to the audit log. Proxy admins only.

Request body (application/json, schema TagDeleteRequest):

FieldTypeRequiredDescription
namestringYesName

Example request:

curl -X POST "http://localhost:4000/tag/delete" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "eu-only"
}'

Responses:

StatusDescriptionBody
200The tag was removed.application/json TagDeleteResponse
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
404Tag eu-only not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500Database not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesConfirmation naming the deleted tag

GET /tag/daily/activity​

Daily spend and usage per tag

Return one row per day and tag with requests, tokens and spend, filtered by tags, model, key and a YYYY-MM-DD date range, in pages. Internal users get only the activity of their own keys.

Parameters:

NameInTypeRequiredDescription
tagsquerystring or nullNo
start_datequerystring or nullNo
end_datequerystring or nullNo
modelquerystring or nullNo
api_keyquerystring or nullNo
pagequeryintegerNo
page_sizequeryintegerNo

Example request:

curl -X GET "http://localhost:4000/tag/daily/activity" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200One row per day with the requests, tokens and spend of the selected tags.application/json SpendAnalyticsPaginatedResponse
401No valid key or Admin UI session was presentedapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500Database not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
resultsarray of DailySpendDataYesResults
metadataDailySpendMetadataNo

GET /tag/distinct​

List the user agent tags the gateway has seen

List the user agent tags the gateway has recorded, most used first, up to 250 tags.

Each tag names the client that sent requests, such as User-Agent: claude-cli.

Example request:

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

Responses:

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

Response fields (200):

FieldTypeRequiredDescription
resultsarray of DistinctTagResponseYesResults

GET /tag/dau​

Daily active users per user agent, last 7 days

Count the unique users of each user agent tag per day, for the last 7 days up to and including today (UTC).

Pass tag_filters to limit the answer to some tags. tag_filter takes a single tag and is ignored when tag_filters is given.

Parameters:

NameInTypeRequiredDescription
tag_filterquerystring or nullNoFilter by specific tag (optional)
tag_filtersqueryarray of string or nullNoFilter by multiple specific tags (optional, takes precedence over tag_filter)

Example request:

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

Responses:

StatusDescriptionBody
200Successful responseapplication/json ActiveUsersAnalyticsResponse
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
resultsarray of TagActiveUsersResponseYesResults

GET /tag/wau​

Weekly active users per user agent, last 7 weeks

Count the unique users of each user agent tag per week, for the last 7 weeks up to and including today (UTC).

Weeks are labelled from the oldest, such as Week 1 (Jan 1), to the most recent. Pass tag_filters to limit the answer to some tags. tag_filter takes a single tag and is ignored when tag_filters is given.

Parameters:

NameInTypeRequiredDescription
tag_filterquerystring or nullNoFilter by specific tag (optional)
tag_filtersqueryarray of string or nullNoFilter by multiple specific tags (optional, takes precedence over tag_filter)

Example request:

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

Responses:

StatusDescriptionBody
200Successful responseapplication/json ActiveUsersAnalyticsResponse
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
resultsarray of TagActiveUsersResponseYesResults

GET /tag/mau​

Monthly active users per user agent, last 7 months

Count the unique users of each user agent tag per 30-day month, for the last 7 months up to today (UTC).

Months are labelled from the oldest, such as Month 1 (Nov), to the most recent. Pass tag_filters to limit the answer to some tags. tag_filter takes a single tag and is ignored when tag_filters is given.

Parameters:

NameInTypeRequiredDescription
tag_filterquerystring or nullNoFilter by specific tag (optional)
tag_filtersqueryarray of string or nullNoFilter by multiple specific tags (optional, takes precedence over tag_filter)

Example request:

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

Responses:

StatusDescriptionBody
200Successful responseapplication/json ActiveUsersAnalyticsResponse
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
resultsarray of TagActiveUsersResponseYesResults

GET /tag/summary​

Users, requests, tokens and spend per tag in a date range

One row per tag between start_date and end_date, both YYYY-MM-DD, with unique users, request counts, tokens and spend. tag_filters narrows it to the tags given. Docs (https://docs.spanway.ai/docs/proxy/user_agent_analytics)

Parameters:

NameInTypeRequiredDescription
start_datequerystringYesStart date in YYYY-MM-DD format
end_datequerystringYesEnd date in YYYY-MM-DD format
tag_filterquerystring or nullNoFilter by specific tag (optional)
tag_filtersqueryarray of string or nullNoFilter by multiple specific tags (optional, takes precedence over tag_filter)

Example request:

curl -X GET "http://localhost:4000/tag/summary?start_date=string&end_date=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful responseapplication/json TagSummaryResponse
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
422A field failed validation and the detail names itapplication/json ErrorDetail
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
resultsarray of TagSummaryMetricsYesResults

GET /tag/user-agent/per-user-analytics​

Per user requests, tokens and spend by user agent, last 30 days

Show successful requests, tokens and spend per user for user agent tags, over the last 30 days up to today (UTC).

Pass tag_filters to limit it to some tags (tag_filter takes a single tag and is ignored when tag_filters is given), and page and page_size (50 by default) to page through the users.

Parameters:

NameInTypeRequiredDescription
tag_filterquerystring or nullNoFilter by specific tag (optional)
tag_filtersqueryarray of string or nullNoFilter by multiple specific tags (optional, takes precedence over tag_filter)
pagequeryintegerNoPage number for pagination
page_sizequeryintegerNoItems per page

Example request:

curl -X GET "http://localhost:4000/tag/user-agent/per-user-analytics" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful responseapplication/json PerUserAnalyticsResponse
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
422A field failed validation and the detail names itapplication/json ErrorDetail
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
resultsarray of PerUserMetricsYesResults
total_countintegerYesTotal Count
pageintegerYesPage
page_sizeintegerYesPage Size
total_pagesintegerYesTotal Pages

GET /tag/mcp/active-users​

Daily, weekly or monthly active users per MCP server, tool or MCP client label

Counts the distinct users who called MCP tools in each of the last 7 days, weeks (Monday to Sunday) or calendar months up to today in UTC, split by MCP server, by tool or by MCP client label. A tool called with no server answers with a null key. Client labels come from the mcp_client_id_header header and the aliases in mcp_allowed_clients, so the client split is empty until that header is set. Docs (https://docs.spanway.ai/docs/proxy/mcp_usage_analytics)

Parameters:

NameInTypeRequiredDescription
periodqueryenum: "day", "week", "month"Noday for DAU, week for WAU, month for MAU
dimensionqueryenum: "server", "tool", "client"Noserver, tool or client (the MCP client label)

Example request:

curl -X GET "http://localhost:4000/tag/mcp/active-users" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Active users per key and period, newest firstapplication/json McpActiveUsersResponse
401No valid key, or the key is not a proxy admin or admin viewerapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
periodenum: "day", "week", "month"Yesday, week or month
dimensionenum: "server", "tool", "client"Yesserver, tool or client
start_datestringYesFirst day counted, in UTC
end_datestringYesLast day counted, today in UTC
resultsarray of McpActiveUsersRowYesOne row per key and period, newest period first

GET /tag/mcp/tools​

Calls, failures, spend, users and latency per MCP tool in a date range

One row per MCP tool between start_date and end_date (both included, UTC), with calls, failures, spend, distinct users, average call time and the last day it was used, most called first, at most 500 tools. The range may be up to 366 days. Docs (https://docs.spanway.ai/docs/proxy/mcp_usage_analytics)

Parameters:

NameInTypeRequiredDescription
start_datequerystringYesFirst day, YYYY-MM-DD
end_datequerystringYesLast day, YYYY-MM-DD

Example request:

curl -X GET "http://localhost:4000/tag/mcp/tools?start_date=string&end_date=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Usage per tool, most called firstapplication/json McpToolUsageResponse
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key, or the key is not a proxy admin or admin viewerapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
start_datestringYesFirst day counted, in UTC
end_datestringYesLast day counted, in UTC
resultsarray of McpToolUsageRowYesUp to 500 tools, most called first

GET /tag/mcp/agents​

MCP tool calls per agent, split by MCP server, tool or MCP client label

The Top agents numbers for MCP traffic between start_date and end_date (both included, UTC). Split by server or tool, each row pairs one User-Agent: tag with one server or tool. Split by client, each row is one MCP-Client: tag, because the client label is already the name the admin gave that client. At most 500 rows, most called first. Docs (https://docs.spanway.ai/docs/proxy/mcp_usage_analytics)

Parameters:

NameInTypeRequiredDescription
start_datequerystringYesFirst day, YYYY-MM-DD
end_datequerystringYesLast day, YYYY-MM-DD
dimensionqueryenum: "server", "tool", "client"Noserver, tool or client (the MCP client label)

Example request:

curl -X GET "http://localhost:4000/tag/mcp/agents?start_date=string&end_date=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Calls per agent and key, most called firstapplication/json McpAgentsResponse
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key, or the key is not a proxy admin or admin viewerapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500The gateway hit an internal error, usually the database is not connectedapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
dimensionenum: "server", "tool", "client"Yesserver, tool or client
start_datestringYesFirst day counted, in UTC
end_datestringYesLast day counted, in UTC
resultsarray of McpAgentRowYesUp to 500 rows, most called first