---
title: "Read a chat session's execution trace"
method: GET
path: "/chat-sessions/{sessionId}/trace"
tags: ["Chat sessions"]
---

# Read a chat session's execution trace

`GET /chat-sessions/{sessionId}/trace`

Per-turn execution spans: per-tool-call latency, token usage, and indices into the transcript. Same span shape as the eval iteration trace.

**Incremental by default** — returns the LATEST turn, not the whole session, because a session's spans are the largest thing this API emits and the turn you just took is the one you are debugging. Reach older turns with `turnId` or `afterPromptIndex`; use `includeSpans=false` for cheap per-turn summaries.

A turn whose spans could not be read reports `spansUnavailable: true` rather than an empty `spans` array: "made no calls" and "could not fetch" are opposite conclusions.

## Path parameters

- `sessionId` string, required

## Query parameters

- `projectId` string
- `turnId` string
- `afterPromptIndex` integer
- `limit` integer
- `includeSpans` boolean

## Response `200`

The selected turns, ascending by promptIndex.

- ChatSessionTrace
  - `sessionId` string, required
  - `origin` string, nullable, required
  - `traceVersion` 1, required
  - `turnCount` integer, required — Turns the session has in total, so a caller can tell whether the window is the whole story.
  - `turns` ChatSessionTraceTurn[], required
    - `turnId` string, required
    - `promptIndex` integer, required
    - `startedAt` integer, required
    - `endedAt` integer, required
    - `finishReason` string
    - `modelId` string
    - `usage` TurnUsage
      - `inputTokens` integer
      - `outputTokens` integer
      - `totalTokens` integer
    - `spanCount` integer, required
    - `spans` object[] — Same span shape as the eval iteration trace.
    - `spansUnavailable` boolean — The spans could not be read. DISTINCT from an empty `spans` array, which means the turn genuinely made no recorded calls.
    - `spansTruncated` boolean — Fewer spans came back than the turn recorded.
  - `latestPromptIndex` integer

## Other responses

- `400` — Malformed body or parameters.
- `401` — Missing, invalid, revoked, or orphaned key (`UNAUTHORIZED`) — or the **target MCP server** needs an OAuth grant (`OAUTH_REQUIRED`), which is a property of the server, not your key.
- `403` — Key is valid but not allowed to do this.
- `404` — Unknown project, server, or resource.
- `429` — Per-key rate limit exceeded (60 requests/minute sustained, bursts up to 10). Honor `Retry-After` and back off with jitter.
- `500` — Something failed on MCPJam's side.
- `502` — Could not connect to the target MCP server.

---

[API](https://skmtc.net/mcpjam/apis/mcpjam-api.md) · [All operations](https://skmtc.net/mcpjam/apis/mcpjam-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mcpjam/mcpjam-api/revisions/087a1084c020/schema)
