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:- A Telnyx account
- Node.js 16+ or a modern browser
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 aslogin_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):
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:Handle Errors
Disconnect
Always disconnect when the user leaves or the app unloads:Next Steps
- Authentication — JWT generation, token refresh, security best practices
- Call State Machine — Understanding call lifecycle and state transitions
- Call Options — Custom headers, ICE config, media control
- Error Handling — Structured error codes and recovery
- Best Practices — Production checklist, performance, security
- Demo App — Full working reference application