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?
): EmergencyCallDataParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Authentication token for the emergency call |
from | string | Yes | Caller identifier (phone number or SIP address) |
to | string | Yes | Emergency number to call (e.g., "911", "112") |
options | EmergencyCallOptions | No | Optional configuration for the emergency call |
EmergencyCallOptions
| Property | Type | Required | Description |
|---|---|---|---|
ringbackTone | string | No | URL to a custom ringback tone audio file to play while connecting |
Return Type
Returns EmergencyCallData containing:
| Property | Type | Description |
|---|---|---|
callId | string | Unique identifier for the emergency call |
reconnectToken | string | Token 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 Type | Error Code | Description |
|---|---|---|
CS_ERROR | Various CS error codes | Backend error returned from the emergency call service. This can include validation errors, service errors, or emergency-specific errors returned by the server |
SESSION_ERROR | internal:auth:authorization_error | Authentication error - invalid or missing authorization token |
NETWORK_ERROR | internal:error:serviceNotAvailable | Network-level errors including connection failures, timeouts (HTTP 503 service unavailable), or HTTP 500+ server errors |
INTERNAL_ERROR | voice:error:media_timeout | Media connection failed to establish within the timeout period |
INTERNAL_ERROR | internal:error:parsing_exception | Failed to parse the response from the server |
INTERNAL_ERROR | internal:error:unsanitized_input_error | Request contains unsanitized input and was rejected |
INTERNAL_ERROR | emergency:error:invalid_reconnect_token_origin | Reconnect token is missing or has invalid origin (only for reconnect scenarios) |
UNKNOWN_ERROR | N/A | Unexpected error that should be reported to support |
For complete error reference and handling guidelines, see Error Reference.
Related Actions
hangUpEmergencyCall- End an active emergency callreconnectEmergencyCall- Reconnect a disconnected emergency call