View Categories

Webhooks & automation

11 min read

Send cart events to Zapier, Make, n8n and OttoKit.

Every feature in CartWin is free. There is no paid version and nothing is locked.

What it does. Calls an external address the moment something happens in the store, so automations elsewhere can react.

Why it matters. Add the customer to a mailing list when a cart is abandoned, ping a chat channel when a cart is recovered, or keep a spreadsheet in sync — without touching code.

Details

The three events

Event Setting Fires when
abandoned Cart abandoned The engine marks a cart as abandoned — it has been quiet for Abandoned after minutes. Fires whether or not follow-up sending is switched on. Not fired for unsubscribed customers.
sent Message sent A follow-up has been handed over: email, SMS or WhatsApp, scheduled or sent with Send now. Not fired for the out-of-stock notice, for the weekly summary or for the “cart recovered” mail to the store.
recovered Cart recovered An order of the customer closes a cart that counts as recovered (see “How the numbers are counted” in 4.10). A cart closed by an order without a reminder before does not fire it.

Each event has its own URL under Settings → Webhooks. Leave one empty and that event is not sent.

How each request looks

  • POST to the URL, the body as JSON, header Content-Type: application/json.
  • Three more headers:
  • X-CartWin-Event — abandoned, sent or recovered.
  • X-CartWin-Delivery — a new unique id (UUID) for every request, to tell deliveries apart.
  • X-CartWin-Signature — sha256= followed by the HMAC-SHA256 of the request body, computed with the Signing secret from the settings. Leave the secret empty and CartWin uses a secret derived from the site instead. Enter a secret of your own so that you know it on the receiving side.
  • The body:

json
{
"event": "abandoned",
"time": "2026-11-27 14:03:00",
"site": "https://www.yoursite.com/",
"cart": {
"id": 1287,
"status": "abandoned",
"email": "[email protected]",
"phone": "+15550100222",
"first_name": "Anna",
"last_name": "Brown",
"user_id": 0,
"total": 84.5,
"currency": "USD",
"items": [
{ "product_id": 61, "variation_id": 0, "name": "Blue T-shirt", "quantity": 2 }
],
"captured_at": "2026-11-27 13:41:10",
"abandoned_at": "2026-11-27 13:56:10",
"recovered": false,
"recovered_order_id": 0,
"recovered_total": 0,
"checkout_url": "https://www.yoursite.com/?cartwin_restore=…"
},
"message": null
}

  • time, captured_at and abandoned_at are in UTC, not in the store’s time zone.
  • message is filled in for sent only: { "id": 4412, "channel": "email", "template_id": 3, "title": "Did you forget something?", "coupon_code": "CARTWIN-8F2K" }. channel is email, sms or whatsapp.
  • Items carry product_id, variation_id, name and quantity — no prices.
  • The secret cart token is not included, but checkout_url is the customer’s restore link: anyone who has it can put that cart back together. Enter webhook addresses of services you trust only.

Checking the signature on the receiving side

Compute the HMAC-SHA256 of the raw request body with the signing secret and compare it with the part after sha256= in the X-CartWin-Signature header. In PHP:

$given  = $_SERVER['HTTP_X_CARTWIN_SIGNATURE'] ?? '';
$expect = 'sha256=' . hash_hmac( 'sha256', file_get_contents( 'php://input' ), $secret );
if ( ! hash_equals( $expect, $given ) ) {
    http_response_code( 401 );
    exit;
}

What CartWin does with the answer

  • One attempt only. There is no retry and no queue: an automation misses the event when its address cannot be reached at that moment.
  • Time-out 8 seconds; redirects are not followed.
  • Only a failed connection counts as a failure — time-out, DNS error, connection refused, an unusable address. It is written to the activity log as “Webhook delivery failed: …”. The engine goes on regardless.
  • An error answer is not noticed. When the receiving server answers with HTTP 4xx or 5xx, CartWin still treats the delivery as done: nothing is logged, and the message or the cart is unaffected. When a webhook does not arrive, look in the history of the automation tool (Zapier, Make, n8n …) first.
  • Any http or https address is accepted, also one inside your own network. CartWin does not block private addresses.

Automation tools

  • Zapier, Make, n8n and OttoKit can all receive these requests: start the automation with a “Webhook” or “HTTP request” trigger (method POST). Then map the fields from the JSON body, for example cart.email, cart.phone, cart.total, cart.checkout_url, cart.items[0].name.
  • Typical uses: add the contact to a mailing list (abandoned), post to a chat channel (recovered), create a lead in a CRM (abandoned), write a row into a spreadsheet (recovered).

Where to find it. Settings → Webhooks. Details for developers: chapter 15.

Setting What it does Default Values / range
Cart abandoned URL called when a cart becomes abandoned. (empty) http(s) URL
Message sent URL called when a follow-up was sent. (empty) http(s) URL
Cart recovered URL called when a cart is recovered. (empty) http(s) URL
Signing secret “Each request is signed with this secret in the X-CartWin-Signature header. Leave empty to use a secret generated from your site.” (empty) Text
  1. In your automation tool, create an automation that starts with a webhook trigger and copy the URL it gives you.
    – Zapier: trigger Webhooks by Zapier → Catch Hook
    – Make: module Webhooks → Custom webhook
    – n8n: node Webhook
    – OttoKit: trigger Webhook
  2. Under CartWin → Settings → Webhooks, paste the URL next to the event you want: Cart abandoned, Message sent or Cart recovered. Save.
  3. Abandon a test cart (or click Run the engine now under Tools once one is abandoned) and look at the data that arrives.

What arrives — a JSON POST with these headers:

Header Value
Content-Type application/json
X-CartWin-Event abandoned, sent or recovered
X-CartWin-Delivery A unique id for this delivery
X-CartWin-Signature sha256= followed by the HMAC-SHA256 of the body

Example payload (cart recovered):

{
  "event": "recovered",
  "time": "2026-11-27 10:15:04",
  "site": "https://your-store.com/",
  "cart": {
    "id": 128,
    "status": "completed",
    "email": "[email protected]",
    "phone": "",
    "first_name": "Alex",
    "last_name": "Sample",
    "user_id": 0,
    "total": 89.5,
    "currency": "USD",
    "items": [
      { "product_id": 51, "variation_id": 0, "name": "Blue T-shirt", "quantity": 2 }
    ],
    "captured_at": "2026-11-26 09:12:40",
    "abandoned_at": "2026-11-26 09:27:40",
    "recovered": true,
    "recovered_order_id": 2401,
    "recovered_total": 89.5,
    "checkout_url": "https://your-store.com/?cartwin_restore=…"
  },
  "message": null
}

Verifying the signature (when a secret is set). The signature is sha256= + HMAC-SHA256 of the raw request body, using the signing secret:

const crypto = require('crypto');

function verify(rawBody, signatureHeader, secret) {
  const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
  const given = String(signatureHeader || '');
  return given.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected));
}

Leave Signing secret empty and the signature is made with a secret derived from your site — still consistent, but only known to this site.

Good to know

  • The Cart abandoned event also fires while Send follow-ups is switched off. Leave its URL empty until you want the automation to run for real.
  • The Message sent event fires for every channel — email, SMS and WhatsApp — and also for a message sent with Send now. The out-of-stock notice does not fire it.
  • The Cart recovered event fires only for carts that count as recovered, that is, when a reminder or the restore link came before the order.
  • Each request is tried once, with an 8-second time-out. Make the receiving side answer quickly — store the data first, work later.
  • CartWin only logs a failed connection. An error answer from the receiving side (HTTP 4xx or 5xx) is not noticed by CartWin: when an automation did not run, look in the history of the automation tool first.
  • The times in the payload are in UTC. Convert them to your time zone in the automation.
  • The payload holds the customer’s email address, phone number and restore link. Only enter addresses of services you trust, and do not paste a payload into a ticket or a public chat.

Setup and payload: 10.5. Settings: 6.7. All details: 4.12.

  1. Create the automation in your tool (Zapier, Make, n8n, OttoKit …) with a webhook trigger and copy its address.
  2. CartWin → Settings → Webhooks. Paste the address next to Cart abandoned, Message sent or Cart recovered. Enter a Signing secret when your tool can check signatures. Save.
  3. Test it: abandon a cart and click Tools → Run the engine now. The tool’s history should show the request.

When nothing arrives, check in this order: the tool’s history (an error answer from the tool is not shown in CartWin), the activity log for “Webhook delivery failed”, and the URL. CartWin tries each request only once.

What is a webhook?
A call from one program to another at a given address, made the moment something happens. CartWin calls an address you choose when a cart is abandoned, a message is sent or a cart is recovered.

What can I do with it?
Anything an automation tool can do with that information: add the customer to a mailing list, create or update a lead in a CRM, post a note in a chat, write a row in a spreadsheet, start a follow-up sequence in another tool.

Which tools can receive the calls?
Any service that can take an HTTP POST with JSON. Zapier, Make, n8n and OttoKit are common choices; each has a “Webhook” trigger for it.

How do I set one up?
Create the automation in the tool, copy the address of its webhook trigger, paste it under Settings → Webhooks next to the event, and save (10.5).

Which events are there?
Three, each with its own address:
– Cart abandoned — the engine marks a cart as abandoned.
– Message sent — a follow-up was handed over, on any channel.
– Cart recovered — an order closed a cart that counts as recovered.

Does “Cart abandoned” also fire while sending is switched off?
Yes. The event belongs to the tracking, not to the sending. Leave its address empty until you want the automation to run for real.

Is a failed call tried again?
No. Each event is tried once, with a time-out of 8 seconds. An automation that is offline at that moment misses the event.

My webhook does not arrive. Why?
Check in this order:
– The history of the automation tool: it shows whether the call arrived and whether the tool answered with an error. CartWin does not notice an error answer.
– Tools → Activity log, search for “webhook”: “Webhook delivery failed: …” means the address could not be reached at all.
– The address: it must be a complete https:// address, saved under the right event.

How do I check that a call really comes from my store?
Enter a Signing secret and check the X-CartWin-Signature header on the receiving side: sha256= followed by the HMAC-SHA256 of the request body, computed with that secret (code in 4.12).

What data is in a call?
The event, the time (UTC), the site address, and the cart: email address, phone number, name, value, currency, items, times, recovery details and the customer’s restore link — plus the message for Message sent. No prices per item, no password, no API key. Because it holds contact details and a working restore link, only enter addresses of services you trust.

Can several tools get the same event?
Not directly: one address per event. Let the first tool pass the event on, or have a developer add a second call (chapter 15).

Do the calls slow down the sending?
Each call waits up to 8 seconds for an answer. A slow receiving side can make an engine run take longer; keep the endpoint quick.

Endpoint Method What
/?wc-ajax=cartwin_capture POST The checkout script sends cartwin_fields (JSON): email, phone, first_name, last_name, consent, phone_consent, billing{…}, shipping{…}. Replies { "ok": true, "data": { "tracked": true } }, or { "ok": false, "code": "…" } (HTTP 403 for a refused origin or rate limit)
/?cartwin_restore=<token> GET Restores the cart, redirects to the checkout
/?wcf_ac_token=… GET Restore links of CartFlows, for imported carts
/?cartwin_unsubscribe=<token>[&m=<message token>] GET, POST Unsubscribes. GET shows the confirmation page; POST answers OK (one-click unsubscribe)
/?cartwin_open=<token> GET The 1×1 tracking pixel; answers image/gif
/?cartwin_click=<token>&r=<target>&h=<signature> GET Records the click, redirects to the (signed) target
/?cartwin_sms_event=1 POST Twilio’s “A MESSAGE COMES IN” webhook; STOP replies (see below)
admin-ajax.php?action=cartwin_preview POST Admin: renders a saved email template (nonce cartwin_ajax)
admin-ajax.php?action=cartwin_product_search POST Admin: product search for the rule editor (nonce cartwin_ajax)

The plugin registers no REST route of its own, and no shortcode and no block.

The SMS reply endpoint in detail

  • Accepted only as POST, only while Provider is Twilio and an Auth Token is entered. Everything else is answered with 403 Forbidden (text/plain).
  • The request must carry X-Twilio-Signature: base64 of HMAC-SHA1 over the full URL (without the query string; a variant with it is accepted too) followed by every posted parameter as name + value, sorted by name, keyed with the Auth Token. A wrong signature is logged as a warning and answered with 403.
  • A Body that consists of STOP, UNSUBSCRIBE, CANCEL, END or QUIT (after upper-casing and removing everything but A–Z) calls CartWin_Data::unsubscribe_phone() for the normalised From number. Any other body is logged at debug level.
  • The answer is 200 with Content-Type: text/xml and an empty <Response/>, so Twilio sends nothing back to the customer.

Calls the plugin makes

To Method Purpose
https://api.twilio.com/2010-04-01/Accounts/{Account SID}/Messages.json POST, form-encoded, Basic auth (SID : token) SMS through Twilio: From, To, Body
The Gateway URL from the settings POST, JSON SMS through another gateway
https://graph.facebook.com/{API version}/{Phone number ID}/messages POST, JSON, Authorization: Bearer <token> WhatsApp messages
The three Webhook URLs POST, JSON, signed Automation events (4.12)

All calls use wp_remote_post() and therefore pass through WordPress’s pre_http_request and http_request_args filters — the place to redirect or block them on a staging site. Time-outs: 20 seconds for SMS and WhatsApp, 8 seconds for webhooks.


Was this helpful?

Still stuck? Write to [email protected] with a screenshot and a description.

Download CartWin — it’s free

← Previous: SMS & WhatsApp setup   |   Next: AI client access →