Skip to main content

Session events

VoisX records each voice session on its own servers: its length, its transcript and every tool call. Sessions you open with the session WebSocket show in the console without any extra calls.

Use this endpoint to add events that only your client knows about, such as an error your client hit or a message from your own UI.

warning

Do not send transcript, session_end or tool call events for a session you opened with the WebSocket. VoisX already records them, and VoisX analyses every transcript it receives, so a second transcript repeats that work.

Send session events​

POST/widget/v1/analytics

Records one or more events for a session. You can send several events in one request.

Requires the widget:read permission.

Headers​

X-API-Keystringrequired
Your project API key.

Body​

session_idstringrequired
The session_id from the WebSocket's connected message.
agent_idintegerrequired
The agent the session is with.
eventsarrayrequired
The events to record.
events[].typestringrequired
The event type. See the table below.
events[].timestampstringrequired
When the event happened, in ISO 8601.
events[].dataobjectoptional
Extra details for the event type.

Event types​

typedata fieldsWhat it records
session_startvisitor_id (optional)The session started.
session_endduration_seconds (number)The session ended and how long it lasted.
transcripttranscript_data (array of turns)The conversation. Each turn has role (user or assistant), text and timestamp.
messagemessage (string)One message in the conversation, for the session log.
errorerror_type, messageAn error your client hit.
tool_call_madenoneThe agent asked for a tool.
tool_call_successnoneA tool call succeeded.

Unknown types are accepted and ignored. Tool calls are counted on the server (see Tools), so you do not need to send tool_call_made or tool_call_success.

Response fields​

successbooleanoptional
Always true when the request was accepted.
receivedintegeroptional
How many events were in the request.
persistedintegeroptional
How many events were recorded. An event that cannot be recorded is skipped and does not fail the request.

Responses​

200
The events were received.
401
The key is invalid, revoked, lacks widget:read, or is not allowed from this domain.
403
The key cannot use this agent, or the agent is in another project.
404
The agent was not found.
422
A required field is missing or has the wrong type.
429
The key's rate limit was reached.
Was this page helpful?
On this page
Try it in the consoleBuild an agent and test it in the Playground.Open console →