Direct Call — protocol reference
One WebSocket per call.
wss://core.eurekatechlabs.com/v1/direct-call/{productId}?token=evt_...or, from a server:
wss://core.eurekatechlabs.com/v1/direct-call/{productId}
Authorization: Bearer ek_live_...Every JSON frame carries "v": 1. Audio is binary frames — never base64 inside JSON.
Audio format: pcm_s16le@24000 (signed 16-bit PCM, 24 kHz, mono), both directions.
Lifecycle
connect ──▶ call.ready ──▶ [dial] ──▶ ringing ──▶ answered ──▶ audio ──▶ call.ended
│
└──▶ call.failed (busy / no answer / rejected)Audio flows only between answered and the end of the call. Anything you send before then is discarded.
You → us
`dial`
Places the call. Valid once, and only before answered.
{ "type": "dial",
"from": "+60123456789",
"to": "+60198765432",
"clientRequestId": "ticket-4821" }| Field | Required | What |
|---|---|---|
from |
yes | The number to call from. Must belong to this product. |
to |
yes | The number to call, E.164. |
clientRequestId |
no | Your own reference. Reusing one will not place a second call. |
`hangup`
{ "type": "hangup" }Binary frames
Your microphone audio, as PCM. Send small, regular chunks — 20 ms is ideal. Sending faster than real time will cause audio to be dropped, so pace it to the clock, not to how fast you can encode.
Us → you
`call.ready`
Sent as soon as the socket is authorized, before you dial.
{ "v": 1, "type": "call.ready",
"sessionId": "ffd09731-5543-4be8-80aa-a93c677f5599",
"audio": { "input": "pcm_s16le@24000", "output": "pcm_s16le@24000" },
"product": { "id": "9663e67e-9181-4670-b028-75e3966fa4a7" },
"permissions": ["calls:write"] }permissions tells you what this connection may actually do. An empty list means
your credential can open the socket but not place calls — check it before showing
a dial button.
`ringing`
{ "v": 1, "type": "ringing", "callId": "…", "from": "+60123456789", "to": "+60198765432" }The carrier accepted the dial. from is the caller ID we resolved — display that, not what you sent.
Play your own ringback tone here. We don't send ringback audio; generating it locally is one line and saves a transcode.
`answered`
{ "v": 1, "type": "answered", "callId": "…" }They picked up. Audio starts now, in both directions.
`call.failed`
{ "v": 1, "type": "call.failed", "callId": "…", "reason": "busy" }The call never connected. The socket closes after this.
reason |
Retry? |
|---|---|
busy |
Not automatically — the line is engaged. |
no_answer |
Your call. |
rejected |
No — they declined. |
carrier_error |
No — something failed. |
capacity_unavailable |
Yes — no line was free at that instant. Carries "retryable": true. |
`call.ended`
{ "v": 1, "type": "call.ended", "callId": "…", "reason": "caller_hangup" }reason |
Meaning |
|---|---|
caller_hangup |
The person you called hung up. |
client_hangup |
You hung up. |
max_conversation_time |
The product's call-length limit was reached. |
peer_gone |
Your socket dropped while the call was live. |
`error`
{ "v": 1, "type": "error", "code": "number_not_owned", "message": "this call is not permitted" }code |
Fatal? | Meaning |
|---|---|---|
unauthorized |
yes | Bad, expired, or wrong-type token. |
forbidden |
no | Missing calls:write — you may connect but not dial. |
invalid_request |
no | dial was missing from or to. |
number_not_owned |
no | That from number is not assigned to this product. |
invalid_destination |
no | to is not a usable E.164 number. |
test_mode_not_allowed |
yes | Test-mode keys cannot place calls. |
already_dialing |
no | This socket already has a call. |
no_dial |
yes | No dial frame arrived in time. |
unsupported_mode |
yes | Direct Call is not enabled on this product. |
Non-fatal errors leave the socket open — fix the input and try again on the same connection.
Binary frames
The other person's audio, as PCM, ready to play.
Close codes
| Code | Meaning |
|---|---|
4401 |
Unauthorized. |
4403 |
Authenticated, but not allowed (wrong product, no balance, blocked IP). |
4409 |
The session was rejected. |
4422 |
This product is not configured for Direct Call. |
4429 |
Too many sessions, or connecting too fast. |
4500 |
Something broke on our side. |
Practical notes
Use a headset. Both people are on live microphones. Browser echo cancellation (echoCancellation: true on getUserMedia) helps, but speakers will still leak the far end back into the call.
One call per socket. To place another call, open another socket.
If your socket drops, the call ends. There is no reconnect window — a live phone call with nobody listening is a bill, so we hang it up.
To cancel while it's still ringing, send hangup — don't just close the socket. A close during ringing isn't noticed until the far end answers, and they'll get one call that drops immediately. hangup is handled as soon as the call connects.
