Pular para o conteúdo principal

Listar Webhooks

GET /backend/webhooks
Retorna todos os webhooks configurados.
curl -X GET "https://api.leavo.ai/backend/webhooks" \
  -H "Authorization: Bearer sua_chave_aqui"
[
  {
    "id": "uuid",
    "name": "Webhook Formulário",
    "type": "inbound",
    "webhook_token": "abc123",
    "is_active": true,
    "total_calls": 150,
    "last_triggered": "2024-01-15T10:30:00Z"
  },
  {
    "id": "uuid",
    "name": "Notificar CRM",
    "type": "outbound",
    "target_url": "https://crm.exemplo.com/api",
    "is_active": true,
    "total_calls": 75,
    "last_triggered": "2024-01-15T09:00:00Z"
  }
]

Obter Webhook

GET /backend/webhooks/{id}
Retorna detalhes completos de um webhook específico.
id
string
obrigatório
UUID do webhook
curl -X GET "https://api.leavo.ai/backend/webhooks/uuid-do-webhook" \
  -H "Authorization: Bearer sua_chave_aqui"
{
  "id": "uuid",
  "tenant_id": "uuid",
  "name": "Webhook Formulário Site",
  "description": "Recebe leads do formulário do site",
  "type": "inbound",
  "webhook_token": "abc123xyz",
  "is_active": true,
  "field_mapping": {
    "name": "form.nome_completo",
    "email": "form.email",
    "phone": "form.telefone"
  },
  "custom_field_mapping": {
    "interesse": "form.produto_interesse"
  },
  "default_status_id": "uuid",
  "default_tags": ["uuid-1", "uuid-2"],
  "total_calls": 150,
  "last_triggered": "2024-01-15T10:30:00Z",
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-10T00:00:00Z"
}

Atualizar Webhook

PUT /backend/webhooks/{id}
Atualiza um webhook existente.
id
string
obrigatório
UUID do webhook
curl -X PUT "https://api.leavo.ai/backend/webhooks/uuid-do-webhook" \
  -H "Authorization: Bearer sua_chave_aqui" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Webhook Formulário Atualizado",
    "is_active": false
  }'
{
  "id": "uuid",
  "name": "Webhook Formulário Atualizado",
  "is_active": false,
  // ... outros campos
}

Deletar Webhook

DELETE /backend/webhooks/{id}
Remove um webhook permanentemente.
id
string
obrigatório
UUID do webhook
Esta ação é irreversível. Certifique-se de que não há integrações dependendo deste webhook.
curl -X DELETE "https://api.leavo.ai/backend/webhooks/uuid-do-webhook" \
  -H "Authorization: Bearer sua_chave_aqui"
// Sem conteúdo

Regenerar Token

Para webhooks inbound, você pode regenerar o token de segurança:
curl -X POST "https://api.leavo.ai/backend/webhooks/uuid-do-webhook/regenerate-token" \
  -H "Authorization: Bearer sua_chave_aqui"
Ao regenerar o token, a URL antiga do webhook deixará de funcionar. Atualize suas integrações.