Skip to content

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

ParameterTypeRequiredPlatformDescription
callIdstringYesAllIdentifier of the active call to terminate
reasonTextstringNoAndroid, iOSHuman-readable reason sent to the remote party (not available on Web)
reasonCodestringNoAndroid, iOSMachine-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 TypeError CodeDescription
INTERNAL_ERRORvoice:error:no_call_foundNo active call found for the provided callId
NETWORK_ERRORinternal:error:serviceNotAvailableNetwork/service failure while hanging up
CS_ERRORVarious backend call errorsBackend returned an error during hangup workflow
UNKNOWN_ERRORN/AUnexpected 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 (connect vs conversation)
  • A callHangup event is emitted to listeners with reason metadata

Built with VitePress.