Browser Calling
Place calls from the browser with a WebRTC softphone
Browser Calling
Let a user place a call straight from your web app, no phone required. Browser calling is a two-step handshake: mint a WebRTC session on the server, register it in the browser, then dial. The split exists so you never bridge a call to a browser that has not finished registering.
1. Mint a session (server)
Call createVoiceWebSession (POST /v1/voice/calls/web) from your backend. It returns a short-lived token and a credentialId the browser needs.
const { data } = await zernio.voice.createVoiceWebSession({});
// Send data.token + data.credentialId to the browser
// (the number to dial from is chosen later, at the /web/dial step)curl -X POST "https://zernio.com/api/v1/voice/calls/web" \
-H "Authorization: Bearer YOUR_API_KEY"The token lives about an hour: it must outlive the whole call, not just the handshake. Mint it server-side and pass it to the client; never ship your API key to the browser.
2. Register in the browser
Register the token with the @telnyx/webrtc SDK. Once the client reports it is registered, you are ready to dial.
import { TelnyxRTC } from '@telnyx/webrtc';
const client = new TelnyxRTC({ login_token: token });
client.on('telnyx.ready', () => {
// registered and ready to place a call
});
client.connect();3. Dial
With the client registered, call dialVoiceWebCall (POST /v1/voice/calls/web/dial) with the credentialId from step 1 to place the call. Pass fromNumber (E.164, optional) to choose which of your numbers to dial from; omit it if you only have one.
curl -X POST "https://zernio.com/api/v1/voice/calls/web/dial" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"credentialId": "CREDENTIAL_ID", "to": "+13105551234", "fromNumber": "+14155550100"}'The call then behaves like any other: it shows up in history and honors the number's recording and transcription settings.