Webhooks

Verificar firmas de webhooks

Comprueba el encabezado X-Studio-Signature para que solo confíes en las solicitudes que enviamos.

11 oct 2026Lectura de 1 min

Every request to a custom endpoint is signed with your endpoint's secret. Check the signature before you trust the body.

How it's signed

  • The signature is an HMAC-SHA256 of the raw request body, keyed with your signing secret.
  • It is sent as X-Studio-Signature: sha256=<hex digest>.
  • Secrets start with whsec_. Find yours under Signing secret on the endpoint page.

Node.js

import { createHmac, timingSafeEqual } from "node:crypto"

export function verify(rawBody: string, header: string, secret: string) {
  const expected = `sha256=${createHmac("sha256", secret).update(rawBody).digest("hex")}`
  const a = Buffer.from(header)
  const b = Buffer.from(expected)
  return a.length === b.length && timingSafeEqual(a, b)
}

Python

import hashlib, hmac

def verify(raw_body: bytes, header: str, secret: str) -> bool:
    expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(header, expected)

Common mistakes

  • Hash the exact bytes you received. Parsing the JSON and serialising it again changes the bytes, so the signature won't match.
  • Use a constant-time comparison, as in the examples above, instead of ==.
  • After Rotate secret, update your server straight away. The old secret stops working.

Chat-app destinations such as Slack receive a formatted message instead, and are not signed.

¿Te resultó útil?
Publica contenido alineado con tu marca en minutos

Contenido de IA, programación, interacción y un conjunto completo de marketing — gratis para empezar.

Empieza gratis
Volver a la documentación

Seguir leyendo

Ponlo en práctica en AeroReply

Todas las herramientas viven en la misma cuenta, desde el plan gratuito en adelante.

Pónlo en práctica

Empieza gratis: diseña, programa y haz crecer todo desde un solo espacio de trabajo.

  • Sin tarjeta de crédito
  • Configuración en 2 minutos
  • Cancela en cualquier momento