> ## Documentation Index
> Fetch the complete documentation index at: https://traceroot.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# List Sessions

> List unique sessions for the caller's project with trace counts.

Args:
    auth (DualStampedAuth): Resolved credential context (API key or user
        session token); scopes the read to its project and stamps the
        rate-limit identity.
    limit (int): Items per page (1-200).
    search_query (str | None): Substring match on session id.
    start_after (datetime | None): Inclusive lower bound on trace time.
    end_before (datetime | None): Exclusive upper bound on trace time.

Returns:
    SessionListResponse: Session summaries, newest first.

Raises:
    HTTPException: 500 on a reader failure.



## OpenAPI

````yaml /api-reference/openapi.json get /api/v1/public/sessions
openapi: 3.1.0
info:
  title: TraceRoot Public API
  version: 0.1.0
servers:
  - description: TraceRoot Cloud
    url: https://app.traceroot.ai
  - description: Self-hosted
    url: '{baseUrl}'
    variables:
      baseUrl:
        default: http://localhost:8000
        description: Your TraceRoot backend URL
security: []
paths:
  /api/v1/public/sessions:
    get:
      tags:
        - Sessions
      summary: List Sessions
      description: |-
        List unique sessions for the caller's project with trace counts.

        Args:
            auth (DualStampedAuth): Resolved credential context (API key or user
                session token); scopes the read to its project and stamps the
                rate-limit identity.
            limit (int): Items per page (1-200).
            search_query (str | None): Substring match on session id.
            start_after (datetime | None): Inclusive lower bound on trace time.
            end_before (datetime | None): Exclusive upper bound on trace time.

        Returns:
            SessionListResponse: Session summaries, newest first.

        Raises:
            HTTPException: 500 on a reader failure.
      operationId: list_sessions
      parameters:
        - description: Items per page
          in: query
          name: limit
          required: false
          schema:
            default: 50
            description: Items per page
            maximum: 200
            minimum: 1
            title: Limit
            type: integer
        - description: Search by session_id
          in: query
          name: search_query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Search by session_id
            title: Search Query
        - description: >-
            Only sessions with traces at or after this time (inclusive, ISO
            8601)
          in: query
          name: start_after
          required: false
          schema:
            anyOf:
              - format: date-time
                type: string
              - type: 'null'
            description: >-
              Only sessions with traces at or after this time (inclusive, ISO
              8601)
            title: Start After
        - description: Only sessions with traces before this time (exclusive, ISO 8601)
          in: query
          name: end_before
          required: false
          schema:
            anyOf:
              - format: date-time
                type: string
              - type: 'null'
            description: Only sessions with traces before this time (exclusive, ISO 8601)
            title: End Before
        - description: >-
            Target project for the request. Required when authenticating with a
            user session token (a user credential is only meaningful scoped to a
            project); for an API key it is optional and, if given, must match
            the key's project.
          in: query
          name: project_id
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              Target project for the request. Required when authenticating with
              a user session token (a user credential is only meaningful scoped
              to a project); for an API key it is optional and, if given, must
              match the key's project.
            title: Project Id
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionListResponse'
          description: Successful Response
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication failed
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to list sessions
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication service unavailable
      security:
        - BearerAuth: []
components:
  schemas:
    SessionListResponse:
      description: Paginated list of sessions.
      properties:
        data:
          items:
            $ref: '#/components/schemas/SessionListItem'
          title: Data
          type: array
        meta:
          $ref: '#/components/schemas/PaginationMeta'
      required:
        - data
        - meta
      title: SessionListResponse
      type: object
    ErrorResponse:
      description: >-
        The canonical public error envelope (matches the gateway's normalized
        shape).
      properties:
        detail:
          title: Detail
          type: string
      required:
        - detail
      title: ErrorResponse
      type: object
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          title: Detail
          type: array
      title: HTTPValidationError
      type: object
    SessionListItem:
      description: Single session with aggregated trace statistics.
      properties:
        duration_ms:
          anyOf:
            - type: number
            - type: 'null'
          title: Duration Ms
        first_trace_time:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: First Trace Time
        input:
          anyOf:
            - type: string
            - type: 'null'
          title: Input
        last_trace_time:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Last Trace Time
        output:
          anyOf:
            - type: string
            - type: 'null'
          title: Output
        session_id:
          title: Session Id
          type: string
        total_cost:
          anyOf:
            - type: number
            - type: 'null'
          title: Total Cost
        total_input_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Total Input Tokens
        total_output_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Total Output Tokens
        trace_count:
          title: Trace Count
          type: integer
        user_ids:
          items:
            type: string
          title: User Ids
          type: array
      required:
        - session_id
        - trace_count
        - user_ids
        - first_trace_time
        - last_trace_time
        - duration_ms
        - total_input_tokens
        - total_output_tokens
        - input
        - output
      title: SessionListItem
      type: object
    PaginationMeta:
      description: Pagination metadata for list responses.
      properties:
        limit:
          title: Limit
          type: integer
        page:
          title: Page
          type: integer
        total:
          title: Total
          type: integer
      required:
        - page
        - limit
        - total
      title: PaginationMeta
      type: object
    ValidationError:
      properties:
        ctx:
          title: Context
          type: object
        input:
          title: Input
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          title: Location
          type: array
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
      type: object
  securitySchemes:
    BearerAuth:
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.