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

# Criar Webhook da Campanha

> Criar um webhook para eventos de nível de campanha

# Criar Webhook da Campanha

Cria um webhook inscrito em eventos de ciclo de vida da campanha e por chamada de campanha.

## Endpoint

```
POST /api/v1/campaigns/{campaign_id}/webhooks
```

## Parâmetros de caminho

<ParamField path="campaign_id" type="string" required>UUID da campanha.</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="name" type="string" required>Nome do webhook. Máximo de 255 caracteres.</ParamField>
<ParamField body="webhook_url" type="string" required>URL de entrega. Máximo de 500 caracteres.</ParamField>
<ParamField body="events" type="array" required>Array de eventos inscritos. Mínimo de 1.</ParamField>
<ParamField body="webhook_secret" type="string">Secret opcional de assinatura HMAC-SHA256. Máximo de 255 caracteres.</ParamField>
<ParamField body="timeout" type="integer">Timeout da requisição em segundos. Faixa: `5`–`120`. Padrão: `30`.</ParamField>
<ParamField body="max_retries" type="integer">Tentativas de retry em caso de falha. Faixa: `0`–`10`. Padrão: `3`.</ParamField>
<ParamField body="enabled" type="boolean">Padrão: `true`.</ParamField>
<ParamField body="http_method" type="string">Opções: `POST`, `PUT`, `PATCH`. Padrão: `POST`.</ParamField>
<ParamField body="authorization_scheme" type="string">Opções: `none`, `bearer`, `basic`, `api_key`, `custom`. Padrão: `none`.</ParamField>
<ParamField body="custom_headers" type="array">Array de objetos `{key, value}`.</ParamField>
<ParamField body="payload_templates" type="object">Sobrescritas de template por evento.</ParamField>
<ParamField body="include_call_events" type="boolean">Quando `true`, também entrega eventos por chamada para chamadas desta campanha (além dos eventos de nível de campanha).</ParamField>

## Exemplos

<RequestExample>
  ```bash theme={null}
  curl -X POST "https://app.talkover.ai/api/v1/campaigns/campaign-uuid/webhooks" \
    -H "Authorization: Bearer talq_your_environment_token_here" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Lifecycle Webhook",
      "webhook_url": "https://example.com/campaign-events",
      "events": ["campaign.started", "campaign.completed", "campaign_call.completed"],
      "include_call_events": false
    }'
  ```
</RequestExample>

## Resposta

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "id": "webhook-uuid-1",
      "campaign_id": "campaign-uuid",
      "name": "Lifecycle Webhook",
      "events": ["campaign.started", "campaign.completed", "campaign_call.completed"],
      "enabled": true,
      "include_call_events": false,
      "created_at": "2024-01-15T15:00:00Z"
    }
  }
  ```
</ResponseExample>
