monitor-sessions
monitor-sessions
Every connection creates a session that captures the configuration used (persona, tools, knowledge, FAQs), timing, and the full transcript. The Sessions API has four endpoints: list (with filters), get-one (with the transcript), items (the messages and tool calls in time order), and delete (permanently removes a finished session, its transcript, its messages and tool calls, and the memory stored from it).
Where the session ID comes from
When you create a connection ([[deploy-webrtc]] / [[deploy-websocket]]), the response includes connection.id — that's the session ID. Store it on your backend to look the session up later.
List sessions
curl "https://napster-api.napster.com/public/sessions?pageSize=10" \
-H "X-Api-Key: $NAPSTER_API_KEY"
Each item includes id, companionId (+ companion), functions, knowledgeBaseId, faqIds, externalClientId, tags, sessionType (webrtc/websocket/voip/sip/kiosk), modality (audio/text/video), status, closeReason, cost, agent ({ id, name }, null for per-session connections), mode (conversation/puppeteer), for SIP calls direction (inbound/outbound), sipConnection ({ id, name }) and humanHandoff ({ destination, reason, startedAt }, present once the agent starts transferring the call to a person, even if the transfer fails; startedAt is ISO 8601), and timestamps (createdAt, startedAt, closedAt). The envelope has items, filteredCount, totalCount, pageIndex, pageSize.
status is pending, started, closed, or failed — a session moves pending → started → closed, or straight to failed if the connection is never established. Failed sessions appear in the list like any other (they are deliberately kept in analytics); there is no status filter parameter — separate them client-side by the field. closeReason (present once closed or failed) says why: connection_closed (including a SIP call transferred to a person), idle_timeout, connection_aborted (your backend called DELETE /public/connections/{id}), connection_timeout (the client didn't connect in time), not_started, session_expired, no_credits_left, provider_connection_aborted (the provider rejected the voice, model, credentials or instructions), function_connection_failed / function_connection_lost (a WebSocket tool with abortOnFailure: true), avatar_allocation_failed (the client gets avatar_state_changed with failed), initialization_failed / session_initialization_failed, application_shutdown, outbound SIP no_answer / rejected / failed, SIP transfer_failed (your phone system accepted a human handoff, then the transfer failed), call_gone (the call ended without a normal hang-up) and media_timeout (no audio for 30 seconds), and unknown.