API Reference

Complete API documentation for the jambonz WebRTC SDK

JambonzClient

The main client class. Manages the SIP connection and call lifecycle.

Creating a Client

1import { createJambonzClient } from '@jambonz/client-sdk-web';
2// or: import { createJambonzClient } from '@jambonz/client-sdk-react-native';
3
4const client = createJambonzClient(options);

Client Options

OptionTypeDefaultDescription
serverstringrequiredWebSocket URL of the jambonz SBC (e.g. wss://sbc.example.com:8443)
usernamestringrequiredSIP username
passwordstringrequiredSIP password
displayNamestringDisplay name shown to the callee
realmstringserver hostnameSIP realm/domain
autoRegisterbooleantrueAuto-register on connect
registerExpiresnumber300Registration expiry in seconds
userAgentstringjambonz-webrtc-{version}Custom SIP User-Agent header

Client Methods

Connection

MethodReturnsDescription
connect()Promise<void>Connect to the SBC and register. Resolves when registration succeeds.
disconnect()voidDisconnect and hang up all active calls.
register()voidRegister manually (if autoRegister was false).
unregister()voidUnregister from the SBC.

Making Calls

MethodReturnsDescription
call(target, options?)JambonzCallCall a phone number or SIP URI
callUser(username, options?)JambonzCallCall a registered SIP user
callQueue(queueName, options?)JambonzCallTake a call from a named queue
callConference(name, options?)JambonzCallJoin a conference room
callApplication(sid, options?)JambonzCallCall a jambonz application by SID

Messaging

MethodReturnsDescription
sendMessage(target, body, contentType?)voidSend a SIP MESSAGE. Default content type: text/plain

Client Properties

PropertyTypeDescription
stateClientStateCurrent connection state
isRegisteredbooleanWhether registered with the SBC
callsReadonlyMap<string, JambonzCall>All active calls
callCountnumberNumber of active calls

Client Events

EventPayloadDescription
registeredSIP registration succeeded
unregisteredSIP registration removed
registrationFailedErrorRegistration failed
incomingJambonzCallIncoming call received
stateChangedClientStateClient state changed
connectedWebSocket connected
disconnectedWebSocket disconnected
message{ from, body, contentType }SIP MESSAGE received
errorErrorError occurred

ClientState Enum

ValueDescription
disconnectedNot connected
connectingInitial connection in progress
connectedWebSocket connected, not yet registered
registeredSIP registration successful — ready to make calls
reconnectingTransient disconnect, auto-reconnecting
unregisteredExplicitly unregistered
errorConnection or registration error

JambonzCall

Represents a single voice call (inbound or outbound).

Call Methods

Answering & Ending

MethodDescription
answer()Answer an incoming call
hangup()Hang up the call

Call Control

MethodDescription
hold()Place the call on hold
unhold()Resume a held call
mute()Mute the microphone
unmute()Unmute the microphone
toggleMute()Toggle mute state
sendDTMF(tone)Send a DTMF tone (0-9, A-D, #, *)

Transfer

MethodDescription
transfer(target, options?)Blind transfer to another target via SIP REFER
attendedTransfer(otherCall, options?)Attended transfer — connect two active calls

Quality Monitoring

MethodReturnsDescription
getStats()Promise<CallQualityStats | null>One-time quality snapshot
startQualityMonitoring(intervalMs?)voidStart periodic monitoring (default: 2000ms)
stopQualityMonitoring()voidStop monitoring

Call Properties

PropertyTypeDescription
idstringUnique call identifier
stateCallStateCurrent call state
directionCallDirection'inbound' or 'outbound'
isMutedbooleanWhether the microphone is muted
isHeldbooleanWhether the call is on hold
durationnumberCall duration in seconds (0 if not connected)
remoteIdentitystringRemote party SIP URI or display name

Call Events

EventPayloadDescription
acceptedCall was answered
progressCall is ringing (180/183 response)
ended{ code, reason }Call ended normally
failed{ code, reason }Call failed to connect
stateChangedCallStateCall state changed
holdbooleanHold state changed
mutebooleanMute state changed
dtmfstringDTMF tone received
transferredCall transfer succeeded
transferFailedErrorCall transfer failed
qualityStatsCallQualityStatsQuality metrics update

CallState Enum

ValueDescription
idleCall created, not yet started
ringingRinging (outbound) or incoming
connectingCall being set up
connectedCall is active
heldCall is on hold
endedCall has ended

Call Options

Passed as the second argument to any call method:

1client.call(target, options);
2client.callUser(username, options);
3client.callQueue(queueName, options);
4// etc.
OptionTypeDefaultDescription
headersRecord<string, string>Custom SIP headers on INVITE
mediaConstraints{ audio?, video? }{ audio: true }getUserMedia constraints
pcConfig{ iceServers? }Google STUNICE/STUN/TURN configuration
noAnswerTimeoutnumberAuto-hangup after N seconds if not answered
preferredCodecsstring[]Preferred audio codecs (e.g. ['opus', 'PCMU'])
recordbooleanfalseEnable server-side recording (sends X-Record-Call header)

CallQualityStats

Returned by call.getStats() and emitted via the qualityStats event:

PropertyTypeDescription
roundTripTimenumberRound-trip time in milliseconds
jitternumberJitter in milliseconds
packetLossnumberFraction of packets lost (0.0 – 1.0)
packetsSentnumberTotal packets sent
packetsReceivednumberTotal packets received
packetsLostnumberTotal packets lost
codecstringAudio codec in use (e.g. opus)
timestampnumberTimestamp of measurement

React Hooks

useJambonzClient

1import { useJambonzClient } from '@jambonz/client-sdk-web';
2
3const {
4 client, // JambonzClient | null
5 state, // ClientState
6 isRegistered, // boolean
7 isConnecting, // boolean
8 error, // string | null
9 connect, // () => Promise<void>
10 disconnect, // () => void
11} = useJambonzClient(options);

useCall

1import { useCall } from '@jambonz/client-sdk-web';
2
3const {
4 call, // JambonzCall | null
5 state, // CallState | null
6 isMuted, // boolean
7 isHeld, // boolean
8 isActive, // boolean
9 incomingCaller, // string | null
10 makeCall, // (target, options?) => void
11 answerIncoming, // () => void
12 declineIncoming, // () => void
13 hangup, // () => void
14 toggleMute, // () => void
15 toggleHold, // () => void
16 sendDtmf, // (tone) => void
17 transfer, // (target) => void
18} = useCall(client);

Error Classes

ClassPropertiesDescription
JambonzErrormessageBase error class
RegistrationErrormessage, code?SIP registration failed
CallErrormessage, code?, reason?Call-related error
ConnectionErrormessageWebSocket connection error

JambonzAudioManager

Manages audio device enumeration and output switching.

MethodReturnsDescription
enumerateDevices()Promise<AudioDevice[]>List all audio devices
getMicrophones()Promise<AudioDevice[]>List input devices only
getSpeakers()Promise<AudioDevice[]>List output devices only
setOutputDevice(deviceId)Promise<boolean>Switch output device. Returns false if unsupported.

AudioDevice

PropertyTypeDescription
deviceIdstringUnique device identifier
labelstringHuman-readable device name
kind'audioinput' | 'audiooutput'Device type