Skip to main content

Quickstart

Get the Telnyx WebRTC JS SDK running in your app — make your first call in under 5 minutes.

Before You Begin

You’ll need:

Portal Setup

Set up everything you need in the Telnyx Portal — no API calls required. 1. Buy a number Go to Numbers → Buy Numbers in the Portal. Purchase a number in your desired country and area code. 2. Create a Credential Connection Go to Call Connections → Create → SIP Credential Connection. This defines how your WebRTC client authenticates with the SIP network. Give it a name and keep the defaults. 3. Create a Telephony Credential Go to Call Connections → [Your Connection] → Credentials → Create. Each user (or device) needs its own credential. Note the username and password — you’ll use these to generate a JWT. 4. Assign your number to the connection Go to Numbers → Your Numbers, select your number, and assign it to the Credential Connection you created. 5. Generate a JWT Still in the Credentials section, click Generate Token for the credential you created. Copy the JWT — this is what you’ll pass to the SDK as login_token.
For production, generate JWTs from your backend using the API. See Authenticating Your App for the full flow.

Install

Create a Client

The SDK connects to Telnyx via WebSocket and establishes WebRTC media sessions. Here’s the minimal setup:
Always wait for telnyx.ready before making calls. The client needs to establish a WebSocket connection and authenticate before it can place calls.

Authentication

The SDK supports three authentication methods: JWT (Production):
Credential (Call Control): If you’re using Telnyx Call Control, you can generate a SIP credential and use it directly:
Each user should get their own credential to avoid registration conflicts. JWT is still preferred for production — credentials don’t expire and can’t be rotated without updating the client. Anonymous (AI Assistants):
Anonymous login connects to an AI assistant without requiring a credential. Use this for click-to-call widgets that connect users directly to an AI agent.
For the full authentication guide including JWT generation, token refresh, and security best practices, see Authenticating Your App.

Make an Outbound Call

Receive an Inbound Call

For more control, show an “Accept/Reject” UI instead of auto-answering.

Play Audio

The SDK handles audio elements automatically, but you can provide your own:
Or let the SDK create them:

Handle Errors

See the full Error Handling Guide for all error codes and recommended responses.

Disconnect

Always disconnect when the user leaves or the app unloads:

Next Steps


Quick Reference