Skip to content

Delete Session

Ends the current session, closes the WebSocket connection, and stops receiving events. After deletion, a new session must be created with createSession to resume SDK functionality.

Signature

// Callback version
fun deleteSession(callback: (Exception?) -> Unit)

// Suspend version
suspend fun deleteSession()

Parameters

None.

Return Type

Returns void (or Promise<void> for Web). Completion indicates the session has been terminated.

Usage Example


 // Callback
 client.deleteSession { err ->
     when {
         err != null -> {  } // handle error
     }
 }

 // Coroutine
 try {
     client.deleteSession()
 }
 catch (e:Error) {
     // Handle Error in creation session
 }

Errors

This method can throw the following error types:

Notes

  • Deleting a session does not end active calls — use hangup to terminate calls before deleting the session if needed.
  • After deletion, all event listeners remain registered but will not fire until a new session is created.

Built with VitePress.