---
title: "Get a trace by ID"
method: GET
path: "/api/v2/trace/{trace_id}"
tags: ["APM Trace"]
---

# Get a trace by ID

`GET /api/v2/trace/{trace_id}`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/trace/{trace_id}`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `apm_read`

Retrieve a full APM trace by its trace ID, including every span in the trace.
Traces are returned from live storage when available and fall back to longer-term storage.
This endpoint is rate limited to `60` requests per minute per organization.

## Path parameters

- `trace_id` string, required

## Query parameters

- `include_fields` string[]

## Response `200`

OK

- TraceResponse: Response containing a single trace.
  - `data` TraceData, required: A trace resource document.
    - `attributes` TraceAttributes, required: The attributes of a trace returned by the Get trace by ID endpoint.
      - `is_truncated` boolean, required: Indicates whether the trace was truncated because its size exceeded the maximum response payload.
      - `spans` APMTraceSpan[], required: The list of spans that compose the trace.
        - `duration` integer, required: The duration of the span, in nanoseconds.
        - `endTime` integer, required: The end time of the span, in Unix nanoseconds.
        - `error` 0 | 1, required: Error flag for a span. `1` when the span is in error, `0` otherwise.
        - `meta` object, required: String-valued tags attached to the span. Tag keys starting with `_` are filtered out of the response.
        - `metrics` object, required: Numeric metrics attached to the span. Metric keys starting with `_` are filtered out of the response.
        - `name` string, required: The operation name of the span.
        - `parentID` integer, required: The ID of the parent span, or `0` when the span is a trace root.
        - `resource` string, required: The resource that the span describes.
        - `resourceHash` string: A hash of the resource field.
        - `restricted` boolean: Whether access to the span is restricted by the organization's data access policies.
        - `self_time` number, double: The time spent in the span itself, excluding time spent in child spans, in nanoseconds.
        - `service` string, required: The name of the service that emitted the span.
        - `spanID` integer, required: The span ID, as an unsigned 64-bit integer.
        - `startTime` integer, required: The start time of the span, in Unix nanoseconds.
        - `traceID` integer, required: The lower 64 bits of the trace ID, as an unsigned 64-bit integer.
        - `traceIDFull` string, required: The full 128-bit trace ID, encoded as a 32-character hexadecimal string.
        - `type` string, required: The type of the span (for example, `web`, `db`, or `rpc`).
    - `id` string, required: The full 128-bit trace ID, encoded as a 32-character hexadecimal string.
    - `type` 'trace', required: The type of the trace resource. The value is always `trace`.

## Other responses

- `403`: Forbidden
- `404`: Not Found
- `413`: Payload Too Large
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/da68bf029e4c?raw)
