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

# Get trace context bundle

> Returns the trace row, trace_stats row, ordered spans, and issue occurrences for chat/agent context.



## OpenAPI

````yaml https://api.uselemma.ai/openapi.json get /traces/{trace_id}/context
openapi: 3.1.0
info:
  title: Lemma Platform API
  description: Lemma Platform HTTP API for AI observability and workspace operations.
  version: 0.1.0
servers:
  - url: https://api.uselemma.ai
    description: Lemma production API
security:
  - bearerAuth: []
paths:
  /traces/{trace_id}/context:
    get:
      tags:
        - Traces
      summary: Get trace context bundle
      description: >-
        Returns the trace row, trace_stats row, ordered spans, and issue
        occurrences for chat/agent context.
      operationId: get_trace_context
      parameters:
        - name: trace_id
          in: path
          required: true
          description: Trace ID.
          schema:
            type: string
        - name: project_id
          in: query
          required: true
          description: Project ID.
          schema:
            type: string
      responses:
        '200':
          description: Trace context
          content:
            application/json:
              schema:
                type: object
                properties:
                  trace:
                    type: object
                    properties:
                      id:
                        type: string
                      project_id:
                        type: string
                      service_name:
                        type:
                          - string
                          - 'null'
                      created_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
                      updated_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
                      otel_trace_id:
                        type: string
                      ready:
                        type: boolean
                    required:
                      - id
                      - project_id
                      - service_name
                      - created_at
                      - updated_at
                      - otel_trace_id
                      - ready
                    additionalProperties: true
                  stats:
                    type:
                      - object
                      - 'null'
                    additionalProperties: {}
                  spans:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        otel_span_id:
                          type: string
                        parent_otel_span_id:
                          type:
                            - string
                            - 'null'
                        name:
                          type: string
                        kind:
                          type:
                            - string
                            - 'null'
                        start_time_ns:
                          type:
                            - string
                            - 'null'
                        end_time_ns:
                          type:
                            - string
                            - 'null'
                        duration_ms:
                          type:
                            - number
                            - 'null'
                        status_code:
                          type:
                            - string
                            - 'null'
                        status_description:
                          type:
                            - string
                            - 'null'
                        input_tokens:
                          type:
                            - number
                            - 'null'
                        output_tokens:
                          type:
                            - number
                            - 'null'
                        model_name:
                          type:
                            - string
                            - 'null'
                        tps:
                          type:
                            - number
                            - 'null'
                        attributes:
                          type: object
                          additionalProperties: {}
                        events: {}
                      required:
                        - id
                        - otel_span_id
                        - parent_otel_span_id
                        - name
                        - kind
                        - start_time_ns
                        - end_time_ns
                        - duration_ms
                        - status_code
                        - status_description
                        - input_tokens
                        - output_tokens
                        - model_name
                        - tps
                      additionalProperties: true
                  issue_occurrences:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        trace_id:
                          type: string
                        issue_id:
                          type:
                            - string
                            - 'null'
                        title:
                          type: string
                        rationale:
                          type: string
                        source_span_ids:
                          type: array
                          items:
                            type: string
                        evidence_span_ids:
                          type: array
                          items:
                            type: string
                        citations: {}
                        created_at:
                          type: string
                        issue:
                          type:
                            - object
                            - 'null'
                          properties:
                            id:
                              type: string
                            name:
                              type: string
                            status:
                              type: string
                            category:
                              type:
                                - string
                                - 'null'
                            agent_name:
                              type:
                                - string
                                - 'null'
                          required:
                            - id
                            - name
                            - status
                            - category
                            - agent_name
                        issue_name:
                          type: string
                        issue_category:
                          type:
                            - string
                            - 'null'
                      required:
                        - id
                        - title
                        - rationale
                        - source_span_ids
                        - evidence_span_ids
                        - created_at
                      additionalProperties: true
                  issue_extraction:
                    type:
                      - object
                      - 'null'
                    properties:
                      status:
                        type: string
                        enum:
                          - running
                          - completed
                          - skipped
                          - failed
                      reason:
                        type:
                          - string
                          - 'null'
                        enum:
                          - issues_found
                          - no_issues_found
                          - no_spans
                          - unsupported_trace
                          - error
                          - null
                      issue_count:
                        type:
                          - number
                          - 'null'
                      occurrence_count:
                        type:
                          - number
                          - 'null'
                      completed_at:
                        type:
                          - string
                          - 'null'
                        format: date-time
                      error_message:
                        type:
                          - string
                          - 'null'
                    required:
                      - status
                      - reason
                      - issue_count
                      - occurrence_count
                      - completed_at
                    additionalProperties: false
                required:
                  - trace
                  - stats
                  - spans
                  - issue_occurrences
                  - issue_extraction
                additionalProperties: true
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                required:
                  - detail
                additionalProperties: false
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                required:
                  - detail
                additionalProperties: false
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````