> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://www.respan.ai/docs/apis/traces/list-traces/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://www.respan.ai/_mcp/server. # List traces POST https://api.respan.ai/api/traces/list/ Content-Type: application/json Returns traces matching the Filters API payload, with pagination. Metadata keys beginning with `_` are reserved for platform use and omitted from span and trace read responses. Reference: https://www.respan.ai/docs/apis/traces/list-traces ## Authentication - `Authorization` header (bearer token, required) — Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer \. 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. - `Authorization` header (bearer token, required) — Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead. ## Request ### Query parameters - `page` (integer, optional, default: 1) — Page number. - `page_size` (integer, optional, default: 50) — Results per page (max 1000). - `sort_by` (string, optional, default: -timestamp) — Field to sort by. Prefix `-` for descending. Common values include `-timestamp`, `-total_cost`, `-duration`, `-total_tokens`, and `-error_count`. - `start_time` (datetime, optional) — Start of time range (ISO 8601). Defaults to one hour before `end_time` when omitted. - `end_time` (datetime, optional) — End of time range (ISO 8601). Defaults to now when omitted. - `environment` (string, optional) — Filter by environment. ### Body (application/json) This endpoint expects an object. - `filters` (Filters, optional) — Each key is a field to filter on, and each value is a condition: `{"": {"operator": "", "value": [...]}}`. A trace 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:** * Trace: `trace_unique_id`, `name` (the workflow name), `customer_identifier`, `environment`, `organization_key_id`, `trace_group_identifier`, `session_identifier`, `root_span_unique_id`, `span_count`, `llm_call_count`, `error_count`, `total_cost`, `total_prompt_tokens`, `total_completion_tokens`, `total_request_tokens`, `duration` (seconds), and `metadata__` (values are strings). * Span fields, which match a trace when any of its spans matches: `span_unique_id`, `span_name`, `span_workflow_name`, `span_parent_id`, `model`, `provider_id`, `deployment_name`, `prompt_id`, `prompt_name`, `prompt_version_number`, `log_type`, `log_method`, `status`, `status_code`, `error_class`, `error_fingerprint`, `cost`, `latency`, `time_to_first_token`, `tokens_per_second`, `routing_time`, `prompt_tokens`, `completion_tokens`, `prompt_cache_hit_tokens`, `prompt_cache_creation_tokens`. Unsupported fields, such as `total_tokens`, return a 400 error. **Example:** ```json { "total_cost": {"operator": "gte", "value": [0.05]}, "model": {"operator": "", "value": ["gpt-5.5"]} } ``` ## Response ### 200 Paginated list of traces. - `count` (integer, required) — Number of results on this page, not the total. Request pages until `next` is null to get every result. - `results` (list of ApiTracesListPostResponsesContentApplicationJsonSchemaResultsItems, required) — Current page of traces. - `next` (string, optional, nullable) — URL for the next page of results. - `previous` (string, optional, nullable) — URL for the previous page of results. ## Errors ### 400 Bad Request Error Bad Request - `error` (string, optional) ### 403 Forbidden Error The API key is missing, invalid or expired. - `detail` (string, required) ### 413 Content Too Large Error The query exceeded the service's memory or execution-time limit. Narrow the time range or add filters before retrying. - `detail` (string, required) ### 429 Too Many Requests Error Rate Limited - `error` (string, optional) ### 500 Internal Server Error Internal Server Error - `error` (string, optional) ## Types ### Filters Each key is a field to filter on, and each value is a condition: `{"": {"operator": "", "value": [...]}}`. A result 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 `[""]`. The fields you can filter on depend on the endpoint; `metadata__` filters custom metadata where the endpoint supports it. - `status` (FilterValue, optional) — A filter condition with an operator and value. - `status_code` (FilterValue, optional) — A filter condition with an operator and value. - `unique_id` (FilterValue, optional) — A filter condition with an operator and value. - `customer_identifier` (FilterValue, optional) — A filter condition with an operator and value. - `thread_identifier` (FilterValue, optional) — A filter condition with an operator and value. - `custom_identifier` (FilterValue, optional) — A filter condition with an operator and value. - `group_identifier` (FilterValue, optional) — A filter condition with an operator and value. - `prompt_id` (FilterValue, optional) — A filter condition with an operator and value. - `trace_unique_id` (FilterValue, optional) — A filter condition with an operator and value. - `span_parent_id` (FilterValue, optional) — A filter condition with an operator and value. - `is_root_span` (FilterValue, optional) — A filter condition with an operator and value. - `span_workflow_name` (FilterValue, optional) — A filter condition with an operator and value. - `span_name` (FilterValue, optional) — A filter condition with an operator and value. - `model` (FilterValue, optional) — A filter condition with an operator and value. - `log_type` (FilterValue, optional) — A filter condition with an operator and value. - `stream` (FilterValue, optional) — A filter condition with an operator and value. - `has_tool_calls` (FilterValue, optional) — Whether the span made tool calls. - `cache_bit` (FilterValue, optional) — Whether the response was served from the Respan cache. - `cache_key` (FilterValue, optional) — A filter condition with an operator and value. - `prompt_tokens` (FilterValue, optional) — A filter condition with an operator and value. - `completion_tokens` (FilterValue, optional) — A filter condition with an operator and value. - `total_tokens` (FilterValue, optional) — A filter condition with an operator and value. - `cost` (FilterValue, optional) — A filter condition with an operator and value. - `latency` (FilterValue, optional) — A filter condition with an operator and value. - `positive_feedback` (FilterValue, optional) — A filter condition with an operator and value. ### ApiTracesListPostResponsesContentApplicationJsonSchemaResultsItems - `id` (string, optional) — Trace identifier. - `trace_unique_id` (string, optional) — Unique trace identifier. - `root_span_unique_id` (string, optional) — Root span ID for the trace. - `unique_organization_id` (string, optional) — Organization unique ID. - `organization_id` (string, optional) — Alias of `unique_organization_id`. - `organization_name` (string, optional) — Organization name when available. - `organization_key_id` (string, optional) — API key identifier used to create the trace. - `environment` (string, optional) — Environment for the trace. - `customer_identifier` (string, optional) — Customer or user identifier. - `start_time` (datetime, optional) — When the trace started. - `end_time` (datetime, optional) — When the trace ended. - `duration` (double, optional) — Total duration in seconds. - `span_count` (integer, optional) — Total spans in the trace. - `llm_call_count` (integer, optional) — Number of LLM-call spans. - `total_cost` (double, optional) — Total cost in USD. - `total_prompt_tokens` (integer, optional) — Sum of prompt tokens. - `total_completion_tokens` (integer, optional) — Sum of completion tokens. - `total_tokens` (integer, optional) — Sum of all tokens. - `error_count` (integer, optional) — Number of error spans. - `name` (string, optional) — Root span name. - `input` (string, optional) — Root span input. API key responses may include full storage-enriched content. - `output` (string, optional) — Root span output. API key responses may include full storage-enriched content. - `metadata` (ApiTracesListPostResponsesContentApplicationJsonSchemaResultsItemsMetadata, optional) — Customer metadata. Keys beginning with `_` are reserved and omitted from customer-facing responses. - `trace_group_identifier` (string, optional) — Workflow or trace-group identifier. - `session_identifier` (string, optional) — Session identifier when present. - `model` (string, optional) — Primary/root model used. - `storage_object_key` (string, optional) — Storage object key for the root span payload when present. ### FilterValue A filter condition with an operator and value. - `value` (list of any, required) — Value(s) to filter by. - `operator` (enum, optional, default: ) — Comparison operator. An empty string means equals. - Allowed values: ``, `not`, `in`, `not_in`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `icontains`, `startswith`, `not_startswith`, `endswith`, `not_endswith`, `empty`, `not_empty` ### ApiTracesListPostResponsesContentApplicationJsonSchemaResultsItemsMetadata Customer metadata. Keys beginning with `_` are reserved and omitted from customer-facing responses. ## Examples **Request** ```json {} ``` **Response** ```json { "count": 150, "results": [ { "id": "trace_abc123", "trace_unique_id": "trace_abc123", "root_span_unique_id": "span_root_123", "organization_id": "org_xyz789", "environment": "prod", "customer_identifier": "user@example.com", "start_time": "2024-01-15T10:30:00Z", "end_time": "2024-01-15T10:30:02.500000Z", "duration": 2.5, "span_count": 5, "llm_call_count": 2, "total_cost": 0.00345, "total_prompt_tokens": 150, "total_completion_tokens": 75, "total_tokens": 225, "error_count": 0, "name": "chat_completion", "input": "[{\"role\": \"user\", \"content\": \"Explain quantum computing\"}]", "output": "{\"role\": \"assistant\", \"content\": \"Quantum computing is...\"}", "metadata": { "user_id": "user123" }, "trace_group_identifier": "workflow_v1", "session_identifier": "session456", "model": "gpt-4" } ], "next": "https://api.respan.ai/api/traces/list/?page=2", "previous": null } ``` **SDK Code** ```python Traces_listTraces_example import requests url = "https://api.respan.ai/api/traces/list/" querystring = {"page":"1","page_size":"50","sort_by":"-total_cost","start_time":"2025-01-01T00:00:00Z","end_time":"2025-01-31T23:59:59Z","environment":"prod"} payload = {} headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers, params=querystring) print(response.json()) ``` ```javascript Traces_listTraces_example const url = 'https://api.respan.ai/api/traces/list/?page=1&page_size=50&sort_by=-total_cost&start_time=2025-01-01T00%3A00%3A00Z&end_time=2025-01-31T23%3A59%3A59Z&environment=prod'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go Traces_listTraces_example package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/traces/list/?page=1&page_size=50&sort_by=-total_cost&start_time=2025-01-01T00%3A00%3A00Z&end_time=2025-01-31T23%3A59%3A59Z&environment=prod" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby Traces_listTraces_example require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/traces/list/?page=1&page_size=50&sort_by=-total_cost&start_time=2025-01-01T00%3A00%3A00Z&end_time=2025-01-31T23%3A59%3A59Z&environment=prod") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` ```java Traces_listTraces_example import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.respan.ai/api/traces/list/?page=1&page_size=50&sort_by=-total_cost&start_time=2025-01-01T00%3A00%3A00Z&end_time=2025-01-31T23%3A59%3A59Z&environment=prod") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php Traces_listTraces_example request('POST', 'https://api.respan.ai/api/traces/list/?page=1&page_size=50&sort_by=-total_cost&start_time=2025-01-01T00%3A00%3A00Z&end_time=2025-01-31T23%3A59%3A59Z&environment=prod', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp Traces_listTraces_example using RestSharp; var client = new RestClient("https://api.respan.ai/api/traces/list/?page=1&page_size=50&sort_by=-total_cost&start_time=2025-01-01T00%3A00%3A00Z&end_time=2025-01-31T23%3A59%3A59Z&environment=prod"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Traces_listTraces_example import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/traces/list/?page=1&page_size=50&sort_by=-total_cost&start_time=2025-01-01T00%3A00%3A00Z&end_time=2025-01-31T23%3A59%3A59Z&environment=prod")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```