Skip to main content
Traces capture every tool call flowing through Kontext. Each trace groups the events from a single session interaction, including timing, status, and error details. Use traces to debug failures, monitor error rates, and understand usage patterns.

Endpoints

MethodPathPurpose
GET/tracesList traces
GET/traces/statsGet trace statistics
GET/traces/:traceIdGet trace events by trace ID
GET/mcp-eventsList recent MCP events for current user

List traces

curl "https://api.kontext.dev/api/v1/traces?limit=20&agentId=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer $TOKEN"

Query parameters

ParameterTypeDescription
limitintegerItems per page (1—200, default 50)
offsetintegerNumber of items to skip
userIdstringFilter by user ID
sessionIdstringFilter by session ID
agentIdstringFilter by application ID

Trace object

FieldTypeDescription
traceIdstringUnique trace identifier
sessionIdstringSession that produced this trace
startedAtstringISO 8601 timestamp
endedAtstring | nullISO 8601 timestamp (null if in progress)
eventCountnumberTotal events in this trace
okCountnumberEvents with "ok" status
warnCountnumberEvents with "warn" status
errorCountnumberEvents with any error status
agentIdstringApplication ID
agentNamestringApplication name
ownerUserIdstringUser who initiated the trace
ownerEmailstringEmail of the user
agentSessionIdstring?Session ID associated with the trace
agentSessionNamestring?Session name

Get trace statistics

curl "https://api.kontext.dev/api/v1/traces/stats?period=7d" \
  -H "Authorization: Bearer $TOKEN"

Query parameters

ParameterTypeDescription
periodstringTime window: "1d", "7d", or "30d"

Stats response

REST response is the stats object directly. SDK response shape is { stats: <stats object> }.
FieldTypeDescription
totalTracesnumberTotal traces in the period
totalEventsnumberTotal events across all traces
eventCountsobjectBreakdown of events by status
errorRatenumberPercentage of events with error status
latencyobjectLatency percentiles (see below)
bytesTransferredobject{ in: number, out: number } — bytes received and sent
errorsByTypeobject[]Error counts grouped by type
topToolsobject[]Most-called tools with call counts
timelineobject[]Time-bucketed event counts for charting

Latency object

FieldTypeDescription
avgnumberAverage latency in milliseconds
p50numberMedian latency
p95number95th percentile latency
p99number99th percentile latency

Get trace events

curl https://api.kontext.dev/api/v1/traces/aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa \
  -H "Authorization: Bearer $TOKEN"
REST response shape: { "events": [...] }. SDK response shape: { "trace": { ... }, "events": [...] } (the SDK synthesizes trace if the API returns only events).

Event object

FieldTypeDescription
idstringEvent ID
createdAtstringISO 8601 timestamp
sessionIdstringSession identifier from event ingestion
agentIdstringApplication UUID
traceIdstring | nullTrace ID (when present)
apiKeyIdstring | nullAPI key identifier (if applicable)
eventTypestringType of event
statusstring"ok", "warn", "error_remote", "error_proxy", or "error_auth"
durationMsnumber | nullTime taken in milliseconds
integrationIdstring | nullIntegration that handled the call
toolNamestring | nullName of the tool called
errorMessagestring | nullError details (when status is not "ok")
bytesInnumber | nullRequest payload size in bytes
bytesOutnumber | nullResponse payload size in bytes
requestJsonobject | nullRequest payload (when available)
responseJsonobject | nullResponse payload (when available)
parentEventIdstring | nullParent event ID for nested operations
agentSessionIdstring | nullAgent session UUID

Event status values

StatusMeaning
okTool call completed successfully
warnCompleted with warnings (e.g., partial results)
error_remoteThe upstream integration returned an error
error_proxyKontext failed to proxy the request
error_authAuthentication or authorization failure

List MCP events

curl "https://api.kontext.dev/api/v1/mcp-events?limit=100" \
  -H "Authorization: Bearer $TOKEN"
Response shape: { "items": [...] } /mcp-events returns lightweight event records:
FieldTypeDescription
idstringEvent ID
createdAtstringISO 8601 timestamp
agentIdstringApplication UUID
integrationIdstring | nullIntegration UUID
toolNamestring | nullTool name
eventTypestringEvent type
statusstringEvent status