Skip to content

Request signing

POST /v1/events is the one endpoint that requires more than your bearer key: every event body must be signed with your tenant’s connector signing secret — a credential (whsec_…) that is entirely separate from your API key. Your API key proves who’s calling; the signature proves this exact body came from someone holding the signing secret, and that it hasn’t been replayed.

HeaderValue
X-Loyalty-Signaturev1=<hex> — HMAC-SHA256 of the signed payload (below), keyed on your signing secret, hex-encoded.
X-Loyalty-TimestampUnix seconds when the request was signed. Requests outside the accepted skew window are rejected as a replay.
X-Loyalty-NonceA fresh, unique value per request. Reusing a nonce that was already accepted is rejected as a replay, even within the timestamp’s skew window.

The signed payload is the literal string {timestamp}.{raw_body} — the timestamp, a period, and the exact bytes of the JSON body you’re about to send (not a re-serialized or reformatted copy: signing a logically-equal-but-differently-formatted body produces a different signature and the request is rejected).

signature = hex(HMAC-SHA256(signing_secret, `${timestamp}.${rawBody}`))
header = `v1=${signature}`

A failed or missing signature, or a timestamp outside the accepted window, or a reused nonce, all fail closed with 401 (signature_invalid / replay_detected) — the event is never processed.

events.ingest(...) computes and attaches all three headers for you from the signingSecret you configured on the client — you never construct them by hand. If you need to sign a body yourself (a custom transport, or verifying your own request before sending), the SDK exports the same signer:

import { signEventBody, SIGNATURE_HEADER, TIMESTAMP_HEADER, NONCE_HEADER } from '@tesseraloyalty/sdk';
const rawBody = JSON.stringify(payload); // sign and send the SAME bytes
const signed = await signEventBody(rawBody, signingSecret);
// signed.headers → { [SIGNATURE_HEADER]: '...', [TIMESTAMP_HEADER]: '...', [NONCE_HEADER]: '...' }

See Earning events for the full request, and Errors & the envelope for signature_invalid / replay_detected alongside every other error code.