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.
HMAC-SHA256
Section titled “HMAC-SHA256”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:
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.
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.
OAuth 2.0 client credentials
Section titled “OAuth 2.0 client credentials”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:
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.
App2App RSA signatures
Section titled “App2App RSA signatures”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:
Verify with the corresponding public key and reject stale timestamps. App2App signs the header values above; the body is not covered by the signature.
No authentication
Section titled “No authentication”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.