TenkaTenka
Sign in

Tenka Help Center › Developer area › Webhooks

Webhooks

Tenka tells your system when something happens.

Register the URL under Settings › Webhooks with a secret: each delivery is signed in X-Tenka-Signature (HMAC-SHA256 of the body) and retried if your system does not answer 2xx. The events:

The events

NameDescription
fatura.pagaInvoice paid (payment confirmed)
proposta.aceitaSales proposal accepted (by the customer)
negocio.ganhoDeal won → contract created
demanda.criadaTicket created
lead.criadoNew lead in the CRM
remessa.criadaRemessa de rolos aberta para o beneficiador (API)
apontamento.criadoApontamento de produção lançado (API)

Headers of each delivery

HeaderDescription
X-Tenka-EventThe event (one of the list above).
X-Tenka-DeliveryUnique delivery identifier: use it to avoid processing twice.
X-Tenka-Signaturesha256= followed by the hex HMAC-SHA256 of the raw body with the subscription secret.
X-Tenka-Event-VersionOptional: contract version of the event body.
X-Tenka-Replay-OfOptional: present only when the delivery is a resend; carries the original delivery id.

How to verify the signature

Compute the HMAC-SHA256 of the body exactly as received (before parsing), with the subscription's whsec_ secret, and compare with the header in constant time. Mismatch: answer 401 and discard.

Node (SDK)
import crypto from "node:crypto";

// raw = the request body exactly as received (Buffer)
function signatureOk(raw, header, secret) {
  const expected = "sha256=" + crypto.createHmac("sha256", secret).update(raw).digest("hex");
  return typeof header === "string" && header.length === expected.length
    && crypto.timingSafeEqual(Buffer.from(header), Buffer.from(expected));
}

Answer 2xx within a few seconds and process later; without 2xx the delivery is retried.