# Webhooks

> Events a store sends to its owner's own HTTPS endpoints, to the apps installed on it (the topics marked apps: those an app chose whose area its installation reads, and app.uninstalled and store.erase_requested, which every installed app is sent) and, for the topics marked services, to Zapier,…

Events a store sends to its owner's own HTTPS endpoints, to the apps installed on it (the topics marked apps: those an app chose whose area its installation reads, and app.uninstalled and store.erase_requested, which every installed app is sent) and, for the topics marked services, to Zapier, Make and Slack. Each delivery is a POST of JSON, signed, and tried again when it is not taken: after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours.

An owner adds endpoints and chooses their topics in the admin, under [Your own endpoints](https://kaizenaflow.com/admin/{store}/integrations/endpoints). Every topic and the JSON Schema of its payload are published at [`/api/webhooks/v1/topics.json`](https://kaizenaflow.com/api/webhooks/v1/topics.json) and in the Admin API's OpenAPI document under `webhooks`.

## Topics {#topics}

| Topic | What happened | Sent to |
|---|---|---|
| [`order.paid`](https://docs.kaizenaflow.com/reference/webhooks/order-paid) | A shopper paid, or a subscription renewed. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`order.sent`](https://docs.kaizenaflow.com/reference/webhooks/order-sent) | An order was marked as sent, with its tracking. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`order.cancelled`](https://docs.kaizenaflow.com/reference/webhooks/order-cancelled) | A paid order was cancelled. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`order.refunded`](https://docs.kaizenaflow.com/reference/webhooks/order-refunded) | Money went back to the shopper, in full or in part. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`customer.created`](https://docs.kaizenaflow.com/reference/webhooks/customer-created) | A shopper made an account. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`subscription.started`](https://docs.kaizenaflow.com/reference/webhooks/subscription-started) | A subscription's first payment went through. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`subscription.cancelled`](https://docs.kaizenaflow.com/reference/webhooks/subscription-cancelled) | A subscription was cancelled. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`return.requested`](https://docs.kaizenaflow.com/reference/webhooks/return-requested) | A shopper or staff started a return, or a withdrawal's return. | Your own endpoints, and apps |
| [`withdrawal.received`](https://docs.kaizenaflow.com/reference/webhooks/withdrawal-received) | A shopper confirmed that they withdraw from a purchase. | Your own endpoints, and apps |
| [`product.created`](https://docs.kaizenaflow.com/reference/webhooks/product-created) | A product was made, by hand, an import or the AI manager. | Your own endpoints, and apps |
| [`product.updated`](https://docs.kaizenaflow.com/reference/webhooks/product-updated) | A product was saved. | Your own endpoints, and apps |
| [`stock.low`](https://docs.kaizenaflow.com/reference/webhooks/stock-low) | A variant's stock fell to its low-stock level. | Your own endpoints, and apps |
| [`discount.created`](https://docs.kaizenaflow.com/reference/webhooks/discount-created) | A discount code was made. | Your own endpoints, and apps |
| [`inventory.updated`](https://docs.kaizenaflow.com/reference/webhooks/inventory-updated) | A variant's stock on hand moved at a location: one event per variant and minute, with its stock as it is then. | Your own endpoints, and apps |
| [`product.archived`](https://docs.kaizenaflow.com/reference/webhooks/product-archived) | A product was put away: off the site and out of the admin's lists. | Your own endpoints, and apps |
| [`order.created`](https://docs.kaizenaflow.com/reference/webhooks/order-created) | An order was made, paid or still waiting for payment: at checkout, from a draft or by a subscription. | Your own endpoints, and apps |
| [`order.updated`](https://docs.kaizenaflow.com/reference/webhooks/order-updated) | A change to an order's lines or prices was applied (D174). | Your own endpoints, and apps |
| [`fulfilment.created`](https://docs.kaizenaflow.com/reference/webhooks/fulfilment-created) | A parcel of an order was recorded, with its carrier and tracking. | Your own endpoints, and apps |
| [`fulfilment.updated`](https://docs.kaizenaflow.com/reference/webhooks/fulfilment-updated) | A parcel's tracking moved on, its tracking number changed, or it was undone. | Your own endpoints, and apps |
| [`refund.created`](https://docs.kaizenaflow.com/reference/webhooks/refund-created) | Money went back to a customer, to the payment or as store credit: the refund itself. | Your own endpoints, and apps |
| [`return.updated`](https://docs.kaizenaflow.com/reference/webhooks/return-updated) | A return moved on: approved, declined, on its way, received, inspected, closed or cancelled. | Your own endpoints, and apps |
| [`quote.requested`](https://docs.kaizenaflow.com/reference/webhooks/quote-requested) | A shopper asked for a quote: a draft order to price and send. | Your own endpoints, and apps |
| [`draft.sent`](https://docs.kaizenaflow.com/reference/webhooks/draft-sent) | A draft order or quote was sent to the customer with its pay link. | Your own endpoints, and apps |
| [`customer.updated`](https://docs.kaizenaflow.com/reference/webhooks/customer-updated) | A customer's name, email, phone, address or company was changed, by them or by staff. | Your own endpoints, and apps |
| [`customer.erased`](https://docs.kaizenaflow.com/reference/webhooks/customer-erased) | A customer's account was erased at their request (D162): only its id, so you can erase what you keep too. | Your own endpoints, and apps |
| [`subscription.renewed`](https://docs.kaizenaflow.com/reference/webhooks/subscription-renewed) | A subscription's renewal was paid. | Your own endpoints, and apps |
| [`subscription.payment_failed`](https://docs.kaizenaflow.com/reference/webhooks/subscription-payment-failed) | A subscription's renewal could not be charged: it waits for the subscriber's payment. | Your own endpoints, and apps |
| [`gift_card.issued`](https://docs.kaizenaflow.com/reference/webhooks/gift-card-issued) | A gift card or store credit was issued: never its code. | Your own endpoints, and apps |
| [`review.created`](https://docs.kaizenaflow.com/reference/webhooks/review-created) | A buyer wrote a product review, waiting for the store's check or published at once. | Your own endpoints, and apps |
| [`experiment.answered`](https://docs.kaizenaflow.com/reference/webhooks/experiment-answered) | A running A/B test has an answer for the first time: its verdict, the version that did best and each version's figures. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`contract.sent`](https://docs.kaizenaflow.com/reference/webhooks/contract-sent) | A deal's contract was sent: its first signer is asked to sign. Never a signer's email or the contract's words. | Your own endpoints, and apps |
| [`contract.signed`](https://docs.kaizenaflow.com/reference/webhooks/contract-signed) | Every signer signed a deal's contract: the deal is won. The sealed PDF follows within minutes, on the contract's page. | Your own endpoints, and apps |
| [`contract.declined`](https://docs.kaizenaflow.com/reference/webhooks/contract-declined) | A signer declined a deal's contract. Never the reason they gave: it is on the contract's page. | Your own endpoints, and apps |
| [`form.response`](https://docs.kaizenaflow.com/reference/webhooks/form-response) | A visitor sent one of the store's forms, or confirmed a newsletter sign-up: the form and what they answered, as the response is kept. | Your own endpoints, and apps |
| [`support.waiting`](https://docs.kaizenaflow.com/reference/webhooks/support-waiting) | A customer has waited for a person in the support chat as long as the support settings say: how many wait now, and a link to the inbox. Never who they are or what they wrote. | Your own endpoints, Zapier, Make and Slack, and apps |
| [`deal.created`](https://docs.kaizenaflow.com/reference/webhooks/deal-created) | A deal was made: by hand, from a lead or by the AI manager. Deals moved in from another CRM send none. | Your own endpoints, and apps |
| [`deal.stage_changed`](https://docs.kaizenaflow.com/reference/webhooks/deal-stage-changed) | A deal moved to another stage of its pipeline: by a person, or because its quote or contract was sent. | Your own endpoints, and apps |
| [`deal.won`](https://docs.kaizenaflow.com/reference/webhooks/deal-won) | A deal was marked won: by a person, a paid order, an issued Work invoice or a signed contract. | Your own endpoints, and apps |
| [`deal.lost`](https://docs.kaizenaflow.com/reference/webhooks/deal-lost) | A deal was marked lost. Never the reason typed for it. | Your own endpoints, and apps |
| [`subscriber.subscribed`](https://docs.kaizenaflow.com/reference/webhooks/subscriber-subscribed) | Someone joined the store's email list: confirmed their address, or subscribed signed in. Addresses moved in from another shop send none. | Your own endpoints, and apps |
| [`subscriber.unsubscribed`](https://docs.kaizenaflow.com/reference/webhooks/subscriber-unsubscribed) | A subscriber left the email list: through an email's link, their account, staff, a complaint or a bounce. | Your own endpoints, and apps |
| [`conversation.ended`](https://docs.kaizenaflow.com/reference/webhooks/conversation-ended) | A support conversation ended: by the customer, a person, or when it went quiet. Never what was written. | Your own endpoints, and apps |
| [`conversation.rated`](https://docs.kaizenaflow.com/reference/webhooks/conversation-rated) | A customer rated a support conversation good or bad. Never the comment they wrote. | Your own endpoints, and apps |
| [`review.published`](https://docs.kaizenaflow.com/reference/webhooks/review-published) | A buyer's product review was published on the site: at once, or when the store checked it. | Your own endpoints, and apps |
| [`checkout.abandoned`](https://docs.kaizenaflow.com/reference/webhooks/checkout-abandoned) | A shopper typed their email at checkout and did not pay: sent once a cart, when its first cart reminder is due. | Your own endpoints, and apps |
| [`work_client.created`](https://docs.kaizenaflow.com/reference/webhooks/work-client-created) | A client was added in Work. Never their email or phone. | Your own endpoints |
| [`work_invoice.sent`](https://docs.kaizenaflow.com/reference/webhooks/work-invoice-sent) | A Work invoice was issued: numbered and sent. | Your own endpoints |
| [`work_invoice.paid`](https://docs.kaizenaflow.com/reference/webhooks/work-invoice-paid) | A Work invoice is paid in full. | Your own endpoints |
| [`work_invoice.credited`](https://docs.kaizenaflow.com/reference/webhooks/work-invoice-credited) | A credit note was issued against a Work invoice. | Your own endpoints |
| [`email.bounced`](https://docs.kaizenaflow.com/reference/webhooks/email-bounced) | One of the store's emails to a customer came back: the address may be wrong or full. Which email, to whom, and the reason the mail server gave. | Your own endpoints, and apps |
| [`email.complained`](https://docs.kaizenaflow.com/reference/webhooks/email-complained) | A customer marked one of the store's emails as spam. They have left the email list. | Your own endpoints, and apps |
| [`broadcast.sent`](https://docs.kaizenaflow.com/reference/webhooks/broadcast-sent) | A broadcast finished sending: how many it went to, and how many were sent, skipped or failed. | Your own endpoints, and apps |
| [`marketing.paused`](https://docs.kaizenaflow.com/reference/webhooks/marketing-paused) | Too many recent marketing emails bounced or were marked as spam, so newsletters and automations are held until an owner resumes them. | Your own endpoints, and apps |
| [`activity.created`](https://docs.kaizenaflow.com/reference/webhooks/activity-created) | A call, a meeting or a task was added, by a person or the AI manager, about a customer, a company or a deal. Activities moved in from another CRM send none. Never its note. | Your own endpoints, and apps |
| [`activity.done`](https://docs.kaizenaflow.com/reference/webhooks/activity-done) | A call, a meeting or a task was marked done, or added as done. Marking it not done again sends nothing. | Your own endpoints, and apps |
| [`lead.dismissed`](https://docs.kaizenaflow.com/reference/webhooks/lead-dismissed) | Someone dismissed a lead in the leads inbox: they leave it until they ask for something again. What they asked for, as ids; never their address or words. | Your own endpoints, and apps |
| [`lead.deal_made`](https://docs.kaizenaflow.com/reference/webhooks/lead-deal-made) | Someone made a deal of a lead: the person became a customer if they were not one, and a deal about them opened. What they asked for, as ids; never their address or words. | Your own endpoints, and apps |
| [`domain.failing`](https://docs.kaizenaflow.com/reference/webhooks/domain-failing) | One of the store's connected domains no longer reaches the store, as the daily domain watch found: its certificate fails, or it points elsewhere or at nothing. Sent once, until it works again. | Your own endpoints, and apps |
| [`domain.recovered`](https://docs.kaizenaflow.com/reference/webhooks/domain-recovered) | A connected domain that was failing reaches the store again, as the daily domain watch found. | Your own endpoints, and apps |
| [`app.uninstalled`](https://docs.kaizenaflow.com/reference/webhooks/app-uninstalled) | The app was removed from the store: by an owner, or because the person who installed it left the store or the app was blocked. Its tokens no longer work, and nothing else is sent but store.erase_requested. | Apps |
| [`store.erase_requested`](https://docs.kaizenaflow.com/reference/webhooks/store-erase-requested) | 48 hours after app.uninstalled: erase what the app keeps of the store, its customers and its orders. | Apps |

## The envelope {#envelope}

Every delivery is a `POST` of JSON with the same envelope; its `data` holds what the topic is about, under its own name, as each topic's page shows. The payload's `version` is 1: a change to a payload's shape raises it.

| Field | Type | Description |
|---|---|---|
| `id` | string (uuid) | The delivery's id: the same when a delivery is sent again, so a receiver can do it once. |
| `topic` | string | The topic. |
| `version` | `1` | The payload's version; a change to a shape raises it. |
| `store` | object |   |
| `store.slug` | string |   |
| `store.name` | string |   |
| `created_at` | string (date-time) | When the event happened. |
| `data` | object | What the event is about, under its own name. |

## Headers {#headers}

| Header | What it holds |
|---|---|
| `Kaizena-Webhook-Id` | The delivery's id, as the body's `id`: the same when a delivery is sent again. |
| `Kaizena-Webhook-Timestamp` | When it was signed, in whole seconds since 1970 (UTC). |
| `Kaizena-Webhook-Topic` | The topic, as the body's `topic`. |
| `Kaizena-Webhook-Signature` | `v1=` and the HMAC-SHA256, in lowercase hex, of `{timestamp}.{body}` with the endpoint's secret; several, separated by commas, while a secret is renewed. |

## Check the signature {#signature}

Every delivery is signed with the endpoint's own secret (`whsec_…`, shown once when the endpoint is made). Check it before you trust a delivery:

1. Read the body as it arrived, before parsing it: the signature is over the exact bytes.
2. Take Kaizena-Webhook-Timestamp and refuse the delivery when it is more than 300 seconds from your own clock, so a captured delivery cannot be played again later.
3. Compute the HMAC-SHA256 of the timestamp, a full stop and the body (`{timestamp}.{body}`) with the endpoint's secret, as lowercase hex, and put `v1=` before it.
4. Compare it, in constant time, with each signature in Kaizena-Webhook-Signature (separated by commas or spaces): one match is enough.
5. Answer with any 2xx status within 10 seconds. Do the work once per Kaizena-Webhook-Id: a delivery that is tried again, or sent again by hand, keeps its id.

### JavaScript {#signature-javascript}

For Node.js, with nothing to install:

```javascript
import { createHmac, timingSafeEqual } from "node:crypto";

// Whether a delivery came from Kaizena Flow. `body` is the raw body as it arrived (a string or a Buffer, before any
// JSON parsing), `timestamp` and `signatures` the Kaizena-Webhook-Timestamp and Kaizena-Webhook-Signature headers, `secret` the endpoint's.
export function verifyKaizenaWebhook(body, timestamp, signatures, secret) {
  if (!secret) return false; // never check against an empty key: a missing variable must refuse every delivery
  const stamp = Number(timestamp);
  if (!timestamp || !Number.isInteger(stamp) || Math.abs(Date.now() / 1000 - stamp) > 300) return false;
  const digest = createHmac("sha256", secret).update(`${stamp}.`).update(body).digest("hex");
  const expected = Buffer.from(`v1=${digest}`);
  return String(signatures ?? "")
    .split(/[ ,]+/)
    .some((part) => {
      const given = Buffer.from(part);
      return given.length === expected.length && timingSafeEqual(given, expected);
    });
}

// With Express, keep the body raw for this route:
// app.post("/webhooks/kaizena-flow", express.raw({ type: "application/json" }), (req, res) => {
//   const ok = verifyKaizenaWebhook(req.body, req.get("Kaizena-Webhook-Timestamp"), req.get("Kaizena-Webhook-Signature"), process.env.KAIZENA_WEBHOOK_SECRET);
//   if (!ok) return res.sendStatus(400);
//   const delivery = JSON.parse(req.body); // do the work once per delivery.id (Kaizena-Webhook-Id)
//   res.sendStatus(200);
// });
```

### Python {#signature-python}

For Python 3.10 and later, with the standard library alone:

```python
import hashlib
import hmac
import re
import time


def verify_kaizena_webhook(body: bytes, timestamp: str | None, signatures: str | None, secret: str) -> bool:
    """Whether a delivery came from Kaizena Flow.

    body is the raw body as it arrived (bytes, before any JSON parsing); timestamp and signatures are the
    Kaizena-Webhook-Timestamp and Kaizena-Webhook-Signature headers; secret is the endpoint's.
    """
    if not secret:  # never check against an empty key: a missing variable must refuse every delivery
        return False
    if not timestamp or not re.fullmatch(r"[0-9]+", timestamp):
        return False
    stamp = int(timestamp)
    if abs(time.time() - stamp) > 300:
        return False
    digest = hmac.new(secret.encode(), f"{stamp}.".encode() + body, hashlib.sha256).hexdigest()
    expected = f"v1={digest}".encode()
    # Compared as bytes: a header with other characters is refused, never an error.
    return any(hmac.compare_digest(part.encode(), expected) for part in re.split(r"[ ,]+", signatures or "") if part)


# With Flask:
# ok = verify_kaizena_webhook(request.get_data(), request.headers.get("Kaizena-Webhook-Timestamp"),
#                             request.headers.get("Kaizena-Webhook-Signature"), os.environ["KAIZENA_WEBHOOK_SECRET"])
```

### PHP {#signature-php}

For PHP 8:

```php
<?php

// Whether a delivery came from Kaizena Flow. $body is the raw body as it arrived (before any JSON parsing),
// $timestamp and $signatures the Kaizena-Webhook-Timestamp and Kaizena-Webhook-Signature headers, $secret the endpoint's.
function verify_kaizena_webhook(string $body, ?string $timestamp, ?string $signatures, string $secret): bool
{
    if ($secret === '') {
        return false; // never check against an empty key: a missing variable must refuse every delivery
    }
    if ($timestamp === null || !preg_match('/^[0-9]+$/', $timestamp)) {
        return false;
    }
    $stamp = (int) $timestamp;
    if (abs(time() - $stamp) > 300) {
        return false;
    }
    $expected = 'v1=' . hash_hmac('sha256', $stamp . '.' . $body, $secret);
    foreach (preg_split('/[ ,]+/', $signatures ?? '', -1, PREG_SPLIT_NO_EMPTY) as $part) {
        if (hash_equals($expected, $part)) {
            return true;
        }
    }
    return false;
}

// $ok = verify_kaizena_webhook(
//     file_get_contents('php://input'),
//     $_SERVER['HTTP_KAIZENA_WEBHOOK_TIMESTAMP'] ?? null,
//     $_SERVER['HTTP_KAIZENA_WEBHOOK_SIGNATURE'] ?? null,
//     (string) getenv('KAIZENA_WEBHOOK_SECRET'),
// );
```

### Try your check {#signature-example}

This delivery was signed with the secret `whsec_cmVmZXJlbmNlLW9ubHktbm90LWEtcmVhbC1zZWNyZXQ` at `1793698200` (2026-11-03T09:30:00Z). With your clock at that time (or the time check left out while you try), your check must take it, and refuse it with any character of the body changed.

```http
Kaizena-Webhook-Timestamp: 1793698200
Kaizena-Webhook-Signature: v1=539b4897e72806d127e17931814c9a92a4eedf8623fe3f97031c7d5f3f194568

{"id":"3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f","topic":"customer.erased","version":1,"store":{"slug":"your-store","name":"Example"},"created_at":"2026-11-03T09:30:00Z","data":{"erasure":{"customer_id":"0af2dcd1-60e1-45c6-9774-425ae857a555"}}}
```

## Retries {#retries}

A delivery your endpoint does not answer with a 2xx status within 10 seconds is tried again after 1 minute, then 5 minutes, then 30 minutes, then 2 hours, then 6 hours; after the last it has failed. It keeps its `Kaizena-Webhook-Id`, so do the work once per id.

## Send a test {#test}

What Send a test delivers: `data.test` is true and `data.order` the store's latest paid order, or a sample.

---

https://docs.kaizenaflow.com/reference/webhooks · made from the API contract 1.57
