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

# Encerrar Chamada

> Desligar uma chamada ativa realizada por um agente

# Encerrar Chamada

Desliga uma chamada ativa realizada por um agente específico. Use isto para paradas de emergência, cancelamentos solicitados pelo usuário ou para impor lógica de timeout customizada a partir da sua aplicação.

## Endpoint

```
POST /api/v1/agents/{agent_id}/end-call
```

## Parâmetros de caminho

<ParamField path="agent_id" type="string" required>
  UUID do agente que possui a chamada.
</ParamField>

## Cabeçalhos da requisição

<ParamField header="Authorization" type="string" required>
  Token Bearer. Formato: `Bearer talq_your_environment_token_here`
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Deve ser definido como `application/json`
</ParamField>

## Corpo da requisição

<ParamField body="call_sid" type="string" required>
  Identificador da chamada a desligar. Use o `id` retornado por [Realizar uma Chamada](/api-reference/endpoints/make-call).
</ParamField>

## Exemplos

<RequestExample>
  ```bash theme={null}
  curl -X POST "https://app.talkover.ai/api/v1/agents/agent-uuid/end-call" \
    -H "Authorization: Bearer talq_your_environment_token_here" \
    -H "Content-Type: application/json" \
    -d '{ "call_sid": "call-uuid-123" }'
  ```

  ```javascript theme={null}
  await fetch('https://app.talkover.ai/api/v1/agents/agent-uuid/end-call', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer talq_your_environment_token_here',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ call_sid: 'call-uuid-123' })
  });
  ```
</RequestExample>

## Resposta

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "id": "call-uuid-123",
      "status": "completed",
      "ended_at": "2024-01-15T11:35:42Z",
      "ended_reason": "ended_by_api"
    }
  }
  ```
</ResponseExample>

## Respostas de erro

### 404 — Chamada Não Encontrada

<ResponseExample>
  ```json theme={null}
  {
    "success": false,
    "message": "Call not found for this agent"
  }
  ```
</ResponseExample>

### 409 — Chamada Já Encerrada

<ResponseExample>
  ```json theme={null}
  {
    "success": false,
    "message": "Call is not active",
    "code": "CALL_NOT_ACTIVE"
  }
  ```
</ResponseExample>

## Observações

* A propagação do hangup é assíncrona. O status da chamada muda para `completed` logo após este endpoint retornar.
* O `ended_reason` será `ended_by_api` para diferenciar de hangups naturais.
* Eventos de webhook `event_phone_call_ended` serão disparados normalmente.
