Visão geral
Receba um POST assinado quando algo acontecer, em vez de perguntar.
Cadastrar um endpoint
curl https://api.slip.amivu.com.br/webhooks/endpoints \
-H "Authorization: ApiKey $CORE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer_id": "id-da-sua-empresa",
"url": "https://sua-empresa.com.br/webhooks/core",
"events": ["transaction.settled", "transaction.failed", "transaction.returned"]
}'A URL precisa ser HTTPS. A resposta traz o secret do endpoint uma única vez: é com ele que você verifica a assinatura.
O que chega
content-type: application/json
x-corebanking-event-id: 3b1f9c2e-8d4a-4e7b-9f10-6c2d8e5a1b7c
x-corebanking-signature: t=1763575200,v1=5f2b…c9e1{
"event_id": "3b1f9c2e-8d4a-4e7b-9f10-6c2d8e5a1b7c",
"event_type": "transaction.settled",
"occurred_at": "2026-11-19T18:00:00.000Z",
"data": {
"transactionId": "c0a8…",
"accountId": "7f0c…",
"customerId": "e21b…",
"type": "pix",
"direction": "outbound",
"amountCents": "15990",
"status": "settled",
"providerRef": "E1234…",
"counterpartyKeyMasked": "lo***@exemplo.com.br",
"reason": null,
"heldFunds": false
}
}Dados pessoais nunca saem em claro: documentos e chaves Pix chegam mascarados. Use os ids para buscar o detalhe pela API.
Verificar a assinatura
A assinatura é um HMAC-SHA256, em hexadecimal, de {t}.{corpo cru} com o secret do endpoint. Verifique sobre o corpo exatamente como chegou, antes de fazer parse.
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verify(secret, rawBody, header, toleranceSeconds = 300) {
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
const given = Buffer.from(parts.v1 ?? '', 'hex');
return given.length === 32 && timingSafeEqual(given, Buffer.from(expected, 'hex'));
}import hmac, hashlib, time
def verify(secret: str, raw_body: bytes, header: str, tolerance: int = 300) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
t = int(parts.get("t", 0))
if not t or abs(time.time() - t) > tolerance:
return False
msg = f"{t}.".encode() + raw_body
expected = hmac.new(secret.encode(), msg, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))Entrega e reentrega
- Responda 2xx rápido e processe depois. Qualquer outra resposta, ou timeout, conta como falha.
- Falhas são reenviadas com backoff exponencial, até 8 tentativas e no máximo uma hora entre elas.
- A mesma entrega pode chegar mais de uma vez: use
event_idpara descartar duplicadas. - A ordem não é garantida. Para o estado atual, consulte a transação pela API.