Authentication Architecture
Telnyx WebRTC has three authentication methods. They’re not interchangeable — they form a hierarchy, and using the wrong one is the most common cause of security issues and unexpected behavior.The Hierarchy
- One Credential Connection can have multiple Telephony Credentials
- Each Telephony Credential can generate multiple JWTs
The Three Methods
1. Credential Connection (login + password)
- Credentials are long-lived — they remain valid until manually deleted
- No per-user isolation — one credential = one SIP registration
- No automatic rotation or refresh
2. Telephony Credential (credential-based login)
One credential per user. Never share a Telephony Credential across multiple users or browser tabs. Each credential = one SIP registration. If two tabs register with the same credential, only the most recent one receives incoming calls.
3. JWT (login_token)
- Time-limited — tokens expire 24 hours after creation (or when the parent credential expires, whichever comes first)
- Per-device — each device should use its own credential → its own JWT, preventing registration conflicts
- Refresh-aware — the SDK emits a
TOKEN_EXPIRING_SOONwarning (code 34001) before expiry, so your app can request a fresh token from your backend - Multiple concurrent sessions — different users/devices can each have their own JWT without overwriting each other’s SIP registration
Comparison
The JWT Flow in Production
Initial connection
Token refresh
JWTs expire after 24 hours. The SDK warns you before expiry so you can refresh without disconnecting: Your backend must:- Have a Telnyx API key (
TELNYX_API_KEY) - Expose an endpoint that creates tokens for a given telephony credential
- Return the token to the browser
- Handle token refresh requests when
TOKEN_EXPIRING_SOON(34001) fires
Why “One Credential Per User” Matters
Wrong — shared credential
When two users share one credential, the second registration overwrites the first. User A never receives incoming calls.Correct — separate JWTs
With JWTs, each token maps to a unique session. Multiple users can register concurrently without conflicts.Common Mistakes
See Also
- Authenticating Your App — Full code examples for all three methods
- IClientOptions —
login_token,login,passwordfields