Webhooks
Receive real-time HTTP notifications when events happen in a Cartly store.
Overview
Webhooks allow your application to receive real-time notifications when events occur in a Cartly store. Instead of polling the API, Cartly sends an HTTP POST request to your specified URL with event data.
Each webhook delivery is signed with your subscription's secret (HMAC-SHA256) — see Signature Verification — so you can verify the request is authentic.
Event Types
| Event | Description |
|---|---|
order.created | Fired when a new order is placed |
order.fulfilled | Fired when an order is marked as fulfilled |
order.cancelled | Fired when an order is cancelled |
order.paid | Fired when payment is confirmed |
product.created | Fired when a new product is created |
product.updated | Fired when a product is updated |
product.deleted | Fired when a product is deleted |
products.imported | Fired once when a CSV or Shopify import finishes (an import sends no product.created / product.updated per product): created_count, updated_count (a Shopify import counts its source products), created_ids, updated_ids (up to 1000 each; ids_truncated when there are more: page GET /apps/api/products for the rest), import_job_id, source, started_at, finished_at |
customer.created | Fired when a customer account is created through the Headless Storefront API or the Apps API |
app/uninstalled | Fired when your app is uninstalled; it is the last event the app receives |
Send test in the admin also delivers a webhook.test event to your endpoint. You cannot subscribe to it.
Payload Structure
Every webhook payload has the same envelope: the event type, the time it was sent, and the event-specific data. The event's id travels in the X-Cartly-Event-Id header.
{
"event": "order.created",
"timestamp": "2026-03-19T12:00:00Z",
"data": {
"id": "0b6f7f0e-6a39-4f0c-9d0a-2f6c1d1e9a11",
"order_number": 1042,
"total": 9999,
"currency": "USD",
"status": "pending",
"items": [
{
"product_id": "…",
"variant_id": "…",
"title": "Classic T-Shirt",
"quantity": 2,
"price": 2999
}
],
"customer": {
"email": "customer@example.com"
}
}
}Key details:
- All monetary values are in cents (integer). Divide by 100 for display.
- Timestamps are in ISO 8601 / UTC format.
- IDs use UUID format.
Signature Verification
Every webhook request carries these headers. Always verify the signature before processing the event — verify X-Cartly-Signature-V2, which binds a timestamp and so rejects replays.
X-Cartly-Signature-V2—t=<unix seconds>,v1=<hex>: HMAC-SHA256 oft + "." + raw bodywith your secretX-Cartly-Timestamp— the sametX-Cartly-Hmac-Sha256(aliasX-Cartly-Signature) —sha256=<hex>HMAC of the raw body only. Deprecated: no replay protectionX-Cartly-Event-Id— the event's id, the same on every delivery of that event: dedupe on itX-Cartly-Webhook-Id— the subscription the delivery is forX-Cartly-Shop-Domain— the store address,<slug>.mycartly.pro
The same headers and signatures are sent on the first attempt, on a retry from the failed-delivery queue and on a Send test. The signature headers are present when the subscription has a secret.
import crypto from "crypto";
import express from "express";
// X-Cartly-Signature-V2: "t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + "." + raw body)>"
function verifyWebhook(rawBody, header, secret, toleranceSeconds = 300) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false; // replayed / stale
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const got = Buffer.from(parts.v1 ?? "", "hex");
const want = Buffer.from(expected, "hex");
return got.length === want.length && crypto.timingSafeEqual(got, want);
}
// Verify the RAW body — re-serialised JSON does not match the signed bytes.
app.post("/webhooks/cartly", express.raw({ type: "application/json" }), (req, res) => {
const rawBody = req.body.toString("utf8");
const header = req.headers["x-cartly-signature-v2"] ?? "";
if (!verifyWebhook(rawBody, header, process.env.WEBHOOK_SECRET)) {
return res.status(401).json({ error: "Invalid signature" });
}
// The same event can arrive twice (a retry after a timeout): dedupe on it.
const eventId = req.headers["x-cartly-event-id"];
const { event, data } = JSON.parse(rawBody);
console.log(`Received ${event} (${eventId})`, data);
// Answer within 10 seconds; do slow work asynchronously.
res.status(200).json({ received: true });
});Retry Policy
Cartly sends each event once to each subscribed endpoint and waits up to 10 seconds for a 2xx response. Redirects are not followed: a 3xx response is a failed delivery, so register the final URL. Any other status, a timeout or a refused connection is a failed delivery too. Send test and a retry from the failed-delivery queue wait up to 30 seconds, so a slow endpoint can pass Send test and still time out on live deliveries:
- The failed delivery is kept in the store's dead-letter queue (Admin → Settings → Webhooks), where it can be retried or discarded. A retry carries the original
X-Cartly-Event-Id. - After 5 failed deliveries in a row that span at least an hour, the subscription is automatically disabled — a short outage of your endpoint does not switch it off.
- A successful Send test or dead-letter retry (Admin → Settings → Webhooks) re-enables a disabled subscription. Events that happen while a subscription is disabled are not queued for it.
Respond quickly and process the event asynchronously, and make your handler idempotent on X-Cartly-Event-Id.
Managing Webhooks in the Admin
Merchants manage subscriptions under Settings → Webhooks (/admin/webhooks):
- Status: Active, Failing while deliveries are failing, or Disabled after the auto-disable rule above. A failing or disabled subscription shows its last error.
- Send test sends one signed
webhook.testevent to the endpoint, without retries. If the endpoint answers2xx, the subscription is active again. - Failed deliveries lists what your endpoint did not accept, with Retry, Discard and Retry All. The list is paginated.
When an App Is Uninstalled
When a store uninstalls an app, the app's access tokens are revoked and its webhook subscriptions stop receiving events right away, including REST hooks created by integrations such as Zapier and Make. Their queued failed deliveries are discarded. The one exception is a subscription to app/uninstalled: it still receives that single event and is then removed. The event data identifies the store and the listing (shop_id, listing_id, listing_slug).
Managing Webhooks
Create a Webhook
curl -X POST "https://cartly.pro/apps/api/webhooks" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.com/webhooks/cartly",
"events": ["order.created", "order.fulfilled"],
"secret": "whsec_your_signing_secret"
}'List Webhooks
curl "https://cartly.pro/apps/api/webhooks" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"Delete a Webhook
curl -X DELETE "https://cartly.pro/apps/api/webhooks/{webhook_id}" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"