---
title: "Get Trace Statistics by Session"
method: GET
path: "/trace_session_stats"
tags: ["Traces", "Traces"]
---

# Get Trace Statistics by Session

`GET /trace_session_stats`

Retrieve aggregated trace statistics grouped by session ID with pagination.

**Provides insights into:**
- Total traces per session
- First and last trace timestamps per session
- Associated user and agent information

**Filtering Options:**
- By user ID
- By agent ID

**Use Cases:**
- Monitor session-level activity
- Track conversation flows
- Identify high-activity sessions
- Analyze user engagement patterns

## Query parameters

- `user_id` string, nullable — Filter by user ID
- `agent_id` string, nullable — Filter by agent ID
- `team_id` string, nullable — Filter by team ID
- `workflow_id` string, nullable — Filter by workflow ID
- `start_time` string, nullable — Filter sessions with traces created after this time (ISO 8601 format with timezone, e.g., '2025-11-19T10:00:00Z' or '2025-11-19T15:30:00+05:30'). Times are converted to UTC for comparison.
- `end_time` string, nullable — Filter sessions with traces created before this time (ISO 8601 format with timezone, e.g., '2025-11-19T11:00:00Z' or '2025-11-19T16:30:00+05:30'). Times are converted to UTC for comparison.
- `page` integer — Page number (1-indexed)
- `limit` integer — Number of sessions per page
- `db_id` string, nullable — Database ID to query statistics from

## Response `200`

Trace statistics retrieved successfully

- PaginatedResponseTraceSessionStats
  - `data` TraceSessionStats[], required — List of items for the current page
    - `session_id` string, required — Session identifier
    - `user_id` string, nullable — User ID associated with the session
    - `agent_id` string, nullable — Agent ID(s) used in the session
    - `team_id` string, nullable — Team ID associated with the session
    - `workflow_id` string, nullable — Workflow ID associated with the session
    - `total_traces` integer, required — Total number of traces in this session
    - `first_trace_at` string, date-time, required — Time of first trace (Pydantic auto-serializes to ISO 8601)
    - `last_trace_at` string, date-time, required — Time of last trace (Pydantic auto-serializes to ISO 8601)
  - `meta` PaginationInfo, required
    - `page` integer — Current page number (0-indexed)
    - `limit` integer — Number of items per page
    - `total_pages` integer — Total number of pages
    - `total_count` integer — Total count of items
    - `search_time_ms` number — Search execution time in milliseconds

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `404` — Not Found
- `422` — Validation Error
- `500` — Failed to retrieve statistics

---

[API](https://skmtc.net/agno/apis/agno-api-reference.md) · [All operations](https://skmtc.net/agno/apis/agno-api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/agno/agno-api-reference/revisions/5f6149d395d0/schema)
