> ## 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.

# Get Session

> Get one session with all its traces for the key's project.

Retention uses the silent list-style clamp rather than a 403: a session
that contains traces older than the plan window degrades to showing only
the in-window traces instead of failing outright.

Args:
    auth (DualStampedAuth): Resolved credential context (API key or user
        session token); scopes the read to its project and stamps the
        rate-limit identity.
    session_id (str): Session to fetch.
    start_after (datetime | None): Inclusive lower bound on trace time.
    end_before (datetime | None): Exclusive upper bound on trace time.

Returns:
    SessionDetailResponse: The session overview and its traces.

Raises:
    HTTPException: 404 if the session is missing or outside the key's
        project, 500 on a reader failure.



## OpenAPI

````yaml /api-reference/openapi.json get /api/v1/public/sessions/{session_id}
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/{session_id}:
    get:
      tags:
        - Sessions
      summary: Get Session
      description: |-
        Get one session with all its traces for the key's project.

        Retention uses the silent list-style clamp rather than a 403: a session
        that contains traces older than the plan window degrades to showing only
        the in-window traces instead of failing outright.

        Args:
            auth (DualStampedAuth): Resolved credential context (API key or user
                session token); scopes the read to its project and stamps the
                rate-limit identity.
            session_id (str): Session to fetch.
            start_after (datetime | None): Inclusive lower bound on trace time.
            end_before (datetime | None): Exclusive upper bound on trace time.

        Returns:
            SessionDetailResponse: The session overview and its traces.

        Raises:
            HTTPException: 404 if the session is missing or outside the key's
                project, 500 on a reader failure.
      operationId: get_session
      parameters:
        - in: path
          name: session_id
          required: true
          schema:
            title: Session Id
            type: string
        - description: Only 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 traces at or after this time (inclusive, ISO 8601)
            title: Start After
        - description: Only 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 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/SessionDetailResponse'
          description: Successful Response
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication failed
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Session not found
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
          description: Validation Error
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to get session
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication service unavailable
      security:
        - BearerAuth: []
components:
  schemas:
    SessionDetailResponse:
      description: Session detail with all traces for conversation view.
      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
        last_trace_time:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          title: Last Trace Time
        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
        traces:
          items:
            $ref: '#/components/schemas/SessionTraceItem'
          title: Traces
          type: array
        user_ids:
          items:
            type: string
          title: User Ids
          type: array
      required:
        - session_id
        - traces
        - user_ids
        - trace_count
        - first_trace_time
        - last_trace_time
        - duration_ms
        - total_input_tokens
        - total_output_tokens
      title: SessionDetailResponse
      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
    SessionTraceItem:
      description: Single trace within a session, for conversation view.
      properties:
        duration_ms:
          anyOf:
            - type: number
            - type: 'null'
          title: Duration Ms
        input:
          anyOf:
            - type: string
            - type: 'null'
          title: Input
        name:
          title: Name
          type: string
        output:
          anyOf:
            - type: string
            - type: 'null'
          title: Output
        status:
          title: Status
          type: string
        trace_id:
          title: Trace Id
          type: string
        trace_start_time:
          format: date-time
          title: Trace Start Time
          type: string
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
      required:
        - trace_id
        - name
        - trace_start_time
        - user_id
        - input
        - output
        - duration_ms
        - status
      title: SessionTraceItem
      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.