Voice

Start a web voice session with an Askocto agent from your server, hand the short-lived session token to your client and read the call afterwards.

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

An agent can talk with customers by voice, on the web and by phone. The REST API covers the web voice case: your server starts a voice session, and your web or mobile client joins it. The conversation is stored like any other, so you can read it afterwards.

How a voice session works

  1. Your server calls Start a voice session with its API key.
  2. The response holds the connection details and a short-lived token.
  3. Your server passes the url and token to your client. The client connects and the customer starts talking.
  4. When the call ends, the conversation appears with the channel voice.

The API key never leaves your server. The client only gets a token that is meant for a single session, see Authentication.

Start a session

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)

The response looks like this:

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

Return url and token to the client through an endpoint of your own, for example after you check that the person is logged in. Start the session only when the customer asks to talk, because a token expires at expiresAt.

Read the conversation afterwards

The conversationId is known from the start. Use Get a conversation and List conversation messages to read what was said, or find it among the results of List conversations, where its channel is voice.

Phone calls

Phone calls do not go through this endpoint. You set up the phone number and routing in the dashboard, with Twilio or a SIP trunk. See the Voice guide and SIP trunk. The agent can also hand a call to a person with the Transfer to phone action.

Errors

The endpoint returns the standard errors from Error handling. A 404 not_found means the agent does not exist. Voice must also be switched on for the agent in the dashboard, under Channels, before you can start a session.

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