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

# Get a trace

For the other ways to fetch a trace's spans, see [Querying traces](https://docs.appsignal.com/api/v2/traces.md#get-the-spans-of-a-trace).

```yaml POST /api/v2/tracing/trace theme={null}
openapi: 3.1.0
info:
  title: AppSignal V2 API
  description: >-
    REST API for metrics, traces, logs, Kubernetes monitoring, and deployment
    tracking.
  license:
    name: ''
  version: 0.1.0
paths:
  /api/v2/tracing/trace:
    post:
      tags:
        - Tracing
      summary: Get a trace
      operationId: trace
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TraceQuery'
            example:
              site_ids:
                - abc123
              trace_id: 5baa0559ff2f4d35f3b2cd90d312bac3
        required: true
      responses:
        '200':
          description: The trace's spans, or an empty array when the trace is not found.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/TraceSpan'
        '400':
          description: Malformed request, or input the server cannot process.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestResponse'
        '401':
          description: Missing or invalid authentication token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Route or resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: External query concurrency limit exceeded; retry shortly.
          headers:
            Retry-After:
              schema:
                type: integer
              description: Seconds to wait before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequestsResponse'
        '500':
          description: Unhandled server-side failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearer_auth: []
        - token_query: []
components:
  schemas:
    BadRequestResponse:
      type: object
      description: >-
        Standard body for HTTP 400 Bad Request responses. Branch on the stable
        `error` slug, display `message` as-is, and read per-error structured
        data from `details`.
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Stable, machine-readable slug identifying the specific error case.
        message:
          type: string
          description: Human-readable message. Safe to log or display to end users.
        details:
          description: >-
            Per-error structured payload. Shape varies by
            [`error`](Self::error).
    ErrorResponse:
      type: object
      description: Error body returned for 401, 404 and 500 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
    TooManyRequestsResponse:
      type: object
      description: Error body returned for 429 responses.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message.
        suggestion:
          type:
            - string
            - 'null'
          description: >-
            A cheaper way to write the request's filter. Only the trace list

            endpoints set it, and only for a filter with a known indexed
            rewrite.
    TraceQuery:
      type: object
      description: The trace to fetch and the sites to search.
      required:
        - site_ids
        - trace_id
      properties:
        site_ids:
          type: array
          items:
            type: string
          description: Sites to search; the token must have access to all of them.
        trace_id:
          type: string
          description: The trace to fetch.
        include_linked_spans:
          type: boolean
          description: Also return spans from other traces that link to this one.
    TraceSpan:
      type: object
      description: A complete span with all its attributes, events and links.
      required:
        - start_time
        - end_time
        - site_id
        - trace_id
        - parent_span_id
        - span_id
        - digest
        - duration
        - trace_state
        - subtrace_root
        - resource_attributes
        - service_name
        - namespace
        - revision
        - scope_name
        - scope_version
        - action_name
        - span_name
        - span_kind
        - span_attributes
        - status_code
        - status_message
        - events.timestamp
        - events.name
        - events.attributes
        - links.trace_id
        - links.span_id
        - links.trace_state
        - links.attributes
      properties:
        start_time:
          type: string
          format: date-time
          description: Timestamp when the span started.
        end_time:
          type: string
          format: date-time
          description: Timestamp when the span ended.
        site_id:
          type: string
          description: Identifier of the site this span belongs to.
        trace_id:
          type: string
          description: Unique identifier for the entire trace.
        parent_span_id:
          type: string
          description: Span ID of the parent span, empty for root spans.
        span_id:
          type: string
          description: Unique identifier for this span.
        digest:
          type: string
          description: Hash digest identifying the span's operation.
        duration:
          type: number
          format: double
          description: Duration of the span in milliseconds.
        trace_state:
          type: string
          description: W3C trace state header value.
        subtrace_root:
          type: boolean
          description: >-
            Whether this span is the root of a subtrace (a separate service
            boundary).
        resource_attributes:
          type: object
          description: Resource-level attributes (e.g. host, service metadata).
          additionalProperties:
            type: string
          propertyNames:
            type: string
        service_name:
          type: string
          description: Name of the service that produced this span.
        namespace:
          type: string
          description: Namespace the span belongs to (e.g. `"web"`, `"background"`).
        revision:
          type: string
          description: >-
            Git revision or deployment identifier active when the span was
            recorded.
        scope_name:
          type: string
          description: >-
            Instrumentation scope name (e.g. the library that produced the
            span).
        scope_version:
          type: string
          description: Instrumentation scope version.
        action_name:
          type: string
          description: Action name for the span (e.g. `"POST /api/users"`).
        span_name:
          type: string
          description: Low-cardinality name of the operation (e.g. `"HTTP GET"`).
        span_kind:
          type: string
          description: Span kind (e.g. `"server"`, `"client"`, `"internal"`).
        span_attributes:
          type: object
          description: Span-level attributes (e.g. HTTP headers, database statements).
          additionalProperties:
            type: string
          propertyNames:
            type: string
        status_code:
          type: string
          description: 'OpenTelemetry status code: `"unset"`, `"ok"` or `"error"`.'
        status_message:
          type: string
          description: Human-readable status message, typically set on error.
        events.timestamp:
          type: array
          items:
            type: string
          description: Timestamps of span events.
        events.name:
          type: array
          items:
            type: string
          description: Names of span events (e.g. `"exception"`).
        events.attributes:
          type: array
          items:
            type: object
            additionalProperties:
              type: string
            propertyNames:
              type: string
          description: Attributes for each span event.
        links.trace_id:
          type: array
          items:
            type: string
          description: Trace IDs of linked spans.
        links.span_id:
          type: array
          items:
            type: string
          description: Span IDs of linked spans.
        links.trace_state:
          type: array
          items:
            type: string
          description: Trace state values of linked spans.
        links.attributes:
          type: array
          items:
            type: object
            additionalProperties:
              type: string
            propertyNames:
              type: string
          description: Attributes for each span link.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: '`Authorization: Bearer <token>`'
    token_query:
      type: apiKey
      in: query
      name: token
      description: >-
        Alternative to the Authorization header: pass the token as a
        `?token=<token>` query parameter.
```


## API Specification

The full API specification for this endpoint is available in the [documentation index](https://docs.appsignal.com/llms.txt).


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