Skip to content

Emergency Call ​

Initiates an emergency call to emergency services. This method establishes a voice connection to the specified emergency number (e.g., 911, 112) and returns call data including a unique call ID and reconnect token that can be used to manage or reconnect the call if interrupted.

Signature ​

// Callback version
fun emergencyCall(
  token: Token,
  from: String,
  to: String,
  options: EmergencyCallOptions?,
  callback: (Exception?, EmergencyCallData?) -> Unit
)

// Suspend version
suspend fun emergencyCall(
  token: Token,
  from: String,
  to: String,
  options: EmergencyCallOptions?
): EmergencyCallData

Parameters ​

ParameterTypeRequiredDescription
tokenstringYesAuthentication token for the emergency call
fromstringYesCaller identifier (phone number or SIP address)
tostringYesEmergency number to call (e.g., "911", "112")
optionsEmergencyCallOptionsNoOptional configuration for the emergency call

EmergencyCallOptions ​

PropertyTypeRequiredDescription
ringbackTonestringNoURL to a custom ringback tone audio file to play while connecting

Return Type ​

Returns EmergencyCallData containing:

PropertyTypeDescription
callIdstringUnique identifier for the emergency call
reconnectTokenstringToken that can be used to reconnect to this call if disconnected

Usage Example ​

// Callback

client.emergencyCall(
    "token",
    "from",
    "911",
    EmergencyCallOptions(ringbackTone = "http://example.com/ringback.mp3")
) { err, data ->
    err?.let {
        println("Error starting emergency call: $it")
    } ?: data?.let {
        println("Emergency call started successfully with callId: ${data.callId} and reconnectToken: ${data.reconnectToken}")
    }
}

// Coroutine
try {
    val data = client.emergencyCall(
        token = "token",
        from = "from", 
        to = "911",
        options = EmergencyCallOptions(ringbackTone = "http://example.com/ringback.mp3")
    )
    println("Emergency CallId: ${data.callId}")
    println("Reconnect Token: ${data.reconnectToken}")
} catch (e: Exception) {
    // Handle Error in emergency call
}

Errors ​

Error TypeError CodeDescription
CS_ERRORVarious CS error codesBackend error returned from the emergency call service. This can include validation errors, service errors, or emergency-specific errors returned by the server
SESSION_ERRORinternal:auth:authorization_errorAuthentication error - invalid or missing authorization token
NETWORK_ERRORinternal:error:serviceNotAvailableNetwork-level errors including connection failures, timeouts (HTTP 503 service unavailable), or HTTP 500+ server errors
INTERNAL_ERRORvoice:error:media_timeoutMedia connection failed to establish within the timeout period
INTERNAL_ERRORinternal:error:parsing_exceptionFailed to parse the response from the server
INTERNAL_ERRORinternal:error:unsanitized_input_errorRequest contains unsanitized input and was rejected
INTERNAL_ERRORemergency:error:invalid_reconnect_token_originReconnect token is missing or has invalid origin (only for reconnect scenarios)
UNKNOWN_ERRORN/AUnexpected error that should be reported to support

For complete error reference and handling guidelines, see Error Reference.

Built with VitePress.