List span groups with filters
https://api.respan.ai/api/request-logs/groups/Group spans using the same query parameters as GET and optional standard Respan filters in the request body.
Servers
https://api.respan.ai: Respan API Server
Authentication
RespanApiKey
Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.
HTTP scheme: bearer; format: Respan API key.
Authorization: Bearer $RESPAN_API_KEYOr:
DashboardJwt
Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.
HTTP scheme: bearer; format: Dashboard JWT.
Authorization: Bearer $RESPAN_DASHBOARD_JWTQuery parameters
group_by string Optionaltrace and thread use entity rollups.Allowed:
"model", "provider_id", "organization_key_id", "prompt_id", "deployment_id", "deployment_name", "custom_identifier", "customer_identifier", "trace", "thread"Default:
modelsort_by string Optionalnumber_of_requestsstart_time string Optionaldate-timeend_time string Optionaldate-timeenvironment string Optionalpage integer Optional1page_size integer Optional1Maximum:
1000Request body
The request body is optional.
application/json
$ object Optional body
filters object OptionalEach key is a field to filter on, and each value is a condition:
{"<field>": {"operator": "<operator>", "value": [...]}}. Each span, trace or thread must match every condition. To set two conditions on one field, such as a range, pass a list of conditions.Operators:
"" (equals, the default), not, in, not_in, lt, lte, gt, gte, contains, not_contains, icontains (ignores case), startswith, not_startswith, endswith, not_endswith, empty, not_empty. Put values in a list: "" and in match any of the listed values, and not and not_in match none of them. Other operators take one value; for empty and not_empty, send [""].Fields depend on
group_by:-
trace: trace fields such as total_cost, error_count, span_count, customer_identifier and metadata__<key>, plus span fields such as model, which match a trace when any of its spans matches.-
thread: thread fields such as thread_identifier, customer_identifier, number_of_requests, total_cost and total_tokens.- Any other value: span columns, such as
model, provider_id, deployment_name, customer_identifier, custom_identifier, organization_key_id, prompt_id, log_type, status_code, cost, latency, prompt_tokens, completion_tokens and total_request_tokens, plus metadata__<key> (values are strings). Aliases such as total_tokens don’t work.Example:
json<br />{<br /> "status_code": {"operator": "not", "value": [200]},<br /> "metadata__plan": {"operator": "", "value": ["pro"]}<br />}<br />Additional properties are allowed
OpenAPI request schema
{
"type": "object",
"properties": {
"filters": {
"type": "object",
"additionalProperties": true,
"description": "Narrows what's grouped.\n\nEach key is a field to filter on, and each value is a condition: `{\"<field>\": {\"operator\": \"<operator>\", \"value\": [...]}}`. Each span, trace or thread must match every condition. To set two conditions on one field, such as a range, pass a list of conditions.\n\n**Operators:** `\"\"` (equals, the default), `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `icontains` (ignores case), `startswith`, `not_startswith`, `endswith`, `not_endswith`, `empty`, `not_empty`. Put values in a list: `\"\"` and `in` match any of the listed values, and `not` and `not_in` match none of them. Other operators take one value; for `empty` and `not_empty`, send `[\"\"]`.\n\n**Fields** depend on `group_by`:\n- `trace`: trace fields such as `total_cost`, `error_count`, `span_count`, `customer_identifier` and `metadata__<key>`, plus span fields such as `model`, which match a trace when any of its spans matches.\n- `thread`: thread fields such as `thread_identifier`, `customer_identifier`, `number_of_requests`, `total_cost` and `total_tokens`.\n- Any other value: span columns, such as `model`, `provider_id`, `deployment_name`, `customer_identifier`, `custom_identifier`, `organization_key_id`, `prompt_id`, `log_type`, `status_code`, `cost`, `latency`, `prompt_tokens`, `completion_tokens` and `total_request_tokens`, plus `metadata__<key>` (values are strings). Aliases such as `total_tokens` don't work.\n\n**Example:**\n\n```json\n{\n \"status_code\": {\"operator\": \"not\", \"value\": [200]},\n \"metadata__plan\": {\"operator\": \"\", \"value\": [\"pro\"]}\n}\n```"
}
}
}Responses
200
Paginated groups and aggregate metrics.
application/json
$ object Body
count integer Required in parentnext is null to get every result.next string or null Optionalprevious string or null Optionalcurrent_filters object Optionalfilters_data object Optionalresults array<object> Required in parent
results[] object Array item
Additional properties are allowed
results[].date_group string Optionaldate-timeresults[].model string Optionalresults[].provider_id string Optionalresults[].organization_key_id string Optionalresults[].prompt_id string Optionalresults[].deployment_id string Optionalresults[].deployment_name string Optionalresults[].custom_identifier string Optionalresults[].customer_identifier string Optionalresults[].trace_unique_id string Optionalresults[].thread_identifier string Optionalresults[].number_of_requests integer or null Optionalresults[].span_count integer or null Optionalresults[].total_cost number or null Optionalresults[].total_tokens integer or null Optionalresults[].error_count integer or null Optionalresults[].error_percentage number or null Optionalresults[].average_cost number or null Optionalresults[].average_tokens integer or null Optionalresults[].average_latency number or null Optionalresults[].average_ttft number or null Optionalresults[].average_tps number or null Optionalresults[].cache_hit_percentage number or null OptionalOpenAPI response schema
{
"type": "object",
"required": [
"count",
"results"
],
"properties": {
"count": {
"type": "integer",
"description": "Number of results on this page, not the total. Request pages until `next` is null to get every result."
},
"next": {
"type": "string",
"nullable": true
},
"previous": {
"type": "string",
"nullable": true
},
"current_filters": {
"type": "object",
"additionalProperties": true
},
"filters_data": {
"type": "object",
"additionalProperties": true
},
"results": {
"type": "array",
"items": {
"type": "object",
"description": "Aggregated metrics plus the selected group key. Trace and thread groups include their richer entity fields.",
"properties": {
"date_group": {
"type": "string",
"format": "date-time"
},
"model": {
"type": "string"
},
"provider_id": {
"type": "string"
},
"organization_key_id": {
"type": "string"
},
"prompt_id": {
"type": "string"
},
"deployment_id": {
"type": "string"
},
"deployment_name": {
"type": "string"
},
"custom_identifier": {
"type": "string"
},
"customer_identifier": {
"type": "string"
},
"trace_unique_id": {
"type": "string"
},
"thread_identifier": {
"type": "string"
},
"number_of_requests": {
"type": "integer",
"nullable": true
},
"span_count": {
"type": "integer",
"nullable": true
},
"total_cost": {
"type": "number",
"nullable": true
},
"total_tokens": {
"type": "integer",
"nullable": true
},
"error_count": {
"type": "integer",
"nullable": true
},
"error_percentage": {
"type": "number",
"nullable": true
},
"average_cost": {
"type": "number",
"nullable": true
},
"average_tokens": {
"type": "integer",
"nullable": true
},
"average_latency": {
"type": "number",
"nullable": true
},
"average_ttft": {
"type": "number",
"nullable": true
},
"average_tps": {
"type": "number",
"nullable": true
},
"cache_hit_percentage": {
"type": "number",
"nullable": true
}
},
"additionalProperties": true
}
}
}
}400
Unsupported group_by value. Invalid sort_by falls back to number_of_requests.
application/json
$ object Body
error string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string"
}
}
}Example
{
"error": "Not supported group_by value"
}403
The API key is missing, invalid or expired, or it doesn’t grant analytics read access.
application/json
$ object Body
detail string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
}Example
{
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}OpenAPI source
The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.
OpenAPI operation
{
"tags": [
"Spans"
],
"parameters": [
{
"name": "group_by",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": [
"model",
"provider_id",
"organization_key_id",
"prompt_id",
"deployment_id",
"deployment_name",
"custom_identifier",
"customer_identifier",
"trace",
"thread"
],
"default": "model"
},
"description": "Grouping dimension. `trace` and `thread` use entity rollups."
},
{
"name": "sort_by",
"in": "query",
"required": false,
"schema": {
"type": "string",
"default": "number_of_requests"
}
},
{
"name": "start_time",
"in": "query",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "end_time",
"in": "query",
"required": false,
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "environment",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "page",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 1
}
},
{
"name": "page_size",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 1000
}
}
],
"responses": {
"200": {
"description": "Paginated groups and aggregate metrics.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"count",
"results"
],
"properties": {
"count": {
"type": "integer",
"description": "Number of results on this page, not the total. Request pages until `next` is null to get every result."
},
"next": {
"type": "string",
"nullable": true
},
"previous": {
"type": "string",
"nullable": true
},
"current_filters": {
"type": "object",
"additionalProperties": true
},
"filters_data": {
"type": "object",
"additionalProperties": true
},
"results": {
"type": "array",
"items": {
"type": "object",
"description": "Aggregated metrics plus the selected group key. Trace and thread groups include their richer entity fields.",
"properties": {
"date_group": {
"type": "string",
"format": "date-time"
},
"model": {
"type": "string"
},
"provider_id": {
"type": "string"
},
"organization_key_id": {
"type": "string"
},
"prompt_id": {
"type": "string"
},
"deployment_id": {
"type": "string"
},
"deployment_name": {
"type": "string"
},
"custom_identifier": {
"type": "string"
},
"customer_identifier": {
"type": "string"
},
"trace_unique_id": {
"type": "string"
},
"thread_identifier": {
"type": "string"
},
"number_of_requests": {
"type": "integer",
"nullable": true
},
"span_count": {
"type": "integer",
"nullable": true
},
"total_cost": {
"type": "number",
"nullable": true
},
"total_tokens": {
"type": "integer",
"nullable": true
},
"error_count": {
"type": "integer",
"nullable": true
},
"error_percentage": {
"type": "number",
"nullable": true
},
"average_cost": {
"type": "number",
"nullable": true
},
"average_tokens": {
"type": "integer",
"nullable": true
},
"average_latency": {
"type": "number",
"nullable": true
},
"average_ttft": {
"type": "number",
"nullable": true
},
"average_tps": {
"type": "number",
"nullable": true
},
"cache_hit_percentage": {
"type": "number",
"nullable": true
}
},
"additionalProperties": true
}
}
}
}
}
}
},
"400": {
"description": "Unsupported group_by value. Invalid sort_by falls back to number_of_requests.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "Not supported group_by value"
}
}
}
},
"403": {
"description": "The API key is missing, invalid or expired, or it doesn't grant analytics read access.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
},
"example": {
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
}
}
}
},
"security": [
{
"RespanApiKey": []
},
{
"DashboardJwt": []
}
],
"summary": "List span groups with filters",
"operationId": "request_logs_groups_filter",
"description": "Group spans using the same query parameters as GET and optional standard Respan filters in the request body.",
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"filters": {
"type": "object",
"additionalProperties": true,
"description": "Narrows what's grouped.\n\nEach key is a field to filter on, and each value is a condition: `{\"<field>\": {\"operator\": \"<operator>\", \"value\": [...]}}`. Each span, trace or thread must match every condition. To set two conditions on one field, such as a range, pass a list of conditions.\n\n**Operators:** `\"\"` (equals, the default), `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `icontains` (ignores case), `startswith`, `not_startswith`, `endswith`, `not_endswith`, `empty`, `not_empty`. Put values in a list: `\"\"` and `in` match any of the listed values, and `not` and `not_in` match none of them. Other operators take one value; for `empty` and `not_empty`, send `[\"\"]`.\n\n**Fields** depend on `group_by`:\n- `trace`: trace fields such as `total_cost`, `error_count`, `span_count`, `customer_identifier` and `metadata__<key>`, plus span fields such as `model`, which match a trace when any of its spans matches.\n- `thread`: thread fields such as `thread_identifier`, `customer_identifier`, `number_of_requests`, `total_cost` and `total_tokens`.\n- Any other value: span columns, such as `model`, `provider_id`, `deployment_name`, `customer_identifier`, `custom_identifier`, `organization_key_id`, `prompt_id`, `log_type`, `status_code`, `cost`, `latency`, `prompt_tokens`, `completion_tokens` and `total_request_tokens`, plus `metadata__<key>` (values are strings). Aliases such as `total_tokens` don't work.\n\n**Example:**\n\n```json\n{\n \"status_code\": {\"operator\": \"not\", \"value\": [200]},\n \"metadata__plan\": {\"operator\": \"\", \"value\": [\"pro\"]}\n}\n```"
}
}
}
}
}
}
}OpenAPI path metadata
{}Referenced OpenAPI components
{
"securitySchemes": {
"DashboardJwt": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "Dashboard JWT",
"description": "Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.",
"x-fern-bearer": {
"name": "dashboardJwt",
"env": "RESPAN_DASHBOARD_JWT"
}
},
"RespanApiKey": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "Respan API key",
"description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
"x-fern-bearer": {
"name": "respanApiKey",
"env": "RESPAN_API_KEY"
}
}
}
}