Errors
PhoneError and its codes.
Every rejected promise and every error event carries a PhoneError; match it with instanceof:
class PhoneError extends Error {
code: string; // match on this
requestId?: string; // give it to support
param?: string; // offending field, for API errors
}code is one of the API error codes, or one of these, specific to the browser:
| Code | Cause | What to do |
|---|---|---|
microphone_denied | The user or the browser refused microphone access | Explain how to allow it in the browser settings |
microphone_not_found | No microphone, or the chosen one was unplugged (mid-call too: then sent as an error event and the call is muted) | Ask the user to plug one in or pick another |
speaker_not_found | The chosen speaker is unplugged, or the browser did not allow it | Pick another one, or leave the default |
audio_unavailable | The page cannot run Web Audio or reach media devices (old browser, insecure origin) | Serve the page over HTTPS, update the browser |
user_gesture_required | call(), answer() or testMicrophone() ran outside a user action, or the browser blocked the sound | Call them from a click handler |
not_supported | An output was set in a browser that cannot choose the speaker | Hide the speaker picker when phone.canChooseOutput is false |
ephemeral_key_failed | getEphemeralKey threw or did not return the JSON of POST /v1/ephemeral-keys | Check your server route |
connection_lost | The WebRTC session could not be restored for 2 minutes (network down, UDP and TURN blocked) | Show it, offer to retry with phone.connect() |
Two API codes also come from the SDK itself: line_offline when you call while the phone is not connected, and
invalid_request with param: 'lineId' when call() cannot pick a line. Anything unexpected is internal.
Call
One call, its state, its controls and its audio levels.
Send an SMS POST
Queues an SMS on one of your lines and returns it with `status: queued`. Long texts are split into segments (153 GSM-7 or 67 UCS-2 characters each), up to 10. Delivery is reported by the `sms.status` webhook. Sending the same `client_ref` again returns the first message (`200`) instead of sending a second one; a message saved but never started (the first request failed with `internal`) is sent then. The network tries to deliver a message for 24 hours. For your servers: an ephemeral key gets `403`.