Skip to content

Sessions ​

A session is one conversation an agent had: a voice call or a text chat. Sessions come from LiveKit (the SDK adapters, Python and Node, or no-code room capture), ElevenLabs or Vapi, or from OpenTelemetry, a file import or the API. All of them use one canonical format.

Send and read sessions ​

EndpointWhat it does
POST /v1/workspaces/{ws}/sessionsIngest one session, with Authorization: Bearer <token> (scope ingest). An upsert on (platform, external_id).
GET /v1/workspaces/{ws}/sessionsNewest first by start time: {items, next_cursor}. Each item has status and result (the worst procedure result, once checked).
GET /v1/workspaces/{ws}/sessions/{id}One session with turns, tool_calls, metadata, checks (SOP checks), model_calls and cost_usd.
GET /v1/workspaces/{ws}/sessions/streamServer-sent events: event: session with data: {type: created | updated, workspace, id, status} each time a session is ingested or processed. A comment every 15s keeps it open.

Ingest needs a token with the ingest scope (Tokens). The rest follows the usual access rules.

sh
curl -s -X POST -H "Content-Type: application/json" \
  -H "Authorization: Bearer $SOPOPS_TOKEN" \
  "$SOPOPS_URL/sessions" \
  -d @session.json
json
{
  "id": "6e549e2c-9d94-4df9-a92f-3f1a5da91624",
  "created": true,
  "updated": false,
  "status": "received",
  "warnings": [
    "Release 99 doesn't exist in workspace 'harbor-qa'; the session is kept without it.",
    "Config 'notes' is too long (values up to 1,024 characters); it was left out."
  ]
}
ResponseWhen
201 {id, created: true, updated: false, status, warnings}A new session.
200 with updated: trueIts content changed.
200 with created and updated both falseAn identical re-send, which changes nothing.
401No valid token for the workspace.
403A token without the ingest scope.

A new or changed session runs process_session.

List filters ​

FilterType
agentstringThe sop id, or the agent as sent.
channel, status, result, platform, releaseenum, intExact match.
since, untilISO 8601On started_at.
cursorstringThe previous page's next_cursor.
limitintDefault 50, at most 200.

Drill-down filters, the ones Insights links to:

FilterType
procedurestringThe router considered it. Adds procedure_check to each item: that procedure's result, goal_reached, and one dot per rule.
procedure_resultenumThat procedure's result.
rulestringAny wording of the rule (its lineage), with optional rule_status (repeatable).
patternstringA rule pattern includes its sub-patterns.
themestringThe theme its patterns belong to.
findingbooltrue: with any finding; false: with none.
eligibleboolThe sessions Insights rates: checked or incomplete, with a result.
suppressedboolfalse: the finding filters leave suppressed findings out, as Insights does; true: only them.
json
{
  "items": [
    {
      "id": "689038cd-9c8c-4c8b-abfe-a290cafa1772",
      "workspace": "harbor-qa",
      "agent_id": "copper-wok-harbor",
      "agent_ref": "copper-wok-harbor",
      "channel": "voice",
      "platform": "livekit",
      "external_id": "ab-mock-832e3f1125",
      "release_id": null,
      "version_ref": null,
      "test": "haiku-vs-gpt",
      "config": {"llm": "anthropic/claude-haiku-4-5", "stt": "deepgram/nova-3", "tts": "cartesia/sonic-2", "voice": "ava"},
      "config_hash": "a157e7efe416d456",
      "started_at": "2026-10-20T21:18:18.519219Z",
      "ended_at": "2026-10-20T21:21:18.519219Z",
      "duration_s": 180.0,
      "status": "checked",
      "status_reason": null,
      "result": "followed",
      "turn_count": 9,
      "tool_call_count": 2,
      "created_at": "2026-10-20T22:08:18.857212Z",
      "updated_at": "2026-10-20T22:09:47.428039Z",
      "processed_at": "2026-10-20T22:09:47.428039Z",
      "procedure_check": null
    }
  ],
  "next_cursor": "WyIyMDI2LTEwLTIwVDIxOjE4OjE4LjUxOTIxOSswMDowMCIsICI2ODkwMzhjZC05YzhjLTRjOGItYWJmZS1hMjkwY2FmYTE3NzIiXQ"
}

Streaming (optional) ​

A sender can also stream a session as it happens, then close it. Nothing is checked until it closes, so a streamed session ends up the same as one posted at the end.

EndpointWhat it does
POST /v1/workspaces/{ws}/sessions/open{platform, external_id, channel?, agent?, release?, version_ref?, started_at?, metadata?, test?, config?}. Creates the session with status open (201), or returns the existing one (200).
POST /v1/workspaces/{ws}/sessions/{platform}/{external_id}/events{events: [{seq, type: turn | tool_call, turn? | tool_call?}]}, up to 500. Returns {accepted, duplicates}. 404 if the session was never opened.
POST /v1/workspaces/{ws}/sessions/{platform}/{external_id}/close{ended_at?, partial?, test?, config?}. config is merged over the one sent at open, key by key, and a nested setting is replaced whole. Closes the session with what streamed in and runs process_session.
sh
curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $SOPOPS_TOKEN" \
  "$SOPOPS_URL/sessions/open" \
  -d '{"platform": "livekit", "external_id": "AJ_tp_8f2k1", "agent": "copper-wok-harbor", "release": 4}'

curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $SOPOPS_TOKEN" \
  "$SOPOPS_URL/sessions/livekit/AJ_tp_8f2k1/events" \
  -d '{"events": [{"seq": 0, "type": "turn", "turn": {"role": "agent", "text": "Pickup or delivery?", "offset_s": 0.8}}]}'

curl -s -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $SOPOPS_TOKEN" \
  "$SOPOPS_URL/sessions/livekit/AJ_tp_8f2k1/close" \
  -d '{"ended_at": "2026-10-15T23:04:40Z"}'
json
{"accepted": 1, "duplicates": 0}
seqCounts from 0 per session. A resent seq is ignored, and events can arrive in any order: they're kept in seq order. Events for a session that has closed are ignored.
A full postPOST /v1/workspaces/{ws}/sessions still works at any point and replaces whatever streamed in.
Going idleAn open session with no events for SOPOPS_SESSION_IDLE_MINUTES (default 30) is closed as incomplete and checked, the next time the workspace opens a session or in the daily job.
AuthAll three endpoints take the ingest token.
Runtime guidanceThis is the transport for it in a later version: the pipeline has a hook for each batch of events (pipeline.session_event), which does nothing yet.
The callbackThe SDKs accept it and never call it yet: on_guidance on Python's attach, record_session and SessionStream, onGuidance on TypeScript's sopops.stream options and elevenLabsSession. TypeScript's attach has none.

From the SDKs, LiveKit's attach posts the session at shutdown in both languages. Python can stream it instead with stream=True; in TypeScript, stream it with sopops.stream(session), which returns a SessionStream.

python
from sopops.livekit import attach

ins = await attach(ctx, session, agent="tonys-pizza", stream=True)
ts
import { attach } from "sopops/livekit";

const ins = await attach(ctx, session, { agent: "tonys-pizza" });

Backfill from ElevenLabs or Vapi ​

Brings in the last 7 days of calls from a platform's API, using the API key stored under runtime/platforms, for each agent at head on that platform. An owner or admin can use these. platform is elevenlabs or vapi.

Each call is converted with the same code as the webhook that would have sent it (the ElevenLabs post-call webhook, the Vapi end-of-call report), so it's the same session: the same external_id, config, test, tool calls and metadata.

Already in sopopsSkipped. A webhook arriving later for a backfilled call changes nothing.
NewChecked like any other session.
Still runningLeft for its webhook.
EndpointWhat it does
GET /v1/workspaces/{ws}/capture/{platform}/backfill/preview?days= (default 7; more counts as 7). Reads the platform now.
POST /v1/workspaces/{ws}/capture/{platform}/backfill{days?}: start it in the background. 202 with the run. While one is running for the platform, it returns that one.
GET /v1/workspaces/{ws}/capture/{platform}/backfillThe latest run, or null.
sh
curl -s "$SOPOPS_URL/capture/elevenlabs/backfill/preview?days=7"
json
{
  "platform": "elevenlabs",
  "days": 7,
  "key_set": true,
  "error": null,
  "agents": [
    {"agent": "support-line", "platform_id": "ag_42", "found": 86, "already_imported": 14, "to_import": 72, "capped": false, "error": null}
  ],
  "found": 86,
  "already_imported": 14,
  "to_import": 72,
  "cost_per_session_usd": 0.009199,
  "estimated_cost_usd": 0.662
}
Preview field
key_set, errorWhether a key is saved, and why the platform couldn't be read. An agent whose calls can't be listed (no key, a refusal) has the reason in its own error.
found, already_imported, to_importCalls in the window, in total and per agent.
cost_per_session_usd, estimated_cost_usdto_import times this team's model spend per checked session over the last 30 days. Null with no spend yet.

A run is {id, platform, days, status: running | done | failed, found, imported, skipped, failed, agents, error, created_by, created_at, updated_at, finished_at}. skipped calls were already in sopops; failed ones couldn't be read or converted. Each agent has the same counts and its last error.

PlatformHow it reads calls
ElevenLabsGET /v1/convai/conversations (by agent_id and call_start_after_unix, 100 a page), then GET /v1/convai/conversations/{id} for each new call.
VapiGET /call (by assistantId and createdAtGt, 100 a page, then createdAtLt the oldest seen), each call whole.

Requests are spaced out, and a 429 waits for Retry-After and tries again. Each agent stops after 20 pages (capped). A run that stops moving for 15 minutes (the server restarted) reads as failed; starting again picks up the rest.

The canonical format ​

json
{
  "platform": "livekit",
  "external_id": "AJ_tp_8f2k1",
  "channel": "voice",
  "agent": "tonys-pizza",
  "release": 1,
  "version_ref": null,
  "started_at": "2026-10-15T23:04:10Z",
  "ended_at": "2026-10-15T23:04:40Z",
  "partial": false,
  "turns": [
    {"role": "agent", "text": "Thanks for calling Tony's Pizza! Pickup or delivery today?", "offset_s": 0.8},
    {"role": "user", "text": "Delivery please.", "at": 1792105454.2},
    {"role": "tool", "text": "check_delivery_zone", "name": "check_delivery_zone", "offset_s": 15.1}
  ],
  "tool_calls": [
    {"name": "check_delivery_zone", "arguments": {"address": "221 Mercer St"}, "result": {"in_zone": true}, "offset_s": 15.1}
  ],
  "metadata": {"room": "tp-delivery-8f2k1"},
  "test": "haiku-vs-gpt",
  "config": {
    "llm": "anthropic/claude-haiku-4-5",
    "tts": "cartesia/sonic-2",
    "pipeline": {"vad": {"threshold": 0.55, "min_silence_ms": 400}, "endpointing": "semantic"},
    "flags": ["warm_transfer", "barge_in"]
  }
}
FieldType
platformenumRequired. livekit, elevenlabs or vapi, or the transport: otel, import, api.
external_idstringRequired, up to 256 characters. The platform's id for the session: a LiveKit job id (room names get reused), an ElevenLabs conversation id, a Vapi call id. With platform, it's the session's unique key in the workspace.
channelenumvoice (default) or text.
agentstringThe sop agent id, its platform ref (livekit:tonys-pizza) or its platform id on this platform. Matched against the given release (else the live one) and stored as agent_id; what was sent is kept as agent_ref.
releaseintThe sopops release the agent ran on (release from GET /v1/workspaces/{ws}/agents/{agent} at session start). An unknown release is dropped with a warning; the session is still stored.
version_refstringThe platform's own version of the agent: ElevenLabs version_id, Vapi assistantVersion.
started_at, ended_atISO 8601started_at defaults to the first turn's time, else when it was received.
partialboolThe sender knows the transcript is incomplete. The status is then incomplete.
turnslistIn order. Fields below.
tool_callslist{name, arguments, result, is_error, call_id, offset_s or at}. Other fields are kept.
metadataobjectAnything else. sopops_* keys (flat, or nested under sopops) are read as test (sopops_test) and config (sopops_llm, and so on), and win over the fields below.
teststringAn A/B test this session is part of (optional, up to 128 characters).
configobjectWhat the agent ran with: scalars, and whole objects or arrays. Fields below.

turns. role is agent, user, tool or system; assistant, bot, human, customer, function and similar are mapped. text is the words. Time is offset_s (seconds since the start) or at (ISO 8601, or Unix seconds or milliseconds), which becomes offset_s. Other fields (interrupted, name) are kept.

config ​

llm, stt, tts (<provider>/<model>), voice, prompt (a template built outside sopops), version, or any other setting.

A settingA string, number or boolean, or a whole object or array: a voice pipeline's settings, a page of feature flags, a nested section.
Nested contentKept as sent, keys and all. Only the top-level keys are lowercased and trimmed.
Left outA setting that is null, blank, unknown, or an empty object or array, and anything JSON can't hold.
promptSent as text, it's stored once and its hash goes in the config.
config_hashSessions with the same agent, release and hash are one version (A/B tests).
Filled for youElevenLabs and Vapi captures read the agent's settings; the Python and TypeScript LiveKit helpers read the AgentSession.
Limit
32 settingsBeyond that, the rest are left out.
64 charactersA key.
1,024 charactersA string setting. A prompt may run to 65,536.
8,192 charactersAn object or array setting, as compact JSON with keys sorted.
8 levelsHow deep an object or array setting may nest. A flat one is 1.

A setting over a limit is left out with a warning in the ingest response, and the session is still stored.

Processing and status ​

Processing (process_session) normalizes turns: canonical roles, offset_s from at, text trimmed, empty turns dropped (except tool turns), a turn that repeats the one before it dropped, sorted by time. Then it routes and checks the session (SOP checks).

Status
openStreaming in. Not checked until it closes.
receivedStored and normalized, not checked (yet). With no model configured it stays here, with status_reason saying so.
routedThe procedures that applied are known; their checks are running.
checkedEvery procedure that applied was checked; result is set.
excludedNothing to check: no procedure applied, or every one that did was cut short (the session ended before it started or finished). status_reason says which.
incompleteNo turns, or the sender said the transcript is incomplete (or it was streamed and went idle). An incomplete session with turns is still checked, and keeps this status. This isn't the procedure result partial.
failedProcessing failed; status_reason says where (normalize, route, check <procedure>).

Import a file ​

sh
sopops import examples/import-sessions/restaurant-sessions.jsonl --workspace test

Reads one session per line in the canonical format (- reads stdin) straight into the database named by DATABASE_URL, with no token. It runs process_session for each new or changed session.

Lines that don't parse are reported by line number and skipped, and the command exits 1 if any did. Importing the same file again changes nothing. examples/import-sessions/restaurant-sessions.jsonl has ten made-up sessions for the test workspace.

sopops is open source under Apache-2.0.