Get a trace

Get the spans of a trace from a source and its connected sources, as a compact tree. Repeated sibling spans under one parent, such as the same query, route or call, are collapsed into one row. Reads at most 5,000 spans of the trace from each source, the newest first. Connected sources are read too.

GET https://telemetry.betterstack.com/api/v4/sources/{source_id}/traces/{trace_id}

URL parameters

source_id
required string
trace_id
required string

Query parameters

start_time
string
end_time
string
team_id
string

Headers

Authorization
required string
200

Response body

{
  "data": {
    "id": "8260a352ac09d8099d76828730511db6",
    "type": "trace",
    "attributes": {
      "trace_id": "8260a352ac09d8099d76828730511db6",
      "start_time": "2026-11-22T16:18:47.901782Z",
      "duration_ms": 67055.097,
      "root_service": "frontend",
      "root_operation": "GET /checkout",
      "span_count": 169,
      "error_count": 2,
      "services": [
        "load-generator",
        "frontend",
        "checkout",
        "payment"
      ],
      "spans": [
        {
          "depth": 0,
          "span_id": "8b72f69cf7620b9c",
          "name": "user_checkout_multi",
          "kind": "internal",
          "span_type": "app",
          "service": "load-generator",
          "source_id": "4689",
          "offset_ms": 336.909,
          "duration_ms": 15512.637,
          "span_count": 1,
          "status": "ok",
          "event_count": 0,
          "detail": "",
          "exceptions": []
        },
        {
          "depth": 1,
          "span_id": "ab74fd4608ddcc2d",
          "parent_span_id": "8b72f69cf7620b9c",
          "name": "user_add_to_cart",
          "kind": "internal",
          "span_type": "app",
          "service": "load-generator",
          "source_id": "4689",
          "offset_ms": 337.203,
          "duration_ms": 494.702,
          "span_count": 4,
          "avg_duration_ms": 123.676,
          "max_duration_ms": 181.529,
          "status": "ok",
          "event_count": 0,
          "detail": "",
          "exceptions": []
        },
        {
          "depth": 2,
          "span_id": "c84588e3c3ba8a81",
          "parent_span_id": "ab74fd4608ddcc2d",
          "name": "POST",
          "kind": "client",
          "span_type": "http",
          "service": "load-generator",
          "source_id": "4689",
          "offset_ms": 833.212,
          "duration_ms": 15012.933,
          "span_count": 1,
          "status": "error",
          "event_count": 0,
          "detail": "POST http://frontend-proxy:8080/api/checkout -> 504",
          "exceptions": []
        }
      ],
      "truncated_row_count": 0,
      "orphaned_span_count": 0,
      "warnings": []
    }
  }
}
401

Response body

{
  "errors": "Invalid Team API token. How to find your Team API token: https://betterstack.com/docs/logs/api/getting-started/#obtaining-a-logtail-api-token"
}
403

Response body

{
  "errors": "You don't have permission to view live tail in this team. Your Better Stack role restricts this action. Ask an organization admin to update your role's permissions."
}
404

Response body

{
  "errors": "Resource with the provided ID was not found"
}
422

Response body

{
  "errors": "Sorry, some values are incorrect",
  "invalid_values": {
    "trace_id": "trace_id must be a trace id: letters, digits, - and _."
  }
}
422

Response attributes

id
string
type
string
trace_id
string
start_time
datetime
duration_ms
number
root_service
string or null
root_operation
string or null
span_count
integer
error_count
integer
services
array of strings
spans
array of objects
spans[].depth
integer
spans[].span_id
string
spans[].parent_span_id
string
spans[].name
string
spans[].kind
string
spans[].span_type
string
spans[].service
string
spans[].source_id
string
spans[].offset_ms
number
spans[].duration_ms
number
spans[].span_count
integer
spans[].avg_duration_ms
number
spans[].max_duration_ms
number
spans[].status
string
spans[].event_count
integer
spans[].detail
string
spans[].exceptions
array of objects
spans[].exceptions[].type
string
spans[].exceptions[].message
string
truncated_row_count
integer
orphaned_span_count
integer
warnings
array of strings

Example cURL

A trace from the last 6 hours
curl --request GET \
  --url "https://telemetry.betterstack.com/api/v4/sources/123456/traces/8260a352ac09d8099d76828730511db6?start_time=now-6h" \
  --header "Authorization: Bearer $TOKEN"