Skip to content

Sync back-in-stock signups to a CRM or Klaviyo

Worked recipe: get every back-in-stock signup into Klaviyo, Omnisend, Mailchimp or any other CRM, with STOQ's built-in sync, a daily API pull, or storefront events. Every call, response and error code.

Last updated

For: agencies who run a client’s email and SMS and want STOQ’s waitlist in the client’s CRM, so they can segment on “waiting for a restock”.

Goal: every new back-in-stock signup lands in the CRM with the product it’s for. Pick one of three ways:

Way Use it when Delay
A. STOQ’s built-in sync The CRM is Klaviyo, Omnisend, Mailchimp or Shopify customers Seconds
B. A daily API pull Any other CRM, a data warehouse, or you need the full history Up to a day
C. Storefront events You already push storefront events to the CRM from the theme Instant, but only signups made on the storefront
  • Credentials: the store’s API key (X-Auth-Token), or an MCP client signed in to the store. Third-party API keys (Omnisend, Mailchimp, Postscript) are never accepted over MCP: the merchant enters them in STOQ.
  • Plan: syncing signups to Klaviyo, Omnisend, Mailchimp or Shopify customers is a paid feature. On the free plan, turning it on fails with plan_required. The API pull (way B) works on every plan.
  • Consent: sync only what the shopper agreed to. Each signup has accepts_marketing; a back-in-stock signup alone is not consent to marketing email.
curl "https://app.stoqapp.com/api/v2/external/account/integrations/klaviyo" \
-H "X-Auth-Token: $STOQ_API_KEY"
{ "tool": "execute_read", "arguments": { "method": "GET", "path": "/account/integrations/klaviyo" } }
{ "id": "klaviyo", "name": "Klaviyo", "category": "marketing", "status": "not_connected",
"reason": { "code": "…", "message": "…" },
"connection": { "method": "oauth", "connected": false, "legacy": false, "key_hint": null },
"plan": { "required": "paid", "available": true },
"settings": { "sync_customers": false, "…": "…" },
"links": { "dashboard_url": "https://admin.shopify.com/store/…", "help_url": "https://help.stoqapp.com/…" },
"…": "…" }

status is not_connected, off, setup_incomplete, needs_attention or connected; every status but connected has a reason. plan.available: false means the store’s plan doesn’t include it. The other ids are omnisend, mailchimp and shopify_customers.

Run this only when A1 shows connection.connected: false (status is not_connected). If A1 already shows connected, skip to A3.

curl -X POST "https://app.stoqapp.com/api/v2/external/account/integrations/klaviyo/connect" \
-H "X-Auth-Token: $STOQ_API_KEY" -H "Idempotency-Key: $(uuidgen)"
{ "tool": "execute_write", "arguments": { "method": "POST", "path": "/account/integrations/klaviyo/connect", "idempotency_key": "<new uuid>" } }

Klaviyo connects with OAuth, so STOQ never connects it by itself. The answer is 201 with connect_url, expires_at, single_use: true, instructions to relay, and the integration as step A1 reads it (with connect.pending: true). Show the link to the merchant: it opens the Klaviyo panel in the STOQ dashboard, where they press Connect and approve in Klaviyo. Don’t open or fetch it yourself. A link works once, for 15 minutes.

Then stop. Tell the merchant Klaviyo is not connected yet and nothing syncs until they approve. Don’t go on to A3: leave sync_customers as it is until A1 reads status: "connected".

For Omnisend or Mailchimp over REST, send the key in the body ({ "api_key": "…" }, plus list_id for Mailchimp). Over MCP, connect returns key_url instead: show it to the merchant, who pastes the key in STOQ.

A3. Turn on the sync (only once A1 reads connected)

Section titled “A3. Turn on the sync (only once A1 reads connected)”

Read A1 again first. If connection.connected is not true, don’t send this PATCH: go back to A2 and give the merchant the link.

curl -X PATCH "https://app.stoqapp.com/api/v2/external/account/integrations" \
-H "X-Auth-Token: $STOQ_API_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{ "klaviyo": { "sync_customers": true }, "sync_customers_tag": "restock-waitlist" }'
{ "tool": "execute_write", "arguments": { "method": "PATCH", "path": "/account/integrations", "params": { "klaviyo": { "sync_customers": true }, "sync_customers_tag": "restock-waitlist" }, "idempotency_key": "<new uuid>" } }

sync_customers_tag is the tag STOQ puts on the profiles it syncs, so the client can build a segment on it. The same PATCH takes omnisend.sync_customers, mailchimp.sync_customers and shopify.sync_customers. It is a deep partial: absent fields stay as they are.

To also send back-in-stock alerts through Klaviyo flows (not only sync profiles), follow the steps GET /account/integrations/klaviyo lists under steps; each names the action that runs it. See Account → Integrations.

The waitlist list returns one status at a time: pending (the default, signups not yet notified) or notified. from and to are days in the shop’s time zone, matched against the signup date for pending and the notified date for notified. Run both for the day before and upsert each signup by its id; together they catch every signup, and the second run updates signups that were notified.

DAY=$(date -v-1d +%F) # GNU date: date -d yesterday +%F
for status in pending notified; do
page=1
while :; do
body=$(curl -s "https://app.stoqapp.com/api/v2/external/back_in_stock/signups?status=$status&from=$DAY&to=$DAY&per_page=100&page=$page" \
-H "X-Auth-Token: $STOQ_API_KEY")
echo "$body" | jq -c '.signups[]' >> "signups-$DAY.jsonl"
[ "$(echo "$body" | jq '.meta.page >= .meta.total_pages')" = "true" ] && break
page=$((page + 1))
done
done
{ "tool": "execute_read", "arguments": { "method": "GET", "path": "/back_in_stock/signups", "params": { "status": "pending", "from": "2026-10-30", "to": "2026-10-30", "per_page": 100 } } }

Each signup:

{
"id": "4b6f…",
"channel": "email",
"source": "restock-rocket-extension",
"contact": "jane@example.com",
"quantity": 1,
"shopify_product_id": "gid://shopify/Product/456",
"shopify_variant_id": "gid://shopify/ProductVariant/123",
"product_title": "Classic Tee",
"variant_title": "Small / Blue",
"sku": "TEE-S-BLU",
"shopify_market_id": null,
"customer_id": "9a1e…",
"customer_name": "Jane",
"accepts_marketing": true,
"unsubscribed_at": null,
"notified_at": null,
"created_at": "2026-10-30T14:12:00Z",
"…": "…"
}

A signup is one contact on one channel for one variant, so a shopper who gave an email and a phone number has two. per_page is at most 100. Map contact by channel (email or phone), product_title and variant_title to CRM properties, and skip rows with unsubscribed_at set. To backfill the full history, run the loop once with no from/to.

On a theme with STOQ’s app embed, and on headless stores with the Storefront SDK, a signup fires stoq:restock-modal:submitted on window:

window.addEventListener('stoq:restock-modal:submitted', (event) => {
const { product, variant, customer } = event.detail
// Send to your CRM's browser SDK, e.g. a "Joined waitlist" event:
window.myCrm?.track('Joined waitlist', {
email: customer.email,
phone: customer.phone,
product: product.title,
variant: variant.title,
variant_id: variant.id,
})
})

This only sees signups made in that browser, not ones added in the dashboard or by the API, and ad blockers can drop it. Use it next to way A or B, not instead of them. See Custom events.

Code What happened What to do
plan_required The integration or the sync needs a paid plan; nothing was saved Ask the merchant to upgrade, or use way B
use_key_link An API key was sent over MCP Show key_url to the merchant. Don’t ask for the key
key_rejected The provider refused the key; nothing was saved The merchant checks the key in the provider and sends it again
already_connected The integration is already connected Skip connect, or send reconnect: true to replace it
not_applicable A switch integration (such as shopify_customers) has nothing to connect Turn it on with PATCH /account/integrations instead
rate_limited Too many calls this minute, or more than 5 connect links for one integration this hour Wait retry_after seconds
invalid_params A filter failed the schema, such as status=blocked or a date that isn’t YYYY-MM-DD Use pending or notified, and ISO dates
unknown_integration The integration id isn’t one STOQ supports Use an id the message lists, or one from GET /account/integrations
  1. Way A: GET /account/integrations/klaviyo shows status: "connected" and settings.sync_customers: true. Then sign up on the storefront with a test email: the profile appears in Klaviyo within a minute, with the tag.
  2. Way B: the day’s file has meta.total_count rows from each status. Compare one day’s pending count with GET /back_in_stock/reports/signups for the same day.
  3. Way C: sign up on the storefront with the browser console open: the listener runs once, and the CRM shows the event.
Was this page helpful?

Still stuck? Ask Quinn or chat with support