Pular para o conteúdo

Referência da API

Webhooks (API)

Cadastre URLs de webhook, teste a entrega, consulte o log e reenvie entregas que falharam.

Ver .md

Veja os eventos, o formato do payload e como verificar a assinatura em Webhooks. Esta página mostra os endpoints para gerenciar os webhooks.

O objeto Webhook

Campo Tipo Descrição
id string Id com prefixo whk_
url string URL que recebe os eventos (HTTPS)
events string[] Eventos assinados
number_id string | null Só eventos deste número. null = todos os números
secret string Segredo da assinatura. Só aparece na criação
created_at string Data de criação

Criar webhook

POST /webhooks

Campo Tipo
url string Obrigatório. URL HTTPS que recebe POST
events string[] Opcional. Padrão: todos os eventos
number_id string Opcional. Só eventos deste número

Guarde o secret em AVISA_WEBHOOK_SECRET. Ele não aparece de novo.

curl -X POST "https://api.avisa.dev/v1/webhooks" \
  -H "Authorization: Bearer $AVISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://meusistema.com/webhooks/avisa",
  "events": [
    "message.received",
    "message.failed"
  ]
}'
{
  "id": "whk_7u8i9o0p",
  "url": "https://meusistema.com/webhooks/avisa",
  "events": ["message.received", "message.failed"],
  "number_id": null,
  "secret": "whsec_4f9a2c7e1b8d3a6f0c5e9b2d7a4f1c8e",
  "created_at": "2026-12-04T15:20:00Z"
}

Listar webhooks

GET /webhooks

curl -X GET "https://api.avisa.dev/v1/webhooks" \
  -H "Authorization: Bearer $AVISA_API_KEY"

Remover webhook

DELETE /webhooks/{id}

curl -X DELETE "https://api.avisa.dev/v1/webhooks/whk_7u8i9o0p" \
  -H "Authorization: Bearer $AVISA_API_KEY"

Testar webhook

POST /webhooks/{id}/test

Envia um evento webhook.test assinado para a URL e devolve o que o seu servidor respondeu. Use para conferir a verificação da assinatura.

curl -X POST "https://api.avisa.dev/v1/webhooks/whk_7u8i9o0p/test" \
  -H "Authorization: Bearer $AVISA_API_KEY"
{ "status_code": 200, "duration_ms": 184, "body": "ok" }

Log de entregas

GET /webhooks/{id}/deliveries

Cada evento enviado para a URL, com o status HTTP, número de tentativas e a próxima retentativa.

curl -X GET "https://api.avisa.dev/v1/webhooks/whk_7u8i9o0p/deliveries?limit=20" \
  -H "Authorization: Bearer $AVISA_API_KEY"
{
  "data": [
    { "id": "dlv_1q2w3e4r", "event": "message.received", "status_code": 500, "attempts": 2, "delivered_at": null, "next_retry_at": "2026-12-04T15:56:00Z", "created_at": "2026-12-04T15:25:00Z" }
  ],
  "next_cursor": null
}

Reenviar entrega

POST /webhooks/{id}/deliveries/{delivery_id}/retry

Reenvia agora uma entrega, sem esperar a próxima retentativa automática.

curl -X POST "https://api.avisa.dev/v1/webhooks/whk_7u8i9o0p/deliveries/dlv_1q2w3e4r/retry" \
  -H "Authorization: Bearer $AVISA_API_KEY"