Skip to Content
Calls

Start an embedded web call

Permissioncalls:start-webRetriesIdempotency-Key requiredAuthentication
POST
/web-calls

Mints a short-lived token your browser front-end uses to talk to an agent over WebRTC, so you can embed a Kejue Voice agent in your own web app.

How it fits together

Call this from your backend with your API key, then hand the returned token and ws_url to the browser. Media flows directly between the browser and Kejue Voice, and never traverses your servers.

The token only gets you into the room

It is valid just long enough to join — see expires_at_ms — and does not bound the call itself.

call_id is the same id the call appears under in GET /v1/calls, available immediately, so you can correlate before the call connects.

variables are rendered into the agent's prompt exactly like outbound call variables. That is how you pass your own end-user's identity or context into the conversation.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Use a Voice API key or connected-app OAuth access token. Authentication.

Header Parameters

Idempotency-Key*string

Required. Reuse the same key to retry this write safely. Retries and idempotency.

Match^[A-Za-z0-9!#$%&'*+.^_`|~-]+$
Length1 <= length <= 255

Request Body

application/json
  1. body
agent_id*string

The agent to talk to. Its production version is used unless version_id is given.

Formatuuid
version_id?string

Run a specific agent version instead of the production one. The version must belong to agent_id.

Formatuuid
variables?

Per-call prompt variables, referenced as {{name}} or {{vars.name}}. Names must match [A-Za-z_][A-Za-z0-9_]{0,63}. Supply your own end-user's identity or context here — these values are trusted because they arrive over an authenticated server-side request, never from the browser.

Propertiesproperties <= 50
metadata?

Opaque object stored on the call for your own bookkeeping and returned by GET /v1/calls/{id}. Max 8 KiB encoded. Never shown to the agent or the caller.

modality?string

The conversation surface. audio (the default) streams speech both ways over WebRTC. text runs the same agent as a typed conversation over the room's data channel, with no microphone, no speech recognition and no synthesis. Text calls are billed as minutes for their full duration and share the same concurrency limit as audio web calls.

Default"audio"
Value in"audio""text"

Response Body

Token minted and the call row created. The call remains in ringing until the browser joins and the agent is dispatched.

application/json
  1. response
call_id*string

The call's id, usable immediately against GET /v1/calls/{id}.

Formatuuid
token*string

Short-lived join credential for the browser. Treat it as a secret in transit; it authorizes exactly one room.

ws_url*string

The WebRTC signalling endpoint the browser connects to.

Formaturi
room_name*string

The room the browser joins. Diagnostic — the SDK takes it from the token.

agent_name*string

The dispatched worker identity. Diagnostic only.

agent_version_id?string

The agent version actually resolved for this call.

Formatuuid
expires_at_ms*integer

Unix ms after which the token can no longer be used to JOIN. It does not bound an already-connected call.

Formatint64
modality*string

The surface this call was opened on, echoed back so a client that omitted the field still knows which transport to run.

Value in"audio""text"
Example Request
curl -X POST 'https://api.kejue.co/v1/web-calls' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{  "agent_id": "2b1e3b65-2c04-4fa2-a2d7-467901e98978"}'
Example Response
{  "call_id": "33333333-3333-4333-8333-333333333333",  "token": "eyJhbGciOiJIUzI1NiJ9.eyJ2aWRlbyI6e319.signature",  "ws_url": "wss://agent.kejue.co",  "room_name": "call-billing_assistant-a1b2c3d4e5f6",  "agent_name": "sonus-prompt",  "agent_version_id": "22222222-2222-4222-8222-222222222222",  "expires_at_ms": 1786101420000,  "modality": "audio"}