Skip to content
Anlyon
Esc
↑↓navigate↵open⌘Jpreview

Ingest spans

Batch-ingest spans for a run. Idempotent: a span carrying an id is upserted, so a retried batch never duplicates.

POST/api/v2/runs/{runId}/spans
Authorization
AuthorizationBearer token (Anlyon API key) · headerrequired

Workspace API key sent as Authorization: Bearer <key>.

or
better-auth.session_tokenAPI key · cookierequired

Browser session used by dashboard-only operations.

Path parameters
runIdstringrequired

Public run id (run_xxx).

Header parameters
X-Request-Idstring

Optional caller correlation ID. Unsafe or oversized values are replaced.

max length 128
Idempotency-Keystring

Stable 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.

min length 1 · max length 255
Request body
requiredapplication/json
spansobject[]required
min items 1 · max items 500
Show properties
Array of object
idstring

Provide to make ingestion idempotent resending the same id updates the span in place.

max length 80
parentIdstring
max length 80
namestringrequired
min length 1 · max length 200
typeSpanType
Allowed:model_callcontext_assemblysession_readsession_writememory_recallmemory_writetool_callaction_callapproval_waitapproval_decisionworkflow_stepqueue_deliveryevent_deliverycustom
statusstring
Allowed:runningsucceededfailed
startedAtstring<date-time>required
endedAtstring<date-time>
modelstring
max length 120
providerstring
max length 120
tokensobject

Token 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.

costnumber

Cost in USD as reported by the provider or gateway. Summed to the run total automatically.

min 0
inputany
outputany
errorobject
attributesobject
Responses
200

Spans ingested.

successbooleanrequired
Allowed:true
dataobjectrequired
Show properties
ingestedintegerrequired
400

Bad Request - Invalid input data

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
401

Unauthorized - Invalid or missing API key

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
403

Authenticated credential lacks the required scope or workspace access.

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
404

Not Found - Resource does not exist

successbooleanrequired
requestIdstringrequired

Correlation ID matching the X-Request-Id response header.

errorobjectrequired
Show properties
codestring
messagestring
detailsobject
Try it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X POST 'https://api.anlyon.com/api/v2/runs/string/spans' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "spans": [
    {
      "id": "string",
      "parentId": "string",
      "name": "string",
      "type": "model_call",
      "status": "running",
      "startedAt": "2019-08-24T14:15:22Z",
      "endedAt": "2019-08-24T14:15:22Z",
      "model": "string",
      "provider": "string",
      "tokens": {
        "property1": 0,
        "property2": 0
      },
      "cost": 0,
      "input": null,
      "output": null,
      "error": {},
      "attributes": {}
    }
  ]
}'
Response
{
  "success": true,
  "data": {
    "ingested": 0
  }
}