> ## 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.

# Definir Agente como Callback

> Configurar um agente inbound para tratar callbacks de agentes de origem outbound

# Definir Agente como Callback

Configura um agente inbound para tratar callbacks de um ou mais agentes de origem outbound. Quando um contato previamente chamado por um agente de origem retorna a ligação, a chamada é roteada para este agente (presumindo que o agente seja dono do número discado).

## Endpoint

```
POST /api/v1/agents/{agent_id}/callback
```

## Parâmetros de caminho

<ParamField path="agent_id" type="string" required>UUID do agente inbound. Deve ter `direction: "inbound"`.</ParamField>

## Cabeçalhos da requisição

<ParamField header="Authorization" type="string" required>
  Token Bearer para autenticação. 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="source_agent_ids" type="array" required>
  Array de UUIDs de agentes outbound cujos contatos devem ser roteados para este agente de callback nos retornos inbound. Deve conter pelo menos uma entrada.
</ParamField>

## Exemplos

<RequestExample>
  ```bash theme={null}
  curl -X POST "https://app.talkover.ai/api/v1/agents/agent-uuid-1/callback" \
    -H "Authorization: Bearer talq_your_environment_token_here" \
    -H "Content-Type: application/json" \
    -d '{
      "source_agent_ids": ["agent-uuid-2", "agent-uuid-3"]
    }'
  ```
</RequestExample>

## Resposta

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "id": "agent-uuid-1",
      "name": "Callback Handler",
      "direction": "inbound",
      "callback_config": {
        "source_agent_ids": ["agent-uuid-2", "agent-uuid-3"]
      }
    }
  }
  ```
</ResponseExample>

## Respostas de erro

### 422 — Direção Incorreta

<ResponseExample>
  ```json theme={null}
  {
    "success": false,
    "message": "Agent must have direction=inbound to serve as a callback",
    "code": "INVALID_AGENT_DIRECTION"
  }
  ```
</ResponseExample>
