Atonom
DocumentationAPI Reference
Webhooks

Webhook Authorization

Verify Atonom webhook deliveries with the JWT in X-Atonom-Signature. The Authorization bearer token is deprecated.

Atonom signs each webhook delivery with a short-lived JWT in the X-Atonom-Signature header. Verify it with your tenant webhook public key (PS256) before you trust the JSON.

Older resthook and inbound-call deliveries also include a deprecated JWT in Authorization. Authorization bearer token is that check. New integrations should use X-Atonom-Signature.

Get your webhook public key

  1. Log in to your Atonom account at https://app.getsignals.ai
  2. Navigate to https://app.getsignals.ai/#/settings/security
  3. Open the accordion card titled Webhook Verification
Atonom Security Page
  1. Copy the public key (PEM text)
Atonom Security Webhook Card Open

X-Atonom-Signature

The header value is the JWT:

X-Atonom-Signature: <jwt>

That JWT carries two signatures, and both use your webhook public key:

  • The JWT signature is the third segment of the token. Verifying the JWT proves Atonom issued the claims and that those claims are intact.
  • The sig claim is a separate PS256 signature of the raw request body. Verifying sig proves the body is intact.

How verification works

  1. Read the raw request body as bytes (or an exact string) before parsing JSON. You need the same octets Atonom POSTed. Parsing the JSON and serializing it again produces different bytes, and the body check fails.
  2. Read the JWT from X-Atonom-Signature (trim whitespace).
  3. Verify the JWT with your webhook RSA public key in PEM form. The token is signed with PS256 (RSA-PSS with SHA-256).
  4. Validate claims after JWT verification succeeds:
    • iss: Atonom tenant id that sent the request (numeric).
    • aud: The webhook endpoint URL Atonom targeted. It must match the URL you configured (trimmed). The token was minted for that original URL, including when your server answers a redirect.
    • iat and exp: Issued-at and expiry. Tokens are valid for five minutes from iat.
    • sig: A standard base64 string (+, /, and = padding). It is the body signature verified in the next step. It sits in the JWT payload, separate from the token's third segment, which is base64url.
  5. Verify sig against the body. Base64-decode sig and confirm those bytes are a PS256 signature of the raw body from step 1, using the same webhook public key: RSA-PSS, SHA-256, MGF1 with SHA-256, and a salt length equal to the digest (32 bytes).

Example: JavaScript (Node.js)

Use jose for the JWT and Node's crypto for the body signature:

npm install jose
import * as jose from "jose";
import crypto from "crypto";

const WEBHOOK_PUBLIC_KEY_PEM = process.env.ATONOM_WEBHOOK_PUBLIC_KEY;
const EXPECTED_AUDIENCE = process.env.ATONOM_WEBHOOK_URL; // URL you saved in Atonom

/**
 * @param {Buffer} rawBody exact bytes from the HTTP body
 * @param {string} signatureHeader value of X-Atonom-Signature
 * @returns {Promise<jose.JWTPayload>}
 */
export async function verifyAtonomSignature(rawBody, signatureHeader) {
  const token = signatureHeader?.trim();
  if (!token) {
    throw new Error("Missing X-Atonom-Signature header");
  }

  const publicKey = await jose.importSPKI(WEBHOOK_PUBLIC_KEY_PEM, "PS256");
  const verifyKey = crypto.createPublicKey(WEBHOOK_PUBLIC_KEY_PEM);

  const { payload } = await jose.jwtVerify(token, publicKey, {
    algorithms: ["PS256"],
    audience: EXPECTED_AUDIENCE,
    clockTolerance: 60,
  });

  const sigB64 = payload.sig;
  if (typeof sigB64 !== "string" || !sigB64) {
    throw new Error("JWT missing sig claim");
  }

  const bodySig = Buffer.from(sigB64, "base64");
  const ok = crypto.verify(
    "sha256",
    rawBody,
    {
      key: verifyKey,
      padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
      saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST,
    },
    bodySig,
  );
  if (!ok) {
    throw new Error("Body signature mismatch");
  }

  return payload;
}

In Express, capture the raw body with a verifier middleware (for example express.raw({ type: "application/json" })) on the webhook route so req.body is a Buffer. In Next.js App Router, use await request.arrayBuffer() before JSON.parse.

Example: Python

pip install PyJWT cryptography
import base64
import os

import jwt
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding

WEBHOOK_PUBLIC_KEY_PEM = os.environ["ATONOM_WEBHOOK_PUBLIC_KEY"]
EXPECTED_AUDIENCE = os.environ["ATONOM_WEBHOOK_URL"]


def verify_atonom_signature(raw_body: bytes, signature_header: str | None) -> dict:
    if not signature_header or not signature_header.strip():
        raise ValueError("Missing X-Atonom-Signature header")
    token = signature_header.strip()

    public_key = serialization.load_pem_public_key(
        WEBHOOK_PUBLIC_KEY_PEM.encode("utf-8"),
        backend=default_backend(),
    )

    payload = jwt.decode(
        token,
        public_key,
        algorithms=["PS256"],
        audience=EXPECTED_AUDIENCE,
        options={"require": ["exp", "iat", "iss", "aud", "sig"]},
        leeway=60,
    )

    sig_b64 = payload.get("sig")
    if not isinstance(sig_b64, str):
        raise ValueError("JWT missing sig claim")
    body_sig = base64.b64decode(sig_b64)

    public_key.verify(
        body_sig,
        raw_body,
        padding.PSS(
            mgf=padding.MGF1(hashes.SHA256()),
            salt_length=padding.PSS.MAX_LENGTH,
        ),
        hashes.SHA256(),
    )

    return payload

If verification fails, respond with 401 Unauthorized and do not treat the JSON body as trusted.

Authorization bearer token (deprecated)

The delivery sets the header like this:

Authorization: Bearer <jwt>

This JWT uses the same webhook public key and PS256. It does not include a signature of the raw body. Its claims are exp, iat, and tenant_id.

How verification works

  1. Read the bearer token from Authorization (scheme Bearer, case-insensitive).
  2. Verify the JWT using your webhook RSA public key in PEM form (-----BEGIN PUBLIC KEY-----). The token is signed with PS256 (RSA-PSS with SHA-256).
  3. Validate claims after verification succeeds:
    • exp: token expiry (tokens are valid for a short window, currently five minutes from issuance).
    • iat: issued-at time (optional sanity check vs your server clock).
    • tenant_id: Atonom tenant that sent the event. You can compare this to the tenant_id field in the JSON body of the same request for consistency.

The JWT payload is not encrypted; only the signature proves authenticity.

Example: JavaScript (Node.js)

Use a library that supports PS256, for example jose:

npm install jose
import * as jose from "jose";

const WEBHOOK_PUBLIC_KEY_PEM = process.env.ATONOM_WEBHOOK_PUBLIC_KEY; // full PEM string

/**
 * @param {import('http').IncomingMessage | { headers: Record<string, string | string[] | undefined> }} req
 * @returns {Promise<jose.JWTPayload>}
 */
export async function verifyAtonomWebhook(req) {
  const raw = req.headers["authorization"] ?? req.headers["Authorization"];
  const auth = Array.isArray(raw) ? raw[0] : raw;
  if (!auth || typeof auth !== "string") {
    throw new Error("Missing Authorization header");
  }
  const m = auth.match(/^Bearer\s+(.+)$/i);
  if (!m) {
    throw new Error("Authorization must be a Bearer token");
  }
  const token = m[1].trim();

  const publicKey = await jose.importSPKI(WEBHOOK_PUBLIC_KEY_PEM, "PS256");

  const { payload } = await jose.jwtVerify(token, publicKey, {
    algorithms: ["PS256"],
    clockTolerance: 60, // seconds; optional, helps with clock skew
  });

  return payload;
}

Example: Python

Use PyJWT with the cryptography backend so PS256 is available:

pip install PyJWT cryptography
import os
import re
import jwt
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend

WEBHOOK_PUBLIC_KEY_PEM = os.environ["ATONOM_WEBHOOK_PUBLIC_KEY"]  # full PEM string

_bearer_re = re.compile(r"^Bearer\s+(.+)$", re.IGNORECASE)


def verify_atonom_webhook(authorization_header: str | None) -> dict:
    if not authorization_header:
        raise ValueError("Missing Authorization header")
    m = _bearer_re.match(authorization_header.strip())
    if not m:
        raise ValueError("Authorization must be a Bearer token")
    token = m.group(1).strip()

    public_key = serialization.load_pem_public_key(
        WEBHOOK_PUBLIC_KEY_PEM.encode("utf-8"),
        backend=default_backend(),
    )

    payload = jwt.decode(
        token,
        public_key,
        algorithms=["PS256"],
        options={"require": ["exp", "iat", "tenant_id"]},
        leeway=60,  # seconds; optional clock skew tolerance
    )

    return payload

If verification fails, respond with 401 Unauthorized (or reject the connection in your framework’s idiomatic way) and do not treat the payload as trusted.

On this page