Call Hangup
Ends an active call identified by callId. This terminates your leg and finalizes the call flow according to backend/NCCO behavior.
Signature
// Callback versions
fun hangup(
callId: String,
callback: (Exception?) -> Unit
)
fun hangup(
callId: String,
reasonText: String?,
reasonCode: String?,
callback: (Exception?) -> Unit
)
// Suspend versions
suspend fun hangup(
callId: String
)
suspend fun hangup(
callId: String,
reasonText: String?,
reasonCode: String?
)
Parameters
| Parameter | Type | Required | Platform | Description |
|---|---|---|---|---|
callId | string | Yes | All | Identifier of the active call to terminate |
reasonText | string | No | Android, iOS | Human-readable reason sent to the remote party (not available on Web) |
reasonCode | string | No | Android, iOS | Machine-readable reason code sent to the remote party (not available on Web) |
INFO
reasonText and reasonCode are only available on Android and iOS. On Web, call hangup(callId) without reason parameters. The reason values are forwarded to the remote party's onCallHangup event if provided.
Return Type
Returns void (or Promise<void> for Web). Completion indicates hangup request processing is finished.
Usage Example
// Callback
client.hangup("callId") {
it?.let { err ->
// Handle Error hanging up call
println("Error hanging up call: $err")
}
}
// Coroutine
try {
client.hangup("callId")
} catch (e: Error) {
// Handle Error hanging up call
}
Errors
| Error Type | Error Code | Description |
|---|---|---|
INTERNAL_ERROR | voice:error:no_call_found | No active call found for the provided callId |
NETWORK_ERROR | internal:error:serviceNotAvailable | Network/service failure while hanging up |
CS_ERROR | Various backend call errors | Backend returned an error during hangup workflow |
UNKNOWN_ERROR | N/A | Unexpected failure |
For complete error reference and handling guidelines, see Error Reference.
Notes
- In 1:1 call flows, hanging up generally ends the remote party leg as well
- Hangup behavior can vary by NCCO action (
connectvsconversation) - A
callHangupevent is emitted to listeners with reason metadata
Related Actions
reconnectCall- Reconnect to an existing call
Related Events
onCallHangup- Fired when a call is terminated