Skip to main content

Sessions

A session is one conversation between a visitor and an agent.

tip

The quickest way to put an agent on your website is the widget embed code from a website channel. It calls these endpoints for you. See Website widget channel. Use the endpoints below only if you build your own client.

Start a session​

POST/widget/v1/session

Starts a voice session with an agent and returns a short-lived token. Your client uses the token to open a realtime voice connection with the provider named in model.

Before the session starts, the API checks that your organization has credit and a free voice line. A session reserves some credit while it runs.

Requires the widget:session permission.

Headers​

X-API-Keystringrequired
Your project API key.

Body​

agent_idintegerrequired
The agent to talk to. Get IDs from GET /widget/v1/config.
modelstringoptional
Override the agent's voice provider for this session. Accepts openai or gemini. Any other value is ignored and the agent's own setting is used.
voicestringoptional
Override the agent's voice for this session.
contextobjectoptional
Details about the visitor, as key and value pairs, for example {"name": "Asha", "plan": "Gold"}. The agent sees them at the start of the conversation. Empty values are skipped.
user_idstringoptional
Your own ID for a signed-in visitor, up to 128 characters. Used by Agent Memory to recognise returning visitors. Send it with user_hash.
user_hashstringoptional
The HMAC-SHA256 signature of user_id, as hex. See Agent Memory for how to compute it on your server.
visitor_idstringoptional
An anonymous ID for this browser, up to 64 characters. Used by Agent Memory when there is no user_id.

Response fields​

successbooleanoptional
true when the session started.
session_idstringoptional
The session ID. Send it with tool calls and session events.
agent_idintegeroptional
The agent ID.
agent_namestringoptional
The agent name.
modelstringoptional
The voice provider for this session: openai or gemini.
voice_llm_modelstring or nulloptional
The provider model the token was issued for.
client_secretobjectoptional
The short-lived token for the provider connection.
client_secret.ephemeral_tokenstringoptional
The token value.
client_secret.expires_atinteger or nulloptional
When the token expires, as a Unix timestamp in seconds.
ice_serversarray or nulloptional
ICE servers to use for the WebRTC connection, when the provider needs them.
initial_messagestring or nulloptional
The agent's greeting.

Responses​

200
The session started.
400
The session could not be set up for this agent. detail says why.
401
The key is invalid, revoked, lacks widget:session, or is not allowed from this domain.
402
Your organization has no active subscription or not enough credit.
403
The key cannot use this agent, the agent is in another project, or your plan does not include a feature the agent uses.
404
The agent was not found.
422
A field is missing or invalid, for example agent_id is missing or user_id is longer than 128 characters.
429
The key's rate limit was reached, or all your voice lines are in use.
warning

The token in client_secret is short-lived and only works for this session. Request a new session for each conversation. Do not cache or reuse it.

Get an ElevenLabs signed URL​

GET/widget/v1/elevenlabs-convai/signed-url

For agents that run on ElevenLabs Conversational AI. Returns a signed URL your client uses to connect to ElevenLabs directly. You can tell these agents apart in GET /widget/v1/config: their elevenlabs_convai_agent_id is set.

Your plan must include ElevenLabs voice. Requires the widget:session permission.

Headers​

X-API-Keystringrequired
Your project API key.

Query parameters​

agent_idintegerrequired
The agent to talk to.

Response fields​

signed_urlstringoptional
The URL to open the ElevenLabs conversation with. It is short-lived.

Responses​

200
The signed URL.
400
The agent is not set up for ElevenLabs Conversational AI.
401
The key is invalid, revoked, lacks widget:session, or is not allowed from this domain.
402
Your organization has no active subscription or not enough credit.
403
The key cannot use this agent, or your plan does not include ElevenLabs voice.
404
The agent was not found.
429
The key's rate limit was reached.
502
ElevenLabs returned an error. Retry after a short wait.
503
The agent service is temporarily unavailable.
Was this page helpful?