Skip to content

Authenticate webhook requests

Configure HMAC-SHA256, OAuth 2.0, or App2App authentication in Admin → Integrations → Webhooks. Your endpoint verifies the credentials or signature on each request. These credentials are separate from your RedJade API credentials.

Set a shared secret in RedJade and in your receiver. RedJade includes these headers:

Header Value
X-Webhook-Timestamp Unix timestamp in seconds
X-Webhook-Signature sha256= followed by a lowercase hexadecimal signature

The signature covers the timestamp, a literal period, and the original HTTP body bytes:

HMAC-SHA256(secret, timestamp + "." + raw_body)

Verify the signature against the raw body with a constant-time comparison. Parsing and re-serializing JSON can change the bytes and invalidate the signature.

This Node.js example also rejects timestamps more than five minutes from the receiver’s clock. That tolerance is an example receiver policy and requires synchronized clocks.

verify-webhook.mjs
import { createHmac, timingSafeEqual } from 'node:crypto';
export function verifyWebhook({ body, timestamp, signature, secret, now = Date.now() }) {
if (!Buffer.isBuffer(body) || typeof secret !== 'string' || !secret) return false;
if (typeof timestamp !== 'string' || !/^\d+$/.test(timestamp)) return false;
if (typeof signature !== 'string' || !/^sha256=[0-9a-f]{64}$/.test(signature)) return false;
if (Math.abs(now / 1000 - Number(timestamp)) > 300) return false;
const expected = createHmac('sha256', secret).update(`${timestamp}.`).update(body).digest();
const received = Buffer.from(signature.slice('sha256='.length), 'hex');
return timingSafeEqual(expected, received);
}

Pass the raw body as a Buffer, the two headers as strings, and your shared secret. Reject the request if verification returns false.

Retried events can have fresh signatures. Handle duplicate events separately.

Configure your token URL, client ID, and client secret. RedJade requests a token with a form-encoded grant_type=client_credentials request, then sends it to your endpoint in Authorization: Bearer ….

Your token server returns a JSON body with access_token and expires_in in seconds:

{
"access_token": "YOUR_RECEIVER_TOKEN",
"expires_in": 3600
}

RedJade uses a one-hour expiry when expires_in is omitted and refreshes cached tokens within 60 seconds of expiry. Validate the token at your endpoint. This token response has no response wrapper; it comes from your token server.

Configure a consumer ID, RSA private key, and key version for an App2App receiver. RedJade sends WM_CONSUMER.ID, WM_CONSUMER.INTIMESTAMP (Unix milliseconds), WM_SEC.KEY_VERSION, and WM_SEC.AUTH_SIGNATURE.

The signature is Base64-encoded RSA-SHA256 over:

consumer_id + "\n" + timestamp_ms + "\n" + key_version + "\n"

Verify with the corresponding public key and reject stale timestamps. App2App signs the header values above; the body is not covered by the signature.

With authentication disabled, RedJade sends no authentication credentials or signature. Use this setting only when another trusted layer verifies the sender; the public endpoint URL alone does not authenticate a request.