All articles

DocsDevelopers

Webhooks

Add HTTPS endpoints, choose events such as points earned or reward redeemed, verify the HMAC-SHA256 signature, and handle retries and duplicates.

Webhooks let Thrice tell your systems when something happens in your loyalty program, such as a member earning points or redeeming a reward. Thrice sends a signed JSON POST request to an HTTPS address you choose. Use them to sync loyalty data to a CRM, trigger your own messages or keep a data warehouse up to date. For Klaviyo and Shopify Flow you don't need webhooks: Thrice connects to both directly, see Klaviyo and Shopify Flow.

Add an endpoint

  1. Open Developers.
  2. Under Webhooks, enter the Endpoint URL.
  3. Under Events, tick the events you want. Leave all unticked to receive every event, including event types added later.
  4. Choose Add endpoint.

Each endpoint gets its own signing secret. You can add up to 10 endpoints per store.

The URL must:

  • start with https://;
  • be at most 2,000 characters;
  • not contain a username or password;
  • point to a public internet address. localhost, addresses ending in .local, .internal or .localhost, private and link-local IP ranges and cloud metadata addresses are refused. Thrice checks this when you save and again on every delivery.

To change an endpoint's URL or events, choose Edit. Disable stops deliveries without deleting the endpoint, and Delete removes it.

You can also manage endpoints from an AI assistant connected through MCP. The assistant sees a signing secret once, when it creates an endpoint or rotates the secret, and can't show an existing one.

Send a test event

Choose Send test event on an endpoint. Thrice sends one signed test.ping request right away and tells you whether it was delivered, or why it failed. The test is a single attempt with no retries, and it works on disabled endpoints too.

{
  "id": "evt_6c1f0b9e2d7a4c53a8e14f2b9d0c7e31",
  "type": "test.ping",
  "created_at": "2026-11-23T11:20:00.000Z",
  "data": { "message": "Test event from Thrice" }
}

Events

Event When it's sent Fields in data
member.enrolled A customer becomes a member member_id
points.earned A member gets points member_id, points, sometimes order_id, rule_id or source
points.spent A member's points are spent or removed member_id, points, sometimes source
points.expiring A member's points will expire soon member_id, points, expires_at
points.expired A member's points expired member_id, points
reward.redeemed A member redeemed a reward member_id, redemption_id
tier.changed A member moved to another VIP tier, up or down member_id, from_tier_id, to_tier_id
referral.completed A friend the member referred placed their first order member_id, referral_id
challenge.completed A member completed a challenge member_id, challenge_id

Every event also has data.customer (see below) as long as the member still exists.

More detail on each:

  • points.earned is sent for order points (with order_id, the Shopify order ID), actions in the widget or on the loyalty page and the referrer's reward (with rule_id), birthday points, newsletter points given when a member subscribes after joining, challenge bonuses, positive adjustments from the admin or the REST API, points added by the Shopify Flow action Add loyalty points (with source: "flow"), and points added by a CSV import. When a customer becomes a member, however they join (the Join button in the widget or on the loyalty page, the customer account page, the Thank you page, or automatically from an order or a customer update), it's sent once right after member.enrolled with the sign-up and newsletter points they got, if any. Members created by a CSV import get no sign-up or newsletter points, so they send member.enrolled and then points.earned for the imported points only.
  • points.spent is sent when a member redeems a reward, for negative adjustments from the admin or the API, for the Shopify Flow action Remove loyalty points (with source: "flow"), and when undoing a CSV import takes points back. points is always a positive number. Points taken back after a refund or cancellation don't send it.
  • points.expiring is sent once per period without earning, on the day the member enters the warning window you chose in Settings (7, 14 or 30 days before expiry). A member who earns again and later goes quiet again gets it again. It's sent even if the Points expiring email is turned off. points is the balance that will expire and expires_at is when.
  • points.expired is sent when an inactive member's balance is cleared. points is the amount that expired.
  • reward.redeemed is sent for redemptions in the widget, on the loyalty page, on the customer account page and through the API.
  • source is only there for points a Shopify Flow action changed. Such points start no Flow workflow, so a workflow can't trigger itself; webhooks still get them. See Integrations.
  • tier.changed: from_tier_id is null when the member had no tier, and to_tier_id is null when they no longer have one.

IDs such as member_id, rule_id, redemption_id and the tier IDs are Thrice IDs. The tier IDs match tier.id and min_tier_id in the REST API, and redemption_id matches a redemption's id. To look a member up in the REST API, use data.customer.id.

Payload

Every request body has the same envelope:

Field Description
id The event ID, starting with evt_. It's the same on every retry and for every endpoint that receives the event. Use it to ignore duplicates.
type The event name
created_at When the event happened (ISO 8601, UTC)
data The event's fields, in snake_case

data.customer describes the member when the delivery is prepared, a moment after the event:

Field Description
id Shopify customer ID, as a string
email The member's email, or null
points_balance Balance at that moment
tier Current VIP tier name, or null

A full example:

{
  "id": "evt_0b8a5e52-6f1d-4c39-9a7e-3d2c1b0f4e85",
  "type": "points.earned",
  "created_at": "2026-11-23T10:15:42.318Z",
  "data": {
    "member_id": "cm3k9z7q10007qz0h4e2c8a1b",
    "points": 200,
    "order_id": "5809123456789",
    "customer": {
      "id": "7012345678901",
      "email": "ana@example.com",
      "points_balance": 650,
      "tier": "Gold"
    }
  }
}

Treat id as an opaque string. Fields can be added to data over time, so ignore any you don't recognize.

Request headers

Header Value
Content-Type application/json
User-Agent Thrice-Webhooks/1.0
X-Thrice-Event The event name, for example points.earned
X-Thrice-Delivery The delivery ID: one per event and endpoint, the same on every retry
X-Thrice-Signature t=<unix seconds>,v1=<signature>

Verify the signature

Check every request before you trust it. The signature is a hex-encoded HMAC-SHA256 of the timestamp, a dot and the raw request body, keyed with the endpoint's signing secret (it starts with whsec_):

v1 = hex( HMAC-SHA256( secret, t + "." + raw_body ) )
  1. Read t and v1 from X-Thrice-Signature.
  2. Compute the HMAC over the body exactly as received. Parsing the JSON and serializing it again changes the bytes and breaks the check.
  3. Compare your result with v1 in constant time.
  4. Reject the request if t is more than 5 minutes from your clock. Every attempt, including retries, is signed with a fresh timestamp.

A working example with Node.js and no dependencies (save it as server.mjs and run node server.mjs):

import { createServer } from "node:http";
import { createHmac, timingSafeEqual } from "node:crypto";

const SECRET = process.env.THRICE_WEBHOOK_SECRET; // whsec_...
const TOLERANCE_SECONDS = 5 * 60;

export function verifySignature(rawBody, header, secret, nowMs = Date.now()) {
  if (typeof header !== "string") return false;
  const fields = {};
  for (const part of header.split(",")) {
    const i = part.indexOf("=");
    if (i > 0) fields[part.slice(0, i).trim()] = part.slice(i + 1).trim();
  }
  const { t, v1 } = fields;
  if (!/^\d+$/.test(t ?? "") || !/^[0-9a-f]{64}$/.test(v1 ?? "")) return false;
  if (Math.abs(nowMs / 1000 - Number(t)) > TOLERANCE_SECONDS) return false;
  const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
  return timingSafeEqual(expected, Buffer.from(v1, "hex"));
}

createServer((req, res) => {
  if (req.method !== "POST" || req.url !== "/webhooks/thrice") {
    res.writeHead(404).end();
    return;
  }
  const chunks = [];
  req.on("data", (chunk) => chunks.push(chunk));
  req.on("end", () => {
    const rawBody = Buffer.concat(chunks).toString("utf8");
    if (!verifySignature(rawBody, req.headers["x-thrice-signature"], SECRET)) {
      res.writeHead(401).end();
      return;
    }
    const event = JSON.parse(rawBody);
    // Answer first, then do the work: Thrice waits at most 10 seconds.
    res.writeHead(200).end();
    console.log(event.id, event.type, event.data);
  });
}).listen(3000);

If you use a framework, give the verification the raw body, for example with express.raw({ type: "application/json" }) in Express, not the parsed JSON.

Note: The example listens on plain HTTP to stay short. Endpoint addresses must be public https:// addresses, so put it behind TLS (a reverse proxy or a tunnel while you test) and register the full address, ending in /webhooks/thrice.

Delivery and retries

  • Any 2xx response counts as delivered. Redirects are not followed and count as failures.
  • Thrice waits up to 10 seconds for a response. Answer quickly and do slow work afterwards.
  • After a failure (an error status, a timeout or a connection error), Thrice tries again up to 6 more times, 7 attempts in all. The wait between attempts grows each time, starting at about 30 seconds and never more than an hour.
  • After the last attempt the delivery is marked failed. A URL that resolves to a private address fails at once, without retries.
  • When you disable an endpoint, new events aren't sent to it and retries still waiting fail with "Endpoint is disabled". Events that happen while it's disabled are not sent later.
  • Events are not guaranteed to arrive in order, and a delivery can arrive more than once, for example if your server took longer than 10 seconds to answer. Use the event id to ignore repeats.

There's no button to resend a failed delivery. If your endpoint was down, use the REST API to read the current state of the members you care about.

Delivery log

Recent deliveries on the Developers page lists the latest 25 deliveries across all your endpoints, with the event, endpoint, status (Pending, Delivered or Failed), number of attempts, the last error and the time. The Overview page also shows how many deliveries failed in the last 7 days, when there are any.

Rotate the secret

Choose Reveal secret to see and copy an endpoint's signing secret. Choose Rotate secret to replace it. The old secret stops working at once, so every delivery after that, including retries of earlier events, is signed with the new one. Update your server straight after rotating.