Start a voice session

POST/v2/agents/{agentId}/voice/sessions

Start a web voice session with an agent and get the connection URL and a short-lived token for your browser or mobile client.

Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.

Starts a web voice session with an agent. Call it from your server when a customer asks to talk, then hand the returned url and token to your client, which connects and starts the call.

Request

POST /v2/agents/{agentId}/voice/sessions

Path parameters:

Name Type Required Description
agentId string Yes The ID of the agent, starting with agt_.

Body fields:

Name Type Required Description
userId string No Your ID for the person, starting with usr_. Links the call to their other conversations.
metadata object No Your own key-value pairs, stored with the conversation.

Voice must be switched on for the agent under Channels in the dashboard. Phone calls do not use this endpoint. The full flow, including what happens after the call, is described in Voice.

Example request

curl -X POST https://api.askocto.co/v2/agents/agt_8f3k2m/voice/sessions \
  -H "Authorization: Bearer $OCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "userId": "usr_3b6t0z" }'
const response = await fetch("https://api.askocto.co/v2/agents/agt_8f3k2m/voice/sessions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OCTO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ userId: "usr_3b6t0z" }),
})

const session = await response.json()
console.log(session.url, session.expiresAt)

Example response

A successful call returns 201 Created.

{
  "conversationId": "conv_5n2p8w",
  "url": "wss://voice.askocto.co/sessions/conv_5n2p8w",
  "token": "vt_live_9x2f7q",
  "expiresAt": "2026-03-14T09:35:00Z"
}

Response fields

Name Type Description
conversationId string The conversation that stores the call. Its channel is voice.
url string The address your client connects to.
token string A short-lived token for this one session.
expiresAt string When the token stops working, as an ISO 8601 UTC time.

Send url and token to the client, never the API key. Read the call afterwards with Get a conversation.

Errors

Status Code When
400 invalid_request userId has the wrong format or metadata is not an object.
401 unauthorized The API key is missing, malformed or deleted.
404 not_found No agent has this ID in your workspace.
409 conflict Voice is not switched on for this agent.
429 rate_limited Too many requests. Wait for the number of seconds in the Retry-After header.

Something unclear or missing? Tell us and we will fix the page.