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

# APM

> Where request time goes, which endpoints consume it, what regressed, and distributed traces

These endpoints are served from the per-request APM rollups (and their pre-aggregated metric
equivalents), never from the span store, so they stay fast at any traffic volume. For
operation-level detail see the [Spans API](https://docs.apitraffic.io/api-reference/spans.md).

All APM endpoints require a bearer token with metrics read access, and all times are ISO 8601 in
UTC (`2024-01-15T00:00:00Z`).

## Time Breakdown

<api-endpoint method="GET" url="https://api.apitraffic.io/v1/accounts/{accountSid}/apm/breakdown" />

Where request time went — database, cache, outbound HTTP, queue/RPC and application — as a summary
and as a time series.

### Path Parameters

**accountSid** `string` *required*

Account identifier (format: `acc_` followed by 27 alphanumeric characters)

### Query Parameters

**startTime** `string` *required*

Start of the window (ISO 8601, UTC)

**endTime** `string` *required*

End of the window (ISO 8601, UTC)

**bucketSid** `string`

Limit to one bucket

**environmentSid** `string`

Limit to one environment

**endpoint** `string`

Limit the breakdown to one normalized endpoint

### Response

**summary** `object`

Totals for the window: `requestCount`, `errorCount`, `totalMs`, `dbMs`, `cacheMs` (Redis and
other caches combined), `httpOutMs`, `queueMs` (queue and RPC combined), `appMs` (residual
in-process time, floored at 0), `spanCount`, `p50Ms`, `p95Ms`, `p99Ms`.

**timeseries** `array`

The same fields per bucket, plus `bucket` (bucket start) and `p95Ms`. The bucket width is derived
from the requested range.

**rollup** `boolean`

True when the answer came from the pre-aggregated metrics tables rather than the request rows.

```bash cURL theme={null}
curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apm/breakdown?startTime=2024-01-15T00:00:00Z&endTime=2024-01-16T00:00:00Z" \
  -H "Authorization: Bearer your-jwt-token"
```

```javascript Node.js theme={null}
const params = new URLSearchParams({
  startTime: '2024-01-15T00:00:00Z',
  endTime: '2024-01-16T00:00:00Z'
});

const response = await fetch(`https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apm/breakdown?${params}`, {
  headers: { 'Authorization': 'Bearer your-jwt-token' }
});

const breakdown = await response.json();
```

```json Response theme={null}
{
  "summary": {
    "requestCount": 128400,
    "errorCount": 312,
    "totalMs": 9120000,
    "dbMs": 4380000,
    "cacheMs": 210000,
    "httpOutMs": 1560000,
    "queueMs": 84000,
    "appMs": 2886000,
    "spanCount": 1042330,
    "p50Ms": 41,
    "p95Ms": 210,
    "p99Ms": 940
  },
  "timeseries": [
    {
      "bucket": "2024-01-15T00:00:00Z",
      "requestCount": 5310,
      "errorCount": 9,
      "totalMs": 372000,
      "dbMs": 180000,
      "cacheMs": 8600,
      "httpOutMs": 62000,
      "queueMs": 3400,
      "appMs": 118000,
      "spanCount": 43120,
      "p95Ms": 198
    }
  ],
  "rollup": true
}
```

## Endpoints By Time Consumed

<api-endpoint method="GET" url="https://api.apitraffic.io/v1/accounts/{accountSid}/apm/endpoints" />

Endpoints ranked by the total time they consume, with the same dependency split. Total time, not
average latency, is what identifies where your capacity goes.

### Query Parameters

**startTime** `string` *required*

Start of the window (ISO 8601, UTC)

**endTime** `string` *required*

End of the window (ISO 8601, UTC)

**bucketSid** `string`

Limit to one bucket

**environmentSid** `string`

Limit to one environment

**limit** `number`

Maximum endpoints to return (1–1000, default 50)

### Response

**points** `array`

Each entry carries `endpoint`, `requestCount`, `errorCount`, `averageDurationMs`, `p95Ms`,
`p99Ms`, `lastSeen`, and the span-time fields (`totalMs`, `dbMs`, `cacheMs`, `httpOutMs`,
`queueMs`, `appMs`, `spanCount`).

```bash cURL theme={null}
curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apm/endpoints?startTime=2024-01-15T00:00:00Z&endTime=2024-01-16T00:00:00Z&limit=25" \
  -H "Authorization: Bearer your-jwt-token"
```

```json Response theme={null}
{
  "points": [
    {
      "endpoint": "GET /v1/orders/{id}",
      "requestCount": 41200,
      "errorCount": 22,
      "averageDurationMs": 86,
      "p95Ms": 240,
      "p99Ms": 810,
      "totalMs": 3543200,
      "dbMs": 2410000,
      "cacheMs": 41000,
      "httpOutMs": 320000,
      "queueMs": 0,
      "appMs": 772200,
      "spanCount": 412000,
      "lastSeen": "2024-01-15T23:59:41Z"
    }
  ]
}
```

## Regressions

<api-endpoint method="GET" url="https://api.apitraffic.io/v1/accounts/{accountSid}/apm/regressions" />

Endpoints whose latency or error rate moved against a baseline window, ranked by the time the
change costs.

### Query Parameters

**startTime** `string` *required*

Start of the current window (ISO 8601, UTC)

**endTime** `string` *required*

End of the current window (ISO 8601, UTC)

**bucketSid** `string`

Limit to one bucket

**environmentSid** `string`

Limit to one environment

**baseline** `string`

`previous` (default) compares against the window immediately before; `weekAgo` compares against
the same window seven days earlier, which suits traffic with a weekly shape.

**minRequests** `number`

Ignore endpoints below this request count in either window (default 20)

**limit** `number`

Maximum endpoints to return (1–1000, default 20)

### Response

**baseline** `string`

The baseline that was applied.

**points** `array`

Each entry carries `endpoint`, `requestCount`, `baselineRequestCount`, `p95Ms`, `baselineP95Ms`,
`p95DeltaPct`, `errorRate`, `baselineErrorRate`, `errorRateDelta`, `totalMs`, `baselineTotalMs`
and `score` (latency/error movement weighted by traffic — the ranking).

> [!NOTE]
>
> If the baseline window falls outside your retention, the comparison is skipped rather than
> silently compared against a clamped, overlapping window — the response comes back with no points.

```bash cURL theme={null}
curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apm/regressions?startTime=2024-01-15T00:00:00Z&endTime=2024-01-16T00:00:00Z&baseline=weekAgo" \
  -H "Authorization: Bearer your-jwt-token"
```

```json Response theme={null}
{
  "baseline": "weekAgo",
  "points": [
    {
      "endpoint": "GET /v1/orders/{id}",
      "baseline": "weekAgo",
      "requestCount": 41200,
      "baselineRequestCount": 39800,
      "p95Ms": 240,
      "baselineP95Ms": 120,
      "p95DeltaPct": 100,
      "errorRate": 0.05,
      "baselineErrorRate": 0.04,
      "errorRateDelta": 0.01,
      "totalMs": 3543200,
      "baselineTotalMs": 1990000,
      "score": 4128.5
    }
  ]
}
```

## Distributed Trace

<api-endpoint method="GET" url="https://api.apitraffic.io/v1/accounts/{accountSid}/apm/trace" />

Every request that belongs to one trace, in time order. The trace id is stamped on each request at
ingest — from the inbound `traceparent` header when present, otherwise from the first span — so
this is an equality lookup rather than a walk over span parentage.

### Query Parameters

**traceId** `string` *required*

Trace id shared by the requests in the trace

**startTime** `string` *required*

Start of the window to search (ISO 8601, UTC)

**endTime** `string` *required*

End of the window to search (ISO 8601, UTC)

**bucketSid** `string`

Limit to one bucket

**environmentSid** `string`

Limit to one environment

**limit** `number`

Maximum requests to return (1–1000, default 100)

### Response

**traceId** `string`

The trace that was resolved.

**points** `array`

Each entry carries `dt`, `sid`, `endpoint`, `method`, `host`, `path`, `direction`, `bucketSid`,
`environmentSid`, `statusCode`, `durationMs` and `spanCount`.

```bash cURL theme={null}
curl -X GET "https://api.apitraffic.io/v1/accounts/acc_abc123def456ghi789jkl012/apm/trace?traceId=4bf92f3577b34da6a3ce929d0e0e4736&startTime=2024-01-15T12:00:00Z&endTime=2024-01-15T13:00:00Z" \
  -H "Authorization: Bearer your-jwt-token"
```

```json Response theme={null}
{
  "traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
  "points": [
    {
      "dt": "2024-01-15T12:04:11Z",
      "sid": "req_abc123def456ghi789jkl012mno",
      "endpoint": "POST /v1/checkout",
      "method": "POST",
      "host": "api.example.com",
      "path": "/v1/checkout",
      "direction": "in",
      "bucketSid": "bkt_xyz789uvw012rst345abc",
      "environmentSid": "env_abc123def456ghi789jkl012",
      "statusCode": 200,
      "durationMs": 412,
      "spanCount": 18
    }
  ]
}
```


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