Skip to content
Context docs
Evals API

Traces

Serverhttps://context.example.com/api/v1/evals

A trace session is one conversation with an agent, with every model call, its tokens, cost and errors; traces cover all agent work, not only evaluation runs. The session, call and histogram reads cut a range longer than 90 days (the deployment's default limit) to its most recent 90 days. An organization admin reads every trace, a workspace admin the traces in the workspaces they administer, and anyone else the traces of agents they own and their own chats. The cost dashboard needs organization-wide trace access.


List trace sessions

GET
https://context.example.com/api/v1/evals
/traces/sessions
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

Returns trace sessions one window at a time, latest activity first (ordered by each session's latest call in the range). Follow nextCursor until it is null. The first page fixes three things that the cursor carries through the rest of the walk: the calls stored by the time of that read (window.writtenBy), the range end it used (window.to), and the data source it read (readSource). As a result, every session with such a call is returned once, in last-activity order, with no duplicates; calls stored later appear in the next walk. startedAt is the session's first call, even if it falls before the range; calls, tokens, cost, and duration cover only the range. filters is a JSON-encoded array of filter conditions. totalCount stops at 10,000; totalCountIsCapped: true marks a capped count.

List trace sessions › query Parameters

from
​string · date-time · required

Start of the date range (ISO 8601)

to
​string · date-time · required

End of the date range (ISO 8601)

page
​integer · min: 1

Page number, starting at 1, for table-style paging. Ignored when cursor is set.

Default: 1
cursor
​string

Token from a previous response's nextCursor. Gives stable iteration and is the preferred way to page through results in code. A walk keeps the range end it started with (returned as window.to). A token from the older start-time order, or a malformed token, returns 400 INVALID_CURSOR: start again from the first page.

pageSize
​integer · min: 1 · max: 100

Sessions per page

Default: 15
search
​string · maxLength: 500

Token search over trace text. Terms match as whole tokens (runs of letters, digits, or non-ASCII characters; punctuation and underscores split terms). Matching ignores ASCII case, and every term must match. A * widens a term: zip* matches words starting with zip (zip, zipped, zipping), *ip matches words ending in ip, and *ognit* matches any text containing ognit. A match covers the whole conversation: every turn of a conversation whose text contains all the terms is returned, not only the turn that introduced them, and the terms may appear in different turns. Terms must occur inside the queried time range. Input with no searchable tokens (punctuation only) returns 400. Some time ranges are served from a data source that matches terms by substring instead; readSource in the response says which source served the range.

filters
​string

Send it as JSON in one value, for example filters=[{"field":"success","operator":"equals","value":"false"}]. Any other value is refused with 400.

matchAll
​boolean

Combine filter conditions with AND (true) or with OR (false)

Default: true

List trace sessions › Responses

Successful response

One window of the session list; follow `nextCursor` for the rest
​object[] · required
totalCount
​integer · min: 0 · required

Number of matching sessions for pagination, counted up to a cap of 10,000

totalCountIsCapped
​boolean · required

true when more sessions matched than the cap; totalCount is then the cap, not the exact total

nextCursor
​string | null · required

Token for the next window; null when every matching session has been returned

​object · required

The time range the server searched, so you can display it

readSource
​string · enum · required

Which data source served this range; it decides how search terms match

Enum values:
v2
legacy
searchMode
​string | null · required

How the search was matched, in words (for example, 'zip* (starts with), earlier (whole word)'); null when no search is given

viewerTimeZone
​string | null · required

IANA time zone from the requesting person's profile, for showing dates in their zone; null when no person is behind the request or no zone is set


Get a trace session

GET
https://context.example.com/api/v1/evals
/traces/sessions/{sessionId}
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

An unknown session ID answers 200 with an empty session (turnCount 0, taskId null) and no calls, not 404.

Get a trace session › path Parameters

sessionId
​string · minLength: 1 · required

Trace session ID

Trace session ID

Get a trace session › query Parameters

from
​string · date-time

Optional range start (ISO 8601). When both bounds are given, the server skips data outside the range.

to
​string · date-time

Optional range end (ISO 8601)

cursor
​string

Token from a previous response's nextCursor; omit it for the first window

Get a trace session › Responses

Successful response

One window of session detail, with a summary of the whole session; follow `nextCursor` for the rest
​object · required

Session summary computed over the whole session, not only the returned window. Totals are exact no matter how many windows you have fetched.

​object[] · required

This window's turns, ordered by timestamp, then trace ID, ascending

nextCursor
​string | null · required

Token for the next window; null when the whole session has been returned. You can fetch any amount; keep following windows.

totalCostSource
​string · enum · required

Where the session's totalCost comes from. billing_ledger: the session's calls in scope (inside the requested range, if one is given) belong to task runs, and totalCost is the billed amount for those runs, including sub-agents' and auxiliary calls (null while the billed amount cannot be determined). warehouse: no call in scope belongs to a run, and totalCost is the sum of those calls' costs, which excludes sub-agents.

Enum values:
billing_ledger
warehouse
​required

The workflows of the session's chat, read the same way as in the list row

​object[]

Turn boundaries for this window, computed by the server (turnIndex counts from the start of this window). Present only when the session is stored in the current trace format. When joining windows, offset the indexes by the number of turns collected so far, and merge the first turn into the previous window's last turn when windowStartsMidTurn is true.

windowStartsMidTurn
​boolean

true when this window's first calls continue a turn that started in a previous window (no boundary before them); use it to join windows. false or absent when the first turn starts in this window (with user text or compaction) or this is the first window of a continuation session. Current trace format only.


List model calls

GET
https://context.example.com/api/v1/evals
/traces/calls
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

Paginated flat list of calls (one row per model turn), with the same filter and search syntax as the session list but applied to each call. Numeric filters (cost_usd, duration_ms, input_tokens, output_tokens) compare the call's own value rather than a session total. Each row includes sessionId, taskId, taskTitle, agentName, userName, and workspaceName, so the response is self-contained for bulk export. Rows carry inputPreview and outputPreview (first 2048 characters) instead of full input and output; use the session detail endpoint for the full text. totalCount stops at 10,000; totalCountIsCapped: true marks a capped count.

List model calls › query Parameters

from
​string · date-time · required

Start of the date range (ISO 8601)

to
​string · date-time · required

End of the date range (ISO 8601)

page
​integer · min: 1

Page number, starting at 1

Default: 1
pageSize
​integer · min: 1 · max: 100

Calls per page

Default: 15
search
​string · maxLength: 500

Token search over trace text. Terms match as whole tokens (runs of letters, digits, or non-ASCII characters; punctuation and underscores split terms). Matching ignores ASCII case, and every term must match. A * widens a term: zip* matches words starting with zip (zip, zipped, zipping), *ip matches words ending in ip, and *ognit* matches any text containing ognit. A match covers the whole conversation: every turn of a conversation whose text contains all the terms is returned, not only the turn that introduced them, and the terms may appear in different turns. Terms must occur inside the queried time range. Input with no searchable tokens (punctuation only) returns 400. Some time ranges are served from an older data source that matches terms by substring instead; this response does not say which (GET /traces/sessions does, in readSource).

filters
​string

Send it as JSON in one value, for example filters=[{"field":"success","operator":"equals","value":"false"}]. Any other value is refused with 400.

matchAll
​boolean

Combine filter conditions with AND (true) or with OR (false)

Default: true

List model calls › Responses

Successful response

Paginated flat list of calls
​object[] · required
totalCount
​integer · min: 0 · required

Number of matching calls for pagination, counted up to a cap of 10,000

totalCountIsCapped
​boolean · required

true when more calls matched than the cap; totalCount is then the cap, not the exact total


Get a message part's full content

GET
https://context.example.com/api/v1/evals
/traces/payloads
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

Looks up the raw JSON of one stored message part by key (complete tool results, every nested field). The session detail endpoint returns the key fields (chatId, messageId, partIndex, day) on each part's payloadKey; pass them back unchanged. Returns 404 for unknown keys.

Get a message part's full content › query Parameters

chatId
​string · minLength: 1 · required

Stable conversation ID the part belongs to

messageId
​string · minLength: 1 · required

ID of the message (msg_...) that owns the part

partIndex
​integer · min: 0 · required

Position of the part within its source array (an identifier, not a dense sequence)

day
​string · pattern: ^\d{4}-\d{2}-\d{2}$ · required

Date of the trace row that introduced the part (YYYY-MM-DD); narrows the lookup to one day

Get a message part's full content › Responses

Successful response

Full payload for one stored message part
payload
​string · required

Raw part JSON exactly as stored (complete tool results, every nested field)

partType
​string · required

Raw part type: text, tool, file, step-start, compaction, and others


Get the session histogram

GET
https://context.example.com/api/v1/evals
/traces/histogram
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

Counts the sessions matching the filters over time: each bucket holds its sessions and the ones with at least one failure. Buckets are hourly for a range of up to 7 days, daily up to 90 days and weekly beyond that.

Get the session histogram › query Parameters

from
​string · date-time · required

Start of the date range (ISO 8601)

to
​string · date-time · required

End of the date range (ISO 8601)

search
​string · maxLength: 500

Token search over trace text. Terms match as whole tokens (runs of letters, digits, or non-ASCII characters; punctuation and underscores split terms). Matching ignores ASCII case, and every term must match. A * widens a term: zip* matches words starting with zip (zip, zipped, zipping), *ip matches words ending in ip, and *ognit* matches any text containing ognit. A match covers the whole conversation: every turn of a conversation whose text contains all the terms is returned, not only the turn that introduced them, and the terms may appear in different turns. Terms must occur inside the queried time range. Input with no searchable tokens (punctuation only) returns 400. Some time ranges are served from an older data source that matches terms by substring instead; this response does not say which (GET /traces/sessions does, in readSource).

filters
​string

Send it as JSON in one value, for example filters=[{"field":"success","operator":"equals","value":"false"}]. Any other value is refused with 400.

matchAll
​boolean
Default: true

Get the session histogram › Responses

Successful response

Session counts over time
​object[] · required

List trace filter values

GET
https://context.example.com/api/v1/evals
/traces/filter-options
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

Returns the values you can filter traces by, read from the last 90 days of traces you can see: models, providers, agents, users, workspaces and skills. The workspace list is capped, and workspacesTruncated says when it is incomplete.

List trace filter values › Responses

Successful response

Available values for filters
models
​string[] · required

Distinct model names from recent traces

providers
​string[] · required

Distinct provider names from recent traces

​object[] · required

Agents with trace data

​object[] · required

Users who own agents with trace data

​object[] · required

First page of workspaces that appear in recent traces, with names (capped; see workspacesTruncated). Search for workspaces in the app to find the full set.

workspacesTruncated
​boolean · required

true when more workspaces appear in recent traces than this list holds, so the list is incomplete

​object[] · required

Skills invoked in recent traces, with names


Get an agent's usage profile

GET
https://context.example.com/api/v1/evals
/traces/agents/{agentId}/profile
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

Returns one agent's usage from since to until (now by default): its sessions, cost, duration and tokens, the models it used and its cost per day. An agent with no traces in the range, or one you can't read, returns a profile of zeros.

Get an agent's usage profile › path Parameters

agentId
​string · minLength: 1 · required

Agent ID

Agent ID

Get an agent's usage profile › query Parameters

since
​string · date-time · required
until
​string · date-time

Get an agent's usage profile › Responses

Successful response

totalSessions
​integer · min: 0 · required

Total number of sessions

totalCost
​number · min: 0 · required

Total cost in USD

totalDurationMs
​number · min: 0 · required

Total duration in milliseconds

avgSessionDurationMs
​number · min: 0 · required

Average session duration in milliseconds

avgCostPerSession
​number · min: 0 · required

Average cost per session in USD

totalTokens
​integer · min: 0 · required

Billed tokens (input, output, reasoning, cache write, and cache read)

models
​string[] · required

Distinct models used

​object[] · required

Daily cost breakdown, oldest date first

​object[]

Per-model cost and token usage


Get a user's usage profile

GET
https://context.example.com/api/v1/evals
/traces/users/{userId}/profile
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

Returns one person's usage from since to until (now by default): their sessions, cost, duration and tokens, the models and agents they used and their cost per day. Work an evaluation started, such as runs, judges and monitors, is not counted.

Get a user's usage profile › path Parameters

userId
​string · minLength: 1 · required

User ID

User ID

Get a user's usage profile › query Parameters

since
​string · date-time · required
until
​string · date-time

Get a user's usage profile › Responses

Successful response

totalSessions
​integer · min: 0 · required

Total number of sessions

totalCost
​number · min: 0 · required

Total cost in USD

totalDurationMs
​number · min: 0 · required

Total duration in milliseconds

avgSessionDurationMs
​number · min: 0 · required

Average session duration in milliseconds

avgCostPerSession
​number · min: 0 · required

Average cost per session in USD

totalTokens
​integer · min: 0 · required

Billed tokens (input, output, reasoning, cache write, and cache read)

models
​string[] · required

Distinct models used

​object[] · required

Daily cost breakdown, oldest date first

​object[] · required

Per-agent usage breakdown

​object[]

Per-model cost and token usage


Get the cost dashboard

GET
https://context.example.com/api/v1/evals
/traces/cost-dashboard
Bearer (tsk_<prefix>_<secret>)
or
X-API-Key (header)

Returns the organization's cost from since to until (now by default): a row per agent with its trend against the previous period of the same length, organization totals, cost per day, media and image generation cost, and cost per skill. It needs organization-wide trace access.

Get the cost dashboard › query Parameters

since
​string · date-time · required

Start date (ISO 8601)

until
​string · date-time

End date (ISO 8601); defaults to now

Get the cost dashboard › Responses

Successful response

​object[] · required

Per-agent cost rows, highest totalCost first (includes media generation cost)

orgTotalCost
​number · min: 0 · required

Organization-wide total cost in USD for the period, including media and image generation

orgTotalSessions
​integer · min: 0 · required

Organization-wide total sessions for the period

orgAvgCostPerSession
​number · min: 0 · required

Organization-wide average cost per session in USD

orgTotalDurationMs
​number · min: 0 · required

Organization-wide total session duration in milliseconds

​object[] · required

Daily cost breakdown, oldest date first (includes media generation cost)

​object · required

Media and image generation share of the period's spend

​object[] · required

Per-skill cost for the current period, highest totalCost first. Estimated provider cost only. Empty when the period's costs come from billing records, which do not track skills.