Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt

Use this file to discover all available pages before exploring further.

Switch/Server Events

The Telnyx signaling server sends events over the WebSocket connection during the call lifecycle. These are the raw server-side events — most applications should use the higher-level telnyx.notification event instead. See INotification for the recommended approach.
Most developers don’t need to handle these events directly. The SDK translates them into INotification objects. Use telnyx.notification unless you need low-level signaling details.

Event Reference

Client Lifecycle

EventDirectionDescription
telnyx.loginClient → ServerAuthentication request (login + password or login_token)
telnyx.login.successServer → ClientAuthentication successful
telnyx.login.errorServer → ClientAuthentication failed (invalid credentials, expired token)
telnyx.logoutClient → ServerClient disconnecting

Call Lifecycle

EventDirectionDescription
telnyx.inviteServer → ClientIncoming call (INVITE)
telnyx.invite.responseClient → ServerResponse to incoming call (trying, ringing, answer)
telnyx.answerClient → ServerAccept incoming call
telnyx.ringingServer → ClientRemote party is ringing (outbound call)
telnyx.bridgeServer → ClientCall bridged (both parties connected)
telnyx.byeServer → ClientRemote party hung up
telnyx.hangupClient → ServerLocal hangup

Media

EventDirectionDescription
telnyx.mediaClient → ServerSDP offer/answer exchange
telnyx.media.candidateClient → ServerICE candidate (trickle ICE)

Call Control

EventDirectionDescription
telnyx.holdClient → ServerPut call on hold
telnyx.unholdClient → ServerTake call off hold
telnyx.dtmfClient → ServerSend DTMF tone
telnyx.transferClient → ServerTransfer call
telnyx.faxServer → ClientFax detection event

Presence & Registration

EventDirectionDescription
telnyx.registerClient → ServerSIP REGISTER (credential-based)
telnyx.unregisterClient → ServerSIP UNREGISTER
telnyx.gateway.stateServer → ClientGateway connection state (up/down)

Event Flow: Outbound Call


Event Flow: Inbound Call


Listening to Server Events

For advanced use cases, you can listen to raw server events by enabling debug mode and parsing the WebSocket messages:
const client = new TelnyxRTC({
 login_token: jwt,
 debug: true,
 debugOutput: 'socket',
});
Or intercept WebSocket messages directly:
// Low-level: intercept raw WebSocket messages
const originalSend = client.connection.socket.send.bind(client.connection.socket);
client.connection.socket.send = function(data) {
 const parsed = JSON.parse(data);
 console.log('→ Server:', parsed.method);
 return originalSend(data);
};
Listening to raw WebSocket messages is not a supported API. The message format may change between SDK versions. Use telnyx.notification for stable event handling.

Server Events vs INotification

AspectServer EventsINotification
LevelLow-level signalingHigh-level SDK abstraction
StabilityMay change between versionsStable across versions
PayloadRaw SIP/Verto formatStructured call object
Use caseDebugging, low-level controlApplication development
Event nametelnyx.invite, telnyx.bye, etc.telnyx.notification
Use telnyx.notification (INotification) for application code:
// Recommended — high-level, stable
client.on('telnyx.notification', (notification) => {
 if (notification.type === 'callUpdate') {
 const call = notification.call;
 // Handle call state changes
 }
});

// Not recommended — low-level, may change
// (No public API for this — would require intercepting WebSocket)

Gateway State Events

The telnyx.gateway.state event indicates when the WebSocket connection to the gateway goes up or down:
// Listen via notification
client.on('telnyx.notification', (notification) => {
 if (notification.type === 'gatewayStateUpdate') {
 console.log('Gateway state:', notification.state);
 // 'up' = connected, 'down' = disconnected
 }
});
Gateway DOWN can indicate:
  • Network interruption
  • Server-side maintenance
  • Credential revoked
  • WebSocket timeout
The SDK automatically attempts reconnection. See Reconnection & Recovery.

See Also