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.
| Method | Path | Summary |
|---|---|---|
| GET | /tag/daily/activity/aggregated | Daily activity per tag |
| GET | /tag/daily/activity/aggregated/keys | Keys ranked by spend for a tag |
| GET | /tag/daily/activity/aggregated/search | Search the keys with activity for a tag |
| GET | /tag/daily/activity/aggregated/model_top_keys | Top keys for one model in a tag |
| GET | /tag/daily/activity/export | Download tag daily activity as CSV or JSON |
| POST | /tag/new | Create a tag |
| POST | /tag/update | Update a tag |
| POST | /tag/info | Read tags by name |
| GET | /tag/list | List tags |
| POST | /tag/delete | Delete a tag |
| GET | /tag/daily/activity | Daily spend and usage per tag |
| GET | /tag/distinct | List the user agent tags the gateway has seen |
| GET | /tag/dau | Daily active users per user agent, last 7 days |
| GET | /tag/wau | Weekly active users per user agent, last 7 weeks |
| GET | /tag/mau | Monthly active users per user agent, last 7 months |
| GET | /tag/summary | Users, requests, tokens and spend per tag in a date range |
| GET | /tag/user-agent/per-user-analytics | Per user requests, tokens and spend by user agent, last 30 days |
| GET | /tag/mcp/active-users | Daily, weekly or monthly active users per MCP server, tool or MCP client label |
| GET | /tag/mcp/tools | Calls, failures, spend, users and latency per MCP tool in a date range |
| GET | /tag/mcp/agents | MCP 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
api_key_limit | query | integer | No | How many top keys to return |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
tags | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/tag/daily/activity/aggregated" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json SpendAnalyticsPaginatedResponse |
| 400 | The date range is invalid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
results | array of DailySpendData | Yes | Results |
metadata | DailySpendMetadata | No |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
offset | query | integer | No | How many rows to skip, for paging |
limit | query | integer | No | How many rows to return |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
tags | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/tag/daily/activity/aggregated/keys" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json DailyActivityKeyPageResponse |
| 400 | The date range is invalid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
api_keys | array of KeySpendActivityRow | Yes | Api Keys |
total_api_keys | integer | Yes | Total Api Keys |
offset | integer | Yes | Offset |
limit | integer | Yes | Limit |
GET /tag/daily/activity/aggregated/search
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
search | query | string | Yes | Text to find in key aliases and key hashes |
limit | query | integer | No | How many rows to return |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
tags | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/tag/daily/activity/aggregated/search?search=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json DailyActivityKeySearchResponse |
| 400 | The date range is invalid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
api_keys | array of KeyActivityRow | Yes | Api 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
model_group | query | string | Yes | The model or model group to rank keys for |
by_model_group | query | boolean | No | Match model_group as a model group, not a model |
limit | query | integer | No | How many rows to return |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
tags | query | string or null | No | |
timezone | query | integer or null | No |
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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json ModelTopKeysResponse |
| 400 | The date range is invalid | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model |
by_model_group | boolean | Yes | By Model Group |
api_keys | array of KeySpendActivityRow | Yes | Api 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
export_type | query | ExportType | No | The breakdown of each row |
format | query | enum: "csv", "json" | No | csv or json |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
tags | query | string or null | No | |
timezone | query | integer or null | No |
Example request:
curl -X GET "http://localhost:4000/tag/daily/activity/export" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Streamed daily activity export | text/csv string |
| 400 | Bad Request | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The caller may not read this scope | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The analytics query failed, the gateway log has the cause | application/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):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name |
description | string or null | No | Description |
models | array of string or null | No | Models |
model_info | object or null | No | Model Info |
budget_id | string or null | No | Budget Id |
max_budget | number or null | No | Max Budget |
soft_budget | number or null | No | Soft Budget |
max_parallel_requests | integer or null | No | Max Parallel Requests |
tpm_limit | integer or null | No | Tpm Limit |
rpm_limit | integer or null | No | Rpm Limit |
model_max_budget | object or null | No | Model Max Budget |
budget_duration | string or null | No | Budget 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:
| Status | Description | Body |
|---|---|---|
| 200 | The stored tag. | application/json TagWriteResponse |
| 400 | Tag eu-only already exists | 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 |
| 500 | DB 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 proxy | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Confirmation naming the tag that was created or updated |
tag | TagConfig | Yes | The 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):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name |
description | string or null | No | Description |
models | array of string or null | No | Models |
model_info | object or null | No | Model Info |
budget_id | string or null | No | Budget Id |
max_budget | number or null | No | Max Budget |
soft_budget | number or null | No | Soft Budget |
max_parallel_requests | integer or null | No | Max Parallel Requests |
tpm_limit | integer or null | No | Tpm Limit |
rpm_limit | integer or null | No | Rpm Limit |
model_max_budget | object or null | No | Model Max Budget |
budget_duration | string or null | No | Budget 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:
| Status | Description | Body |
|---|---|---|
| 200 | The tag after the update. | application/json TagWriteResponse |
| 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 | Tag eu-only not found | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Database not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Confirmation naming the tag that was created or updated |
tag | TagConfig | Yes | The 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):
| Field | Type | Required | Description |
|---|---|---|---|
names | array of string | Yes | Names |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The requested tags keyed by name. | application/json object |
| 401 | No valid key was sent, or the key belongs to someone who is not a proxy admin | application/json ProxyError |
| 404 | Tags not found: ['eu-only'] | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Database not connected | application/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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
start_date | query | string or null | No | Optional 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_date | query | string or null | No | Optional 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:
| Status | Description | Body |
|---|---|---|
| 200 | Stored tags first, then dynamic spend tags. | application/json array of TagConfig |
| 400 | start_date and end_date must be provided together or start_date must be on or before end_date | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Database not connected | application/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):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Name |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The tag was removed. | application/json TagDeleteResponse |
| 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 | Tag eu-only not found | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Database not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Confirmation 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tags | query | string or null | No | |
start_date | query | string or null | No | |
end_date | query | string or null | No | |
model | query | string or null | No | |
api_key | query | string or null | No | |
page | query | integer | No | |
page_size | query | integer | No |
Example request:
curl -X GET "http://localhost:4000/tag/daily/activity" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | One row per day with the requests, tokens and spend of the selected tags. | application/json SpendAnalyticsPaginatedResponse |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | Database not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
results | array of DailySpendData | Yes | Results |
metadata | DailySpendMetadata | No |
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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json DistinctTagsResponse |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 500 | The gateway hit an internal error, usually the database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
results | array of DistinctTagResponse | Yes | Results |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tag_filter | query | string or null | No | Filter by specific tag (optional) |
tag_filters | query | array of string or null | No | Filter 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json ActiveUsersAnalyticsResponse |
| 401 | No valid key or Admin UI session was presented | 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 |
|---|---|---|---|
results | array of TagActiveUsersResponse | Yes | Results |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tag_filter | query | string or null | No | Filter by specific tag (optional) |
tag_filters | query | array of string or null | No | Filter 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json ActiveUsersAnalyticsResponse |
| 401 | No valid key or Admin UI session was presented | 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 |
|---|---|---|---|
results | array of TagActiveUsersResponse | Yes | Results |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tag_filter | query | string or null | No | Filter by specific tag (optional) |
tag_filters | query | array of string or null | No | Filter 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json ActiveUsersAnalyticsResponse |
| 401 | No valid key or Admin UI session was presented | 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 |
|---|---|---|---|
results | array of TagActiveUsersResponse | Yes | Results |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
start_date | query | string | Yes | Start date in YYYY-MM-DD format |
end_date | query | string | Yes | End date in YYYY-MM-DD format |
tag_filter | query | string or null | No | Filter by specific tag (optional) |
tag_filters | query | array of string or null | No | Filter 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json TagSummaryResponse |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 422 | A field failed validation and the detail names it | application/json ErrorDetail |
| 500 | The gateway hit an internal error, usually the database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
results | array of TagSummaryMetrics | Yes | Results |
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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tag_filter | query | string or null | No | Filter by specific tag (optional) |
tag_filters | query | array of string or null | No | Filter by multiple specific tags (optional, takes precedence over tag_filter) |
page | query | integer | No | Page number for pagination |
page_size | query | integer | No | Items per page |
Example request:
curl -X GET "http://localhost:4000/tag/user-agent/per-user-analytics" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json PerUserAnalyticsResponse |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 422 | A field failed validation and the detail names it | application/json ErrorDetail |
| 500 | The gateway hit an internal error, usually the database is not connected | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
results | array of PerUserMetrics | Yes | Results |
total_count | integer | Yes | Total Count |
page | integer | Yes | Page |
page_size | integer | Yes | Page Size |
total_pages | integer | Yes | Total 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
period | query | enum: "day", "week", "month" | No | day for DAU, week for WAU, month for MAU |
dimension | query | enum: "server", "tool", "client" | No | server, 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:
| Status | Description | Body |
|---|---|---|
| 200 | Active users per key and period, newest first | application/json McpActiveUsersResponse |
| 401 | No valid key, or the key is not a proxy admin or admin viewer | application/json ProxyError |
| 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 |
|---|---|---|---|
period | enum: "day", "week", "month" | Yes | day, week or month |
dimension | enum: "server", "tool", "client" | Yes | server, tool or client |
start_date | string | Yes | First day counted, in UTC |
end_date | string | Yes | Last day counted, today in UTC |
results | array of McpActiveUsersRow | Yes | One 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
start_date | query | string | Yes | First day, YYYY-MM-DD |
end_date | query | string | Yes | Last 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:
| Status | Description | Body |
|---|---|---|
| 200 | Usage per tool, most called first | application/json McpToolUsageResponse |
| 400 | The request is malformed or breaks a rule named in the detail | application/json ErrorDetail |
| 401 | No valid key, or the key is not a proxy admin or admin viewer | application/json ProxyError |
| 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 |
|---|---|---|---|
start_date | string | Yes | First day counted, in UTC |
end_date | string | Yes | Last day counted, in UTC |
results | array of McpToolUsageRow | Yes | Up 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
start_date | query | string | Yes | First day, YYYY-MM-DD |
end_date | query | string | Yes | Last day, YYYY-MM-DD |
dimension | query | enum: "server", "tool", "client" | No | server, 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:
| Status | Description | Body |
|---|---|---|
| 200 | Calls per agent and key, most called first | application/json McpAgentsResponse |
| 400 | The request is malformed or breaks a rule named in the detail | application/json ErrorDetail |
| 401 | No valid key, or the key is not a proxy admin or admin viewer | application/json ProxyError |
| 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 |
|---|---|---|---|
dimension | enum: "server", "tool", "client" | Yes | server, tool or client |
start_date | string | Yes | First day counted, in UTC |
end_date | string | Yes | Last day counted, in UTC |
results | array of McpAgentRow | Yes | Up to 500 rows, most called first |