Ingest spans
Batch-ingest spans for a run. Idempotent: a span carrying an id is upserted, so a retried batch never duplicates.
/api/v2/runs/{runId}/spansAuthorizationBearer token (Anlyon API key) · headerrequiredWorkspace API key sent as Authorization: Bearer <key>.
better-auth.session_tokenAPI key · cookierequiredBrowser session used by dashboard-only operations.
runIdstringrequiredPublic run id (run_xxx).
X-Request-IdstringOptional caller correlation ID. Unsafe or oversized values are replaced.
Idempotency-KeystringStable retry key for a mutation. The key is claimed atomically before the handler runs, so concurrent retries execute the side effect at most once. Replaying the key for the same request (same method, path, workspace and JSON body) returns the original response with an X-Idempotent-Replay: true header. Reusing the key for a different request returns 409 with error code idempotency_key_reuse. A duplicate arriving while the first is still in flight waits and then replays; if the first does not finish in time the duplicate gets 409 idempotency_request_in_progress. Keys are retained for 24 hours. Only successful (2xx) responses are stored; a failed request frees the key so it can be retried.
application/jsonspansobject[]requiredShow propertiesHide properties
objectidstringProvide to make ingestion idempotent resending the same id updates the span in place.
parentIdstringnamestringrequiredtypeSpanTypemodel_callcontext_assemblysession_readsession_writememory_recallmemory_writetool_callaction_callapproval_waitapproval_decisionworkflow_stepqueue_deliveryevent_deliverycustomstatusstringrunningsucceededfailedstartedAtstring<date-time>requiredendedAtstring<date-time>modelstringproviderstringtokensobjectToken counts, e.g. {input, output, total}. Rolled up to the run automatically: total wins when present, otherwise the values sum. Explicit run totals set at end-of-run override the rollup.
costnumberCost in USD as reported by the provider or gateway. Summed to the run total automatically.
inputanyoutputanyerrorobjectattributesobjectSpans ingested.
successbooleanrequiredtruedataobjectrequiredShow propertiesHide properties
ingestedintegerrequiredBad Request - Invalid input data
successbooleanrequiredrequestIdstringrequiredCorrelation ID matching the X-Request-Id response header.
errorobjectrequiredShow propertiesHide properties
codestringmessagestringdetailsobjectUnauthorized - Invalid or missing API key
successbooleanrequiredrequestIdstringrequiredCorrelation ID matching the X-Request-Id response header.
errorobjectrequiredShow propertiesHide properties
codestringmessagestringdetailsobjectAuthenticated credential lacks the required scope or workspace access.
successbooleanrequiredrequestIdstringrequiredCorrelation ID matching the X-Request-Id response header.
errorobjectrequiredShow propertiesHide properties
codestringmessagestringdetailsobjectNot Found - Resource does not exist
successbooleanrequiredrequestIdstringrequiredCorrelation ID matching the X-Request-Id response header.
errorobjectrequiredShow propertiesHide properties
codestringmessagestringdetailsobject
