> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magpipe.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# End Call

> Terminate an active call

End an in-progress call immediately. Use this when you need to programmatically hang up a call.

## Request Body

<ParamField body="call_id" type="string" required>
  The unique identifier of the call to terminate.
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the call was terminated successfully.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.magpipe.ai/functions/v1/terminate-call \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"call_id": "7f3d8e00-a1b2-4c3d-9e4f-567890abcdef"}'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://api.magpipe.ai/functions/v1/terminate-call',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        call_id: '7f3d8e00-a1b2-4c3d-9e4f-567890abcdef'
      }),
    }
  );

  const result = await response.json();
  console.log('Call ended:', result.success);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.magpipe.ai/functions/v1/terminate-call',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json',
      },
      json={'call_id': '7f3d8e00-a1b2-4c3d-9e4f-567890abcdef'}
  )

  result = response.json()
  print(f"Call ended: {result['success']}")
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true
  }
  ```

  ```json Error Response theme={null}
  {
    "error": {
      "code": "call_not_found",
      "message": "Call not found or already ended"
    }
  }
  ```
</ResponseExample>
