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

# Get Trace

Retrieve all spans for a trace ID. Each span includes its metadata and, when the span generated a request log, the associated `request_log_id`.

## Related

* [Get Request](/reference/get-request)
* [Traces](/running-requests/traces)
* [OpenTelemetry](/features/opentelemetry)


## OpenAPI

````yaml GET /api/public/v2/traces/{trace_id}
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /api/public/v2/traces/{trace_id}:
    get:
      tags:
        - tracking
      summary: Get Trace
      operationId: getTrace
      parameters:
        - name: trace_id
          in: path
          required: true
          schema:
            type: string
          description: The trace ID to retrieve spans for.
          example: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
      responses:
        '200':
          description: Trace detail.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceDetailResponse'
              examples:
                trace:
                  summary: Trace with spans
                  value:
                    success: true
                    trace_id: a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6
                    spans:
                      - id: 1
                        name: llm_call
                        span_id: 1a2b3c4d5e6f7a8b
                        parent_id: null
                        request_log_id: 12345
                        start_time: '2024-04-03T20:57:25Z'
                        end_time: '2024-04-03T20:57:26Z'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          $ref: '#/components/responses/ValidationError'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    TraceDetailResponse:
      type: object
      title: TraceDetailResponse
      required:
        - success
        - trace_id
        - spans
      properties:
        success:
          type: boolean
          enum:
            - true
        trace_id:
          type: string
        spans:
          type: array
          items:
            additionalProperties: true
            type: object
          description: >-
            Spans in this trace. Spans that created request logs include
            request_log_id.
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          default: false
          description: Indicates that the request failed.
        message:
          type: string
          description: Human-readable error message.
        error:
          type: string
          description: Machine-readable or fallback error message.
      additionalProperties: true
      description: >-
        Standard error response. Some legacy endpoints may return either message
        or error.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  responses:
    UnauthorizedError:
      description: Unauthorized - missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ForbiddenError:
      description: Forbidden - API key does not have access to the requested resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Not found - requested resource does not exist or is not accessible.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Validation error - request parameters or body are invalid.
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/HTTPValidationError'
              - $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````