Sessions
List sessions, filter by companion or client, and retrieve conversation transcripts
Every connection creates a session. A session captures the full configuration — which companion, tools, knowledge, and FAQs were attached — along with timing data, cost, and the complete conversation transcript between the user and the agent.
The Sessions API gives you four endpoints:
| Endpoint | What you get |
|---|---|
GET /public/sessions | A paginated list of sessions with filters for companion, client, channel, creation time, and tags |
GET /public/sessions/{sessionId} | Full session details including configuration, timing, and the complete conversation transcript |
GET /public/sessions/{sessionId}/items | A paginated list of the session's messages and tool calls in time order, with filters for item type, tool type, and status |
DELETE /public/sessions/{sessionId} | Permanently deletes a finished session and its transcript |
Getting the session ID
Where the session ID comes from
Listing sessions
Paginated session list with filters
Retrieving a session
Full session details with the transcript
Session fields
What each session record includes
Session cost
The billed cost of a session in USD
Messages and tool calls
Which tools the agent called, with what, and what came back
Deleting a session
Permanently remove a session and its data
API reference
Full schemas for the session endpoints
Getting the session ID
When you create a session from your Omniagent, the response includes a connection.id. This is the session ID you use to query session data later.
curl -X POST https://napster-api.napster.com/public/agents/agent_abc123/connections \
-H "X-Api-Key: $NAPSTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channelType": "webrtc"
}'Response:
{
"token": "eyJhbGci...",
"connection": {
"id": "sess_abc123"
}
}Store the connection.id on your backend. You need it to retrieve session details and transcripts.
Listing sessions
Retrieve a paginated list of sessions across your project. Sessions are returned newest first, by creation time.
curl https://napster-api.napster.com/public/sessions?pageSize=10 \
-H "X-Api-Key: $NAPSTER_API_KEY"Response:
{
"items": [
{
"id": "sess_abc123",
"companionId": "comp_abc123",
"companion": {
"id": "comp_abc123",
"firstName": "Alex",
"lastName": "Chen"
},
"functions": ["fn_def456"],
"knowledgeBaseId": "kb_abc123",
"knowledgeBase": {
"id": "kb_abc123",
"name": "Product Docs"
},
"faqIds": ["faq_abc123"],
"faqCollections": [
{
"id": "faq_abc123",
"name": "Support FAQs"
}
],
"externalClientId": "user_12345",
"tags": {
"environment": "production",
"channel": "web"
},
"sessionType": "webrtc",
"modality": "audio",
"status": "closed",
"closeReason": "idle_timeout",
"agent": {
"id": "agent_abc123",
"name": "Support Agent"
},
"cost": 0.42,
"createdAt": 1710000000,
"startedAt": 1710000005,
"closedAt": 1710000300
}
],
"filteredCount": 1,
"totalCount": 42,
"pageIndex": 0,
"pageSize": 10
}Filtering
Use query parameters to narrow results:
| Parameter | Type | Description |
|---|---|---|
companionId | string | Filter by companion |
externalClientId | string | Filter by your external user or client identifier |
sessionType | string | Filter by channel: webrtc, websocket, sip, voip, or kiosk |
from | string | Sessions created at or after this time, in ISO 8601 (for example, 2026-11-01T00:00:00Z) |
to | string | Sessions created at or before this time, in ISO 8601 |
tags | object | Filter by tag values — a map of tag name to a list of matching values, e.g. tags[env]=prod. |
pageIndex | integer | Page number, zero-based (default 0) |
pageSize | integer | Number of results per page (default 10, minimum 1) |
curl "https://napster-api.napster.com/public/sessions?companionId=comp_abc123&pageSize=20" \
-H "X-Api-Key: $NAPSTER_API_KEY"Combine parameters to narrow the results. For example, to list the SIP calls from November 2026:
curl "https://napster-api.napster.com/public/sessions?sessionType=sip&from=2026-11-01T00:00:00Z&to=2026-11-30T23:59:59Z" \
-H "X-Api-Key: $NAPSTER_API_KEY"Paging is offset-based, so sessions created while you page shift existing sessions onto later pages, and you can see duplicates or miss sessions. To export many sessions, page inside a fixed from/to window that ends in the past:
curl "https://napster-api.napster.com/public/sessions?from=2026-11-01T00:00:00Z&to=2026-11-18T23:59:59Z&pageSize=50&pageIndex=0" \
-H "X-Api-Key: $NAPSTER_API_KEY"Increase pageIndex until a page comes back empty.
Retrieving a session
Get the full details of a session, including the conversation transcript:
curl https://napster-api.napster.com/public/sessions/sess_abc123 \
-H "X-Api-Key: $NAPSTER_API_KEY"Response:
{
"id": "sess_abc123",
"companionId": "comp_abc123",
"companion": {
"id": "comp_abc123",
"firstName": "Alex",
"lastName": "Chen"
},
"functions": ["fn_def456"],
"knowledgeBaseId": "kb_abc123",
"knowledgeBase": {
"id": "kb_abc123",
"name": "Product Docs"
},
"faqIds": ["faq_abc123"],
"faqCollections": [
{
"id": "faq_abc123",
"name": "Support FAQs"
}
],
"externalClientId": "user_12345",
"tags": {
"environment": "production"
},
"sessionType": "webrtc",
"modality": "audio",
"status": "closed",
"closeReason": "idle_timeout",
"agent": {
"id": "agent_abc123",
"name": "Support Agent"
},
"cost": 0.42,
"createdAt": 1710000000,
"startedAt": 1710000005,
"closedAt": 1710000300,
"conversation": {
"items": [
{
"role": "Assistant",
"text": "Hi there! How can I help you today?",
"timestamp": 1710000006
},
{
"role": "User",
"text": "I'd like to check the status of my order.",
"timestamp": 1710000010
},
{
"role": "Assistant",
"text": "Let me look that up for you. Your order #ORD-7890 shipped yesterday and is expected to arrive by Friday.",
"timestamp": 1710000015
}
]
}
}The conversation.items array contains each message in chronological order. Each item includes:
| Field | Description |
|---|---|
role | Who sent the message: User, Assistant, or System |
text | The message content |
timestamp | Unix timestamp of the message |
A session with no messages, such as one that failed before anyone spoke, has no conversation field at all, rather than an empty items array. Check that conversation exists before reading conversation.items.
Session fields
Beyond the transcript, each session record includes:
| Field | Description |
|---|---|
agent | The Omniagent that served the session, as { id, name }. null for per-session connections created without an agent. |
cost | The billed cost of the session, in USD. See Session cost below. |
sessionType | The channel the session ran on: webrtc, websocket, voip, sip, or kiosk. |
modality | The interaction mode the session ran in: audio, text, or video. |
mode | How the agent spoke: conversation or puppeteer. See Mode. |
status | Session state: pending, started, closed, or failed. A session moves from pending to started, then closed — or straight to failed if the connection is never established. Failed sessions appear in the session list like any other; use this field to separate them. |
closeReason | Why the session ended. Present once the session is closed or failed. See Close reasons below. |
direction | For SIP calls: inbound if someone called your agent, outbound if your agent placed the call. |
sipConnection | For SIP calls: the SIP Connection the call went through, as { id, name }. |
humanHandoff | For SIP calls the agent transferred to a person, as { destination, reason, startedAt }: the extension or number the call went to, the agent's reason, and when the transfer started (ISO 8601). It's recorded when the transfer starts, so it's present even if the transfer fails. Absent if the call wasn't transferred. |
createdAt / startedAt / closedAt | Unix timestamps for when the session was created, connected, and ended. |
functionStates | Connection state for each of the session's WebSocket-based tools. Returned only by GET /public/sessions/{sessionId}, not on list items. See Tool connection states below. |
Close reasons
A session that ends before it starts has a status of failed; otherwise it's closed. Either way, closeReason says why:
closeReason | Meaning |
|---|---|
connection_closed | The connection ended — the user closed the page or hung up, the network dropped, or a SIP call was transferred to a person. |
idle_timeout | The session was idle for too long. See Idle timeout. |
connection_aborted | Your backend ended the session. |
connection_timeout | The client didn't connect in time after the session was created. |
not_started | The session was created, but no client ever connected. |
session_expired | The AI provider's maximum session length was reached. |
no_credits_left | Your organization ran out of credits. |
provider_connection_aborted | The AI provider rejected the session's configuration. See provider_connection_aborted. |
function_connection_failed | A WebSocket tool set to abortOnFailure: true couldn't connect. |
function_connection_lost | A WebSocket tool set to abortOnFailure: true lost its connection during the session. |
avatar_allocation_failed | The avatar couldn't be started. Your client receives avatar_state_changed with failed. |
initialization_failed / session_initialization_failed | The session couldn't be set up after the client connected (WebRTC / WebSocket). |
application_shutdown | The server handling the session shut down. |
no_answer | An outbound SIP call wasn't answered. |
rejected | An outbound SIP call was declined, or the line was busy. |
failed | An outbound SIP call couldn't be placed. |
transfer_failed | Your phone system accepted a SIP call's human handoff, then the transfer failed. |
call_gone | A SIP call ended without a normal hang-up, for example because your phone system dropped it. |
media_timeout | A SIP call received no audio for 30 seconds. |
unknown | The session stopped reporting and was closed without a reason. |
Session cost
The cost field reports the billed cost of the session in USD, calculated from the minutes the agent was active and your API key's model configuration. Use it to attribute spend per session, per companion, or per end user.
{
"id": "sess_abc123",
"sessionType": "webrtc",
"status": "closed",
"cost": 0.42,
"closedAt": 1710000300
}cost is null while a session is still pending or started — it is populated once the session closes and billing is finalized. To total spend across many sessions, list sessions and sum cost across the returned items, filtering by companionId or externalClientId as needed.
Tool connection states
When a session uses WebSocket-based tools, the platform opens a socket to each tool's server at session start. functionStates records that connection's lifecycle per tool — use it to answer "did my tool connect, when, and why not". It's returned by GET /public/sessions/{sessionId} as one flat array covering every tool in the session:
{
"id": "sess_abc123",
"functionStates": [
{
"name": "get_order_status",
"state": "connected",
"startedAt": "2026-08-14T10:15:02Z",
"connectedAt": "2026-08-14T10:15:03Z"
},
{
"name": "check_inventory",
"state": "failed",
"startedAt": "2026-08-14T10:15:02Z",
"failedAt": "2026-08-14T10:15:07Z",
"error": {
"code": "connection_failed",
"message": "WebSocket handshake timed out"
}
}
]
}| Field | Description |
|---|---|
name | The tool's name. |
state | The connection's current state. |
startedAt | When the platform began connecting to the tool's server (ISO 8601). |
connectedAt | When the socket connected successfully. |
failedAt | When the connection attempt failed. error carries the cause as { code, message }. |
canceledAt | When the connection attempt was abandoned because the session ended first — for example, the user closed the tab before the tool finished connecting. |
Only the timestamps that occurred are present. Tools with other execution types (HTTP, implicit) don't hold a session-long connection, so they never appear in functionStates. To control what happens to the session when a tool connects slowly or fails, see the tool's connectionBehavior setting.
This field was previously named functionMetrics and returned an object keyed by function library ID, with an array of tool entries under each ID. If your code reads functionMetrics, switch to functionStates — the entries themselves have the same fields, but they now come in a single array.
Cost is finalized on session close. Poll GET /public/sessions/{sessionId} after a session ends, or read it from the session list, rather than expecting a value mid-session.
Messages and tool calls
To see which tools the agent called during a session, what it passed them, and what they returned, call GET /public/sessions/{sessionId}/items. It returns the session's messages and tool calls in one list, ordered by time:
curl "https://napster-api.napster.com/public/sessions/sess_abc123/items?pageSize=20" \
-H "X-Api-Key: $NAPSTER_API_KEY"Response:
{
"items": [
{
"type": "message",
"timestamp": 1710000010000,
"message": {
"role": "user",
"text": "Where's my order ORD-7890?"
}
},
{
"type": "toolCall",
"timestamp": 1710000011200,
"toolCall": {
"callId": "call_abc123",
"toolType": "function",
"name": "get_order_status",
"server": null,
"arguments": "{\"orderId\":\"ORD-7890\"}",
"status": "completed"
}
},
{
"type": "toolCallOutput",
"timestamp": 1710000011650,
"toolCallOutput": {
"callId": "call_abc123",
"toolType": "function",
"name": "get_order_status",
"server": null,
"status": "completed",
"output": "{\"status\":\"shipped\",\"eta\":\"Friday\"}",
"error": null,
"durationMs": 450
}
}
],
"filteredCount": 3,
"totalCount": 3,
"pageIndex": 0,
"pageSize": 20
}Each item in items has these fields:
| Field | Description |
|---|---|
type | The kind of item: message, toolCall, or toolCallOutput. |
timestamp | When the item happened, as a Unix timestamp in milliseconds. |
message / toolCall / toolCallOutput | The item's content. Each item has exactly one of these objects, the one that matches its type. |
A message object has these fields:
| Field | Description |
|---|---|
role | Who sent the message: user, assistant, or system. |
text | The message content. |
interrupted | true when the user cut the agent off before it finished. |
A toolCall object has these fields:
| Field | Description |
|---|---|
callId | The ID of the tool call. The matching toolCallOutput has the same callId. |
toolType | The kind of tool: function, mcp, mcpApproval, memory, knowledge, faq, webSearch, humanHandoff, or other. New values can be added, so accept any string. |
name | The tool's name. |
server | For MCP tools, the MCP server that ran the tool. Otherwise null. |
arguments | The arguments the agent passed, as a JSON string. |
status | The outcome of the call: completed, failed, timedOut, approved, or rejected. approved and rejected record the decision on an MCP approval request. |
A toolCallOutput object has the same callId, toolType, name, server, and status as its toolCall, plus:
| Field | Description |
|---|---|
output | What the tool returned. |
error | Why the call failed, as { code, message }. |
durationMs | How long the call took, in milliseconds. |
Filtering items
Use query parameters to narrow results:
| Parameter | Type | Description |
|---|---|---|
type | string[] | message, toolCall, or toolCallOutput. Repeat to match several. |
toolType | string[] | Any toolType value, such as function or mcp. Repeat to match several. |
status | string[] | Any status value, such as failed. Repeat to match several. |
pageIndex | integer | Page number, zero-based (default 0) |
pageSize | integer | Number of items per page (default 10, minimum 1) |
Repeat a parameter to match any of its values (status=failed&status=timedOut), or combine parameters to narrow the results (toolType=mcp&status=failed). A tool call and its output are filtered together. Filtering by toolType or status leaves out messages.
curl "https://napster-api.napster.com/public/sessions/sess_abc123/items?status=failed&status=timedOut" \
-H "X-Api-Key: $NAPSTER_API_KEY"Items are saved when the session closes, so a session that's still running returns an empty list. Sessions that closed before tool-call history was added return their messages but may have no tool calls.
An unknown session ID returns 400 with SessionNotFound.
Deleting a session
To remove a session permanently — for example, when an end user asks you to delete their data — call DELETE /public/sessions/{sessionId}:
curl -X DELETE https://napster-api.napster.com/public/sessions/sess_abc123 \
-H "X-Api-Key: $NAPSTER_API_KEY"The API returns 200 once the session is deleted. Deleting a session also removes its conversation transcript and its messages and tool calls.
Deletion is permanent. The session and its transcript can't be recovered.
Deleting a session doesn't reliably remove the memory stored from it. Only the memory from the user's last session is removed, so the agent can still recall facts from earlier conversations in future sessions with the same externalClientId.
You can only delete sessions that are closed or failed. To end a session that's still running, close it first.
| Error | Status | When |
|---|---|---|
SessionNotFound | 404 | No session with this ID exists in your project. |
SessionNotClosed | 400 | The session is still pending or started. |
SessionDeleteFailed | 400 | The session couldn't be deleted. Nothing was removed — retry the request. |