Skip to main content
Closes a session and cancels every remaining task in it. Idempotent - ending an already-ended session is safe.

Parameters

string
required
The session to close.

Behavior

  • Cancels remaining tasks. Any pending, running, or paused task in the session completes with terminal: "stopped_by_user".
  • Call it only when the entire workflow is finished. A successful task completion does not require ending the session - reuse the same session_id for related follow-up tasks instead.
  • Do not reuse a session after ending it; subsequent task calls fail with session_not_found_or_inactive. Start fresh with phone_session_start or let phone_run_task create one.
To stop one runaway task without losing the workflow, use phone_task_cancel - it keeps the session open.