Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.atriby.com/llms.txt

Use this file to discover all available pages before exploring further.

Cada entrega de webhook inclui headers para identificação, deduplicação e assinatura.

Headers

HeaderDescrição
x-atriby-eventEvento enviado, como order.paid.
x-atriby-deliveryID único da entrega.
x-atriby-timestampTimestamp usado na assinatura.
x-atriby-signaturesha256=<hmac>.

Como a assinatura é calculada

HMAC_SHA256(secret, timestamp + "." + rawBody)
O valor final é enviado como:
sha256=<hex>

Exemplo conceitual em Node.js

import crypto from "node:crypto"

function verifyWebhook({ secret, timestamp, rawBody, signature }) {
  const expected =
    "sha256=" +
    crypto
      .createHmac("sha256", secret)
      .update(`${timestamp}.${rawBody}`)
      .digest("hex")

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected),
  )
}
Use o raw body original. Se você fizer parse JSON antes de validar e serializar novamente, a assinatura pode não bater.

Boas práticas

  • Rejeite timestamps antigos.
  • Deduplicate por x-atriby-delivery.
  • Responda 2xx apenas depois de aceitar o evento.
  • Guarde o segredo em cofre/variável de ambiente.