Endpoint
Authentication
Requires admin authentication using theadmin_auth security dependency.
Admin authentication token configured via
ADMIN_TOKEN environment variablePath Parameters
The unique identifier for the call to cancel (OpenAI call ID from webhook)
Response
Whether the cancellation request was processed successfully
Confirmation message with the canceled call ID
Error message if the cancellation failed (only present if ok is false)
How It Works
The cancel endpoint performs two operations:-
Stop Call Session (
src/apps/calls/app/call_manager.py:110):- Calls
CallManager.stop_call(call_id, reason="admin_cancel") - Marks the session for termination
- Cancels all running tasks in the session
- Calls
-
Hangup API Connection (
src/apps/calls/api/v1/endpoints/admin.py:32):- Makes a best-effort call to OpenAI’s hangup API
- Uses idempotency key:
admin_hangup_{call_id}_{uuid} - Logs errors but doesn’t fail the request if hangup fails
Example Request
Example Responses
Success
Error
Use Cases
- Emergency Shutdown: Immediately terminate problematic calls
- Testing: Clean up test calls during development
- Operational Control: Manual intervention when automated systems fail
- Cost Management: Stop runaway calls that are consuming resources
Notes
Even if the OpenAI API hangup fails, the local session will be stopped, so the call will not continue processing events.
Related Endpoints
- GET /api/v1/calls - List active calls to find the call_id
- GET /api/v1/metrics/live - Monitor system metrics after cancellation