Skip to main content

Agent tracing API

This page documents the 17 gateway endpoints tagged agent tracing in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.

MethodPathSummary
GET/v1/traces/searchSearch the text of agent traces
GET/v1/traces/sessionsList conversation sessions
GET/v1/traces/sessions/{session_id}Read one session as a thread
GET/v1/traces/{trace_id}/graphRead the agent graph of one trace
GET/v1/traces/{trace_id}/commentsList the comments on a trace
POST/v1/traces/{trace_id}/commentsComment on a trace
PATCH/v1/traces/{trace_id}/comments/{comment_id}Edit a comment on a trace
DELETE/v1/traces/{trace_id}/comments/{comment_id}Delete a comment on a trace
GET/v1/tracesList agent traces
POST/v1/tracesSend OTLP traces from your app
POST/v1/logsSend OTLP logs from your app
GET/v1/traces/agentsList the agents seen in traces
POST/v1/traces/queryRun a read only SQL query over traces
GET/v1/traces/query/helpDescribe the tables a trace query may use
GET/v1/traces/{trace_id}Read one trace as a page of spans
GET/v1/traces/{trace_id}/spans/{span_id}Read one span in full
GET/v1/traces/{trace_id}/spans/{span_id}/errorPage through a span's error details

Endpoints​

Search the text of agent traces

Find the agent runs whose steps contain every word of q, newest first, with the first matching step and a short snippet around the match. Words are matched anywhere and ignore case, and a "quoted phrase" is matched as written. The search looks inside step inputs, outputs and error messages only when your role may see them (searched_fields says which), and always in trace ids, step names, agent names and models. The window defaults to the last 7 days and may be at most 31 days. A search that looks inside content is written to the audit log as a read, with a hash of the search text, never the text. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#search)

Parameters:

NameInTypeRequiredDescription
qquerystringYesWords or quoted phrases to find
start_msqueryinteger or nullNoWindow start, unix ms. Default: 7 days ago
end_msqueryinteger or nullNoWindow end, unix ms. Default: now
limitqueryintegerNoMost traces to return

Example request:

curl -X GET "http://localhost:4000/v1/traces/search?q=string" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The matching traces, newest firstapplication/json TraceSearchResult
400The window or the search text is not validapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer or the query ran past the reader limits, or the gateway has no master keyapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
querystringYesQuery
termsarray of stringYesTerms
searched_fieldsarray of enum: "input", "output", "error", "name"YesThe fields your role lets the search look inside
start_msintegerYesStart Ms
end_msintegerYesEnd Ms
hitsarray of TraceSearchHitYesHits
truncatedbooleanYesTrue when more traces matched than the limit returned

GET /v1/traces/sessions​

List conversation sessions

List the sessions seen in your traces, most recently active first. A session groups the runs that carry the same session.id attribute (on the span or its resource) or OpenTelemetry gen_ai.conversation.id, for example every turn of one chat. Each row counts its runs, error steps and tokens and names up to 10 agents. contains keeps sessions whose id contains that text. The window defaults to the last 7 days. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#sessions)

Parameters:

NameInTypeRequiredDescription
containsquerystringNoKeep sessions whose id contains this
start_msqueryinteger or nullNoWindow start, unix ms. Default: 7 days ago
end_msqueryinteger or nullNoWindow end, unix ms. Default: now
limitqueryintegerNoMost sessions to return

Example request:

curl -X GET "http://localhost:4000/v1/traces/sessions" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The sessions in the windowapplication/json TraceSessionList
400The window or the search text is not validapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer or the query ran past the reader limits, or the gateway has no master keyapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
start_msintegerYesStart Ms
end_msintegerYesEnd Ms
sessionsarray of TraceSessionYesSessions
truncatedbooleanYesTruncated

GET /v1/traces/sessions/{session_id}​

Read one session as a thread

Read every run of one session in the order they started, as a conversation: each turn has the run's first input, its final output (each cut to 4,000 characters), the agents that took part, its steps, errors and tokens, and the trace id to open it. Pass the session_ref from the session list to keep sessions of other keys that reuse the same id apart. Inputs and outputs your role hides come back as null and are listed in hidden_fields. The window defaults to the trace retention (14 days). Reading a thread is written to the audit log as a content read. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#sessions)

Parameters:

NameInTypeRequiredDescription
session_idpathstringYes
session_refquerystringNo
start_msqueryinteger or nullNoWindow start, unix ms. Default: 14 days ago
end_msqueryinteger or nullNoWindow end, unix ms. Default: now
limitqueryintegerNoMost turns to return

Example request:

curl -X GET "http://localhost:4000/v1/traces/sessions/session_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The session's runs as turns, oldest firstapplication/json SessionThread
400The window or the search text is not validapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
404No session with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer or the query ran past the reader limits, or the gateway has no master keyapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
session_idstringYesSession Id
session_refstringYesSession Ref
start_msintegerYesStart Ms
end_msintegerYesEnd Ms
turnsarray of SessionTurnYesTurns
hidden_fieldsarray of stringYesContent your role hides, such as prompts or responses
truncatedbooleanYesTruncated

GET /v1/traces/{trace_id}/graph​

Read the agent graph of one trace

Draw one run as a graph: a node for the run, for every agent, every tool and every model, and an edge for each hand-off from one agent to another and for each tool or model an agent called, with call, error, time and token totals. It reads at most the first 5,000 steps (truncated says when a trace had more). The caller must be able to see the trace, otherwise it answers 404. No prompt or response text is returned, and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#agent-graph)

Parameters:

NameInTypeRequiredDescription
trace_idpathstringYes
trace_refquerystringNo

Example request:

curl -X GET "http://localhost:4000/v1/traces/trace_id-123/graph" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The trace's agents, tools and models and how they called each otherapplication/json AgentGraph
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
404No trace with that id is visible to the callerapplication/json ErrorDetail
409The trace changed while it was read, so try againapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
trace_idstringYesTrace Id
trace_refstringYesTrace Ref
span_countintegerYesSpan Count
nodesarray of GraphNodeYesNodes
edgesarray of GraphEdgeYesEdges
truncatedbooleanYesTrue when the trace had more steps than the graph reads

GET /v1/traces/{trace_id}/comments​

List the comments on a trace

List the comments people left on one trace, oldest first, with who wrote each and whether you may edit it. Anyone who may read the trace may read its comments. Pass the trace_ref from the trace list so comments of another key that reuses the trace id stay apart. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#comments)

Parameters:

NameInTypeRequiredDescription
trace_idpathstringYes
trace_refquerystringNo

Example request:

curl -X GET "http://localhost:4000/v1/traces/trace_id-123/comments" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The trace's commentsapplication/json TraceCommentList
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
404No trace with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
trace_idstringYesTrace Id
trace_refstringYesTrace Ref
commentsarray of TraceCommentYesComments

POST /v1/traces/{trace_id}/comments​

Comment on a trace

Leave a note on a trace, or on one step of it with span_id, for example why a run went wrong or who is looking into it. Anyone who may read the trace may comment, except the read only roles. The text may be up to 4,000 characters and a trace holds at most 500 comments. The new comment is written to the audit log with a hash and the length of its text. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#comments)

Parameters:

NameInTypeRequiredDescription
trace_idpathstringYes

Request body (application/json, schema NewTraceComment):

FieldTypeRequiredDescription
bodystringYesBody
span_idstring or nullNoSpan Id
trace_refstringNoThe trace_ref from the trace list, if known

Example request:

curl -X POST "http://localhost:4000/v1/traces/trace_id-123/comments" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"body": "The refund tool timed out here, the retry picked the wrong order. Filed SUP-812.",
"span_id": "00f067aa0ba902b7",
"trace_ref": "9D3C1E0B7A4F2E6D8C5B1A0F3E2D4C6B8A9F7E5D3C1B0A2F4E6D8C0B2A4F6E8D"
}'

Responses:

StatusDescriptionBody
201The new commentapplication/json TraceComment
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read the trace or has a read only roleapplication/json ErrorDetail
404No trace with that id is visible to the callerapplication/json ErrorDetail
409The trace already holds the most comments allowedapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

PATCH /v1/traces/{trace_id}/comments/{comment_id}​

Edit a comment on a trace

Replace the text of a comment. Only its author or a proxy admin may edit it, and read only roles never can. The change is written to the audit log with a hash and the length of the text before and after. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#comments)

Parameters:

NameInTypeRequiredDescription
trace_idpathstringYes
comment_idpathstringYes
trace_refquerystringNo

Request body (application/json, schema EditTraceComment):

FieldTypeRequiredDescription
bodystringYesBody

Example request:

curl -X PATCH "http://localhost:4000/v1/traces/trace_id-123/comments/comment_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"body": "Root cause found: the order lookup used the wrong customer id."
}'

Responses:

StatusDescriptionBody
200The edited commentapplication/json TraceComment
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read the trace, has a read only role, or did not write the commentapplication/json ErrorDetail
404No trace or no comment with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
comment_idstringYesComment Id
trace_idstringYesTrace Id
trace_refstringYesTrace Ref
span_idstring or nullYesSpan Id
bodystringYesBody
author_user_idstring or nullYesAuthor User Id
author_key_aliasstring or nullYesAuthor Key Alias
created_atstringYesCreated At
updated_atstringYesUpdated At
can_editbooleanNoWhether the caller may edit or delete this comment

DELETE /v1/traces/{trace_id}/comments/{comment_id}​

Delete a comment on a trace

Remove a comment for good and return it one last time. Its author or a proxy admin may delete it, read only roles never can. The removal is written to the audit log with a hash and the length of the text. Docs (https://docs.spanway.ai/docs/proxy/lens/explore#comments)

Parameters:

NameInTypeRequiredDescription
trace_idpathstringYes
comment_idpathstringYes
trace_refquerystringNo

Example request:

curl -X DELETE "http://localhost:4000/v1/traces/trace_id-123/comments/comment_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The comment that was deletedapplication/json TraceComment
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read the trace, has a read only role, or did not write the commentapplication/json ErrorDetail
404No trace or no comment with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway runs without a databaseapplication/json ErrorDetail
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
comment_idstringYesComment Id
trace_idstringYesTrace Id
trace_refstringYesTrace Ref
span_idstring or nullYesSpan Id
bodystringYesBody
author_user_idstring or nullYesAuthor User Id
author_key_aliasstring or nullYesAuthor Key Alias
created_atstringYesCreated At
updated_atstringYesUpdated At
can_editbooleanNoWhether the caller may edit or delete this comment

GET /v1/traces​

List agent traces

List the agent runs the gateway recorded, one summary per trace with its agents, models, tokens, spend and status, newest first. A key with a user sees the traces of its own requests and of the teams where it is a team admin or holds the spend logs permission, proxy admins and admin viewers see every trace, and a key with no user answers 403. The window defaults to the last 24 hours, start_ms and end_ms are unix milliseconds and cursor continues a page. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing)

Parameters:

NameInTypeRequiredDescription
cursorquerystring or nullNo
end_msqueryinteger or nullNoWindow end, unix ms. Default: now
start_msqueryinteger or nullNoWindow start, unix ms. Default: 24h ago

Example request:

curl -X GET "http://localhost:4000/v1/traces" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200One page of trace summariesapplication/json TracePage
400A parameter or the cursor is not validapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
404No trace or span with that id is visible to the callerapplication/json ErrorDetail
409The trace changed while it was paged, so start again without a cursorapplication/json ErrorDetail
413The trace is too large for this viewapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
dataarray of TraceSummaryYesData
next_cursorstring or nullYesNext Cursor

POST /v1/traces​

Send OTLP traces from your app

Accept an OTLP/HTTP trace export from your own application, authenticated with a virtual key, and store the spans in Lens next to the gateway's request records, so one trace shows your app's steps and the model calls they made through the gateway. Send application/x-protobuf or application/json, optionally gzip compressed. The spans are stored under the key's team and user, never under ids the spans claim. Uploads above OTLP_MAX_BODY_BYTES (16 MiB by default, before and after decompression) are refused with 413. Docs (https://docs.spanway.ai/docs/proxy/otlp_intake)

Request body (application/x-protobuf, string):

Request body (application/json, object):

Example request:

curl -X POST "http://localhost:4000/v1/traces" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "research-service"
}
}
]
},
"scopeSpans": [
{
"spans": [
{
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"spanId": "00f067aa0ba902b7",
"name": "plan step",
"startTimeUnixNano": "1795000000000000000",
"endTimeUnixNano": "1795000001200000000"
}
]
}
]
}
]
}'

Responses:

StatusDescriptionBody
200Lens stored the batch. The body is an empty OTLP export responseapplication/json object
400The body or its encoding is not valid OTLPapplication/json object
401No valid virtual key was sentapplication/json object
413The upload is larger than the gateway acceptsapplication/json object
501Lens is not set up on this gateway, so there is nowhere to store spansapplication/json object
503The gateway or Lens is busy or unreachable, retry after Retry-After secondsapplication/json object

POST /v1/logs​

Send OTLP logs from your app

Accept an OTLP/HTTP log export, such as the event logs coding agents emit, authenticated with a virtual key, and store the records in Lens next to the gateway's request records. Encoding, size limit and tenant rules are the same as POST /v1/traces. Docs (https://docs.spanway.ai/docs/proxy/otlp_intake)

Request body (application/x-protobuf, string):

Request body (application/json, object):

Example request:

curl -X POST "http://localhost:4000/v1/logs" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"resourceSpans": [
{
"resource": {
"attributes": [
{
"key": "service.name",
"value": {
"stringValue": "research-service"
}
}
]
},
"scopeSpans": [
{
"spans": [
{
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"spanId": "00f067aa0ba902b7",
"name": "plan step",
"startTimeUnixNano": "1795000000000000000",
"endTimeUnixNano": "1795000001200000000"
}
]
}
]
}
]
}'

Responses:

StatusDescriptionBody
200Lens stored the batch. The body is an empty OTLP export responseapplication/json object
400The body or its encoding is not valid OTLPapplication/json object
401No valid virtual key was sentapplication/json object
413The upload is larger than the gateway acceptsapplication/json object
501Lens is not set up on this gateway, so there is nowhere to store spansapplication/json object
503The gateway or Lens is busy or unreachable, retry after Retry-After secondsapplication/json object

GET /v1/traces/agents​

List the agents seen in traces

List the agent names that appear in the caller's traces in the window, with how often each ran and failed, for filters and pickers. The same scoping as the trace list applies, and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing)

Parameters:

NameInTypeRequiredDescription
start_msqueryinteger or nullNo
end_msqueryinteger or nullNo

Example request:

curl -X GET "http://localhost:4000/v1/traces/agents" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The agents seen in the windowapplication/json TraceAgentList
400A parameter or the cursor is not validapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
404No trace or span with that id is visible to the callerapplication/json ErrorDetail
409The trace changed while it was paged, so start again without a cursorapplication/json ErrorDetail
413The trace is too large for this viewapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
agentsarray of TraceAgentYesAgents

POST /v1/traces/query​

Run a read only SQL query over traces

Run a read only SQL query over the caller's traces and spend logs for ad hoc analysis, for example the slowest agents of the week. Any key that may read traces may call it, and rows are limited to what the caller may read. GET /v1/traces/query/help lists the tables and columns the query may use. A custom role that hides prompts, responses or tool arguments may not run it, because SQL could read them. A query that writes, reads outside the caller's scope or exceeds the reader limits is refused, and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing#reading-traces)

Request body (application/json, schema TraceQueryRequest):

FieldTypeRequiredDescription
sqlstringYesSql

Example request:

curl -X POST "http://localhost:4000/v1/traces/query" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT agent, count() AS traces FROM traces WHERE start_ms > now() - 86400000 GROUP BY agent"
}'

Responses:

StatusDescriptionBody
200The rows the query returnedapplication/json TraceSQLResponse
400The SQL is not a single read only query the reader acceptsapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent traces, or a custom role hides prompts, responses or tool argumentsapplication/json ErrorDetail
404No trace or span with that id is visible to the callerapplication/json ErrorDetail
409The trace changed while it was paged, so start again without a cursorapplication/json ErrorDetail
413The trace is too large for this viewapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503The query failed or ran past the reader limits, or the gateway has no master key to sign it withapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
dataarray of objectYesData

GET /v1/traces/query/help​

Describe the tables a trace query may use

Describe what POST /v1/traces/query may read: the tables and columns, how they join, the attribute and metadata keys seen in the caller's data, example queries and the limits. Any key that may read traces may call it, and nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing#reading-traces)

Example request:

curl -X GET "http://localhost:4000/v1/traces/query/help" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The query reference for the callerapplication/json TraceQueryHelp
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, or the gateway has no master key to sign the query withapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
accessstringYesAccess
attributesarray of TraceQueryAttributesYesAttributes
dialectstringYesDialect
examplesarray of TraceQueryExampleYesExamples
gotchasarray of stringYesGotchas
guidestringYesGuide
metadataTraceQueryMetadataYes
normalized_fieldsarray of TraceQueryNormalizedFieldYesNormalized Fields
relationshipsarray of TraceQueryRelationshipYesRelationships
responsestringYesResponse
tablesarray of TraceQueryTableYesTables

GET /v1/traces/{trace_id}​

Read one trace as a page of spans

Read one agent run as its summary, the agents that took part and a page of its spans, the steps such as model calls and tool calls in the order they ran. The caller must be able to see the trace, otherwise it answers 404. cursor continues a long trace, and a trace that changed while it was paged answers 409 so the client starts again. Input previews and error text read [hidden by your role] when a custom role hides prompts or tool arguments. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing)

Parameters:

NameInTypeRequiredDescription
trace_idpathstringYes
cursorquerystring or nullNo
page_sizequeryinteger or nullNo
trace_refquerystringNo

Example request:

curl -X GET "http://localhost:4000/v1/traces/trace_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The trace summary, its agents and one page of spansapplication/json Trace
400A parameter or the cursor is not validapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
404No trace or span with that id is visible to the callerapplication/json ErrorDetail
409The trace changed while it was paged, so start again without a cursorapplication/json ErrorDetail
413The trace is too large for this viewapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
agentsarray of AgentNodeYesAgents
next_cursorstring or nullNoNext Cursor
spansarray of SpanYesSpans
summaryTraceSummaryYes

GET /v1/traces/{trace_id}/spans/{span_id}​

Read one span in full

Read one step of a trace in full: its attributes and, when the content policy keeps them, its input and output. The caller must be able to see the trace, otherwise it answers 404. When a custom role hides prompts, responses or tool arguments, the hidden parts and the attributes that can quote them read [hidden by your role]. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing#what-spans-keep)

Parameters:

NameInTypeRequiredDescription
trace_idpathstringYes
span_idpathstringYes
trace_refquerystringNo

Example request:

curl -X GET "http://localhost:4000/v1/traces/trace_id-123/spans/span_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The span with its attributes, input and outputapplication/json SpanDetail
400A parameter or the cursor is not validapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
404No trace or span with that id is visible to the callerapplication/json ErrorDetail
409The trace changed while it was paged, so start again without a cursorapplication/json ErrorDetail
413The trace is too large for this viewapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
attributesobjectYesAttributes
inputstringYesInput
input_uiUIMessages or UIFields or UITextYesInput Ui
outputstringYesOutput
output_uiUIMessages or UIFields or UITextYesOutput Ui
span_idstringYesSpan Id

GET /v1/traces/{trace_id}/spans/{span_id}/error​

Page through a span's error details

Read the error message recorded on a failed step, paged with cursor when it is long. The caller must be able to see the trace, otherwise it answers 404. Nothing changes. Docs (https://docs.spanway.ai/docs/proxy/agent_tracing)

Parameters:

NameInTypeRequiredDescription
trace_idpathstringYes
span_idpathstringYes
cursorquerystring or nullNo
trace_refquerystringNo

Example request:

curl -X GET "http://localhost:4000/v1/traces/trace_id-123/spans/span_id-123/error" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200One page of the span's error messageapplication/json SpanErrorPage
400A parameter or the cursor is not validapplication/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The caller may not read agent tracesapplication/json ErrorDetail
404No trace or span with that id is visible to the callerapplication/json ErrorDetail
409The trace changed while it was paged, so start again without a cursorapplication/json ErrorDetail
413The trace is too large for this viewapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
501Lens is not set up on this gatewayapplication/json ErrorDetail
503Lens did not answer, retry after Retry-After secondsapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage
next_cursorstring or nullYesNext Cursor
span_idstringYesSpan Id
total_charsintegerYesTotal Chars