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

# End call

> Configure the End Call tool in Retell AI to hang up when a conversation is complete and send optional custom SIP headers with call outcomes or reference IDs.

By default, the agent won't end the call automatically. You'll need to configure when and how the call should be terminated using the end call tool.

<Steps>
  <Step title="Add End Call Tool">
    Click "+ Add" in the tools section and select "End Call" from the dropdown menu.

    <Frame>
      <img height="700" src="https://mintcdn.com/retellai/rxvYffEkEJPRL1KD/images/end_call.png?fit=max&auto=format&n=rxvYffEkEJPRL1KD&q=85&s=53ae902cbe4dbfa4edff788fff3ca94e" alt="Adding end call tool" data-path="images/end_call.png" />
    </Frame>
  </Step>

  <Step title="Configure Termination Conditions">
    Define specific conditions under which the call should be terminated. For example:

    * "If the user says 'thank you', 'goodbye', or 'bye', use the end\_call tool to terminate the conversation."

    <Frame caption="Set the end-call condition and optional custom SIP headers.">
      <img src="https://mintcdn.com/retellai/xnGtpZfvieBKNmwD/images/end-call-sip-headers.png?fit=max&auto=format&n=xnGtpZfvieBKNmwD&q=85&s=999cc5b92ffb208e9c65b70e01573504" alt="End Call dialog with a condition to hang up after resolving a delivery question, Custom SIP Headers outlined in blue with X-Ticket-ID set to the ticket_id dynamic variable, and Talk While Waiting enabled." style={{ maxHeight: 560 }} width="710" height="660" data-path="images/end-call-sip-headers.png" />
    </Frame>
  </Step>

  <Step title="Update the Prompt">
    Enhance the agent's understanding by incorporating the end call conditions into the prompt. Include specific instructions such as:

    "If the user says 'thank you', 'goodbye', or 'bye', use the end\_call tool to terminate the conversation."

    <Frame>
      <img height="700" src="https://mintcdn.com/retellai/rxvYffEkEJPRL1KD/images/end_call_3.png?fit=max&auto=format&n=rxvYffEkEJPRL1KD&q=85&s=c9f4683f55f36dae81c83b91bd607ad0" alt="Adding end call instructions to prompt" data-path="images/end_call_3.png" />
    </Frame>
  </Step>
</Steps>

## Custom SIP headers

For phone calls, add or edit the **End Call** tool and click **Add** under **Custom SIP Headers**. Enter a header name starting with `X-` or `x-`, then a static value or a [dynamic variable](/build/dynamic-variables), and save the tool.

For example, use `X-Ticket-ID` with the value `{{ticket_id}}` to pass the ticket created during the conversation to your SIP system when the tool ends the call. You can also configure headers on End Call tools in [subagent nodes](/build/conversation-flow/subagent-node).

Headers are optional. See [end-call SIP headers](/build/telephony/sip-headers#set-custom-sip-headers-when-ending-a-call) for allowed names, validation errors, and when the headers apply.

## End a call using the API

The steps above configure the agent to hang up on its own. You can also work with call termination through the API:

* **Stop an ongoing call**: Call [Stop Call](/api-references/stop-call) (`POST /v2/stop-call/{call_id}`) to immediately end a live call from your server.
* **Add the End Call tool programmatically**: Include a tool with `type: end_call` in `general_tools` when you [create](/api-references/create-retell-llm) or [update](/api-references/update-retell-llm) a Retell LLM. This is equivalent to adding the tool in the dashboard.
* **Custom LLM integrations**: If you bring your own LLM over WebSocket, set `end_call: true` in your response and Retell ends the call after the content is fully spoken. See the [LLM WebSocket reference](/api-references/llm-websocket).
