To get an Amazon Buy Box lost alert into IFTTT today, poll /amazon-product-offers for each of your ASINs, compare buyBox.sellerId with your own seller ID, and fire your Webhooks Applet's trigger once per confirmed change. The trap this channel sets that no earlier channel in this series does: a successful trigger answers HTTP 200 with a plain-text body, "Congratulations! You've fired the {event} event", never JSON, so calling resp.json() on the happy path raises. The one documented failure, a wrong webhook key, answers 401 with a JSON body - the opposite split from Pushbullet, WeCom and every other sibling, which always return JSON on success. The script below tells a lost Buy Box apart from a suppressed one, retries the one way IFTTT actually fails, and costs one SellerMagnet credit per ASIN per check.
Key Takeaways
- A successful IFTTT Webhooks trigger answers HTTP 200 with a plain-text body, not JSON - the script checks resp.status_code == 200 and the literal "Congratulations" substring, and never calls resp.json() on that path.
- The one documented failure (a wrong or regenerated key) answers 401 WITH a JSON body, {"errors": [{"message": ...}]} - the opposite shape from the success path, and the opposite split from every earlier channel in this series.
- IFTTT documents no Retry-After header or numeric rate-limit code for this endpoint, only "requests may be rate limited" in prose, so 429/500/502/503 all get one fixed 5s backoff-and-retry.
- A 200 without the documented text is treated as NOT sent, so a future response-format change fails safe instead of silently reporting a send that never happened.
- buyBox is the featured offer: its sellerId is the seller who holds the Buy Box, the literal "Amazon" when Amazon does.
- Alert only when two checks in a row agree: an offer page can come back without parsable offers, and one reading should not fire the trigger.
- Each check costs 1 SellerMagnet credit per ASIN; 502/503 retries are billed per attempt, a 500 is refunded, and a free 401/403 stops the run.
Why is a successful IFTTT trigger plain text, not JSON?
Every Webhooks trigger call is POST https://maker.ifttt.com/trigger/<event>/with/key/<key> with a JSON body of value1/value2/value3. A successful call answers HTTP 200 with the plain-text body "Congratulations! You've fired the {event} event" - reproduced the same way by a published community reference implementation and a widely used shell notifier that checks for the literal substring "Congratulations" in the response (checked 2026-11-29; IFTTT's own Webhooks documentation page sits behind a connected account and has no public URL to cite directly). Calling resp.json() on that response raises a ValueError, so the script never does on the success path. The only place this script sees real JSON is the one documented failure, a wrong key, which answers 401 with {"errors": [{"message": "You sent an invalid key."}]} - checked against a third-party Webhooks reference that reproduces IFTTT's own error shape, 2026-11-29.
| Response | Reading | IFTTT trigger |
|---|---|---|
| buyBox.sellerId is your sellerId | mine | BACK, after a confirmed loss |
| buyBox.sellerId is any other seller or "Amazon" | lost | LOST, with holder, price and your offer |
| buyBox is {} and buyBoxSuppressed is true | suppressed | NONE |
| buyBox is {} and offers is [] | no-offers | EMPTY |
How do I build the Amazon Buy Box lost alert for IFTTT?
read_buy_box() turns one offers response into a reading, check() keeps a streak per ASIN in buybox_state.json and queues a line once a new reading has been seen CONFIRM times in a row, and fire_ifttt() fires the trigger once per run with the confirmed lines packed into value1/value2/value3. get_with_retry comes from retry.py and ApiError/new_session from sellermagnet.py, both from the Python quickstart. Malformed ASINs are skipped before any call, because the offers endpoint bills a typo like any other request. MY_SELLER_ID has no default on purpose: without it every ASIN would read as lost, so the script refuses to start. fire_ifttt() checks the plain-text success marker first, falls back to a JSON-parsed message only on the documented 401, and treats every other non-200 as a generic failure worth one retry.
buybox_ifttt_alert.py - offers check, 2-check confirmation, one Webhooks trigger per run
import json
import os
import re
import time
import requests
from retry import get_with_retry
from sellermagnet import ApiError, new_session
MARKETPLACE_ID = "ATVPDKIKX0DER" # amazon.com
MY_SELLER_ID = os.environ["MY_SELLER_ID"] # your sellerId as it appears in offers[]; no default on purpose
ASINS = ["B0CL61F39H", "B0EXAMPLE2", "B0EXAMPLE3"]
CONFIRM = 2 # same reading on 2 checks in a row before IFTTT hears about it
STATE_FILE = "buybox_state.json"
ASIN_RE = re.compile(r"^[A-Z0-9]{10}$") # offers calls are billed even for a typo, so filter first
IFTTT_EVENT = os.environ.get("IFTTT_EVENT", "buybox_lost")
IFTTT_KEY = os.environ["IFTTT_WEBHOOKS_KEY"] # from ifttt.com/maker_webhooks/documentation; treat like a password
IFTTT_URL = f"https://maker.ifttt.com/trigger/{IFTTT_EVENT}/with/key/{IFTTT_KEY}"
MAX_VALUE_CHARS = 1000 # IFTTT does not document a hard cap on value1/2/3; capped
# defensively so one run never sends an unbounded string
MAX_LINES = 50
def read_buy_box(session, asin: str) -> tuple[str, str]:
"""('mine' | 'lost' | 'suppressed' | 'no-offers', detail for the message)."""
data = get_with_retry(session, "amazon-product-offers", asin=asin, marketplaceId=MARKETPLACE_ID)
box = data.get("buyBox") or {}
if not box:
return ("suppressed", "") if data.get("buyBoxSuppressed") else ("no-offers", "")
holder = box.get("sellerId") or "unknown"
if holder == MY_SELLER_ID:
return "mine", ""
currency = (data.get("currency") or {}).get("code", "")
detail = f"held by {box.get('sellerName', 'unknown')} ({holder}, {box.get('fulfillment', '?')}) at {box.get('price')} {currency}"
return "lost", detail
def _load_state() -> dict:
try:
with open(STATE_FILE) as f:
return json.load(f)
except FileNotFoundError:
return {}
def _save_state(state: dict) -> None:
with open(STATE_FILE, "w") as f:
json.dump(state, f)
def check(session, state: dict) -> list[tuple[str, str]]:
"""Advance the streak for every ASIN, return the (asin, line) pairs to fire this run (confirmed changes only)."""
lines = []
for asin in ASINS:
if not ASIN_RE.match(asin):
continue
reading, detail = read_buy_box(session, asin)
entry = state.get(asin)
if entry is None:
state[asin] = {"reading": reading, "streak": CONFIRM, "reported": reading} # seed, no false alert
continue
if entry["reading"] == reading:
entry["streak"] = min(entry["streak"] + 1, CONFIRM)
else:
entry["reading"], entry["streak"] = reading, 1
if entry["streak"] >= CONFIRM and entry["reported"] != reading:
entry["reported"] = reading
if reading == "lost":
lines.append((asin, f"LOST, {detail}"))
elif reading == "mine":
lines.append((asin, "BACK, you hold the Buy Box again"))
return lines
def _clip(text: str) -> str:
return text if len(text) <= MAX_VALUE_CHARS else text[:MAX_VALUE_CHARS - 15] + "...(truncated)"
def fire_ifttt(lines: list[tuple[str, str]]) -> bool:
"""One trigger per run (value1=count, value2=first ASIN, value3=the joined detail lines). Returns True if
IFTTT accepted it. The ONE channel in this series where a successful send is never JSON: the documented
body is plain text ("Congratulations! You've fired the {event} event"), so success is read off
resp.status_code == 200 and that substring, never resp.json(). The one documented failure (a wrong key)
answers 401 WITH a JSON body ({"errors": [...]}) - the opposite split from every sibling channel, which
always returns JSON on success and plain text (if anything) on failure."""
if not lines:
return False
if len(lines) > MAX_LINES:
lines = lines[:MAX_LINES] + [("", f"...and {len(lines) - MAX_LINES} more")]
detail = _clip("; ".join(f"{asin}: {msg}" for asin, msg in lines))
payload = {"value1": str(len(lines)), "value2": lines[0][0], "value3": detail}
resp = requests.post(IFTTT_URL, json=payload, timeout=30)
if resp.status_code == 200 and "Congratulations" in resp.text:
print(f"[ifttt] fired {IFTTT_EVENT}: {detail}")
return True
if resp.status_code == 401:
# the one documented failure mode for this trigger: a wrong/regenerated key. Unlike every success
# response, THIS one IS JSON ({"errors": [{"message": "You sent an invalid key."}]}).
try:
msg = (resp.json().get("errors") or [{}])[0].get("message", "")
except ValueError:
msg = resp.text[:200]
print(f"[ifttt] STOP 401: {msg}")
return False
if resp.status_code in (429, 500, 502, 503):
# IFTTT's own docs say only "Requests may be rate limited" for this trigger, no documented
# Retry-After header or error code (unlike Pushbullet's X-Ratelimit-* or Telegram's retry_after),
# so one fixed backoff-and-retry is as precise as this endpoint gets.
time.sleep(5)
resp = requests.post(IFTTT_URL, json=payload, timeout=30)
if resp.status_code == 200 and "Congratulations" in resp.text:
print(f"[ifttt] fired {IFTTT_EVENT}: {detail}")
return True
print(f"[ifttt] still failing after 1 retry ({resp.status_code}), left unreported")
return False
print(f"[ifttt] {resp.status_code}: {resp.text[:200]}, left unreported")
return False
def main() -> None:
session = new_session()
state = _load_state()
lines = check(session, state)
sent = fire_ifttt(lines)
_save_state(state)
print(f"{len(ASINS)} checked, {1 if sent else 0} alert(s) sent")
if __name__ == "__main__":
main()
Five runs of the script (illustrative ASIN and seller; bracketed line = the trigger fired)
--- run 1 (illustrative ASIN and seller)
3 checked, 0 alert(s) sent
--- run 2, B0EXAMPLE2 lost (1st sighting, not yet confirmed)
3 checked, 0 alert(s) sent
--- run 3, same reading confirmed
[ifttt] fired buybox_lost: B0EXAMPLE2: LOST, held by Example Outlet (A2OTHERSELLER0, FBA) at 18.49 USD
3 checked, 1 alert(s) sent
--- run 4, back to mine (1st sighting, not yet confirmed)
3 checked, 0 alert(s) sent
--- run 5, back to mine, confirmed
[ifttt] fired buybox_lost: B0EXAMPLE2: BACK, you hold the Buy Box again
3 checked, 1 alert(s) sent
What the script actually POSTs (curl equivalent, illustrative values)
curl -s -X POST "https://maker.ifttt.com/trigger/buybox_lost/with/key/dX4mpL3-ifttt-key-xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{"value1": "1", "value2": "B0EXAMPLE2", "value3": "B0EXAMPLE2: LOST, held by Example Outlet (A2OTHERSELLER0, FBA) at 18.49 USD"}'
# HTTP 200, plain text body: Congratulations! You've fired the buybox_lost event <- not JSON, never resp.json()

How do I get the webhook key and read whether it fired?
- Connect the Webhooks serviceOpen ifttt.com/maker_webhooks and connect it to your account; this provisions one webhook key for your whole account.
- Create an AppletIf This: Webhooks, "Receive a web request", event name e.g. buybox_lost. Then That: whatever you want the alert fanned out to (push notification, email, Slack, a Sheets row).
- Copy the keyOpen Documentation on the Webhooks service page to see
https://maker.ifttt.com/use/<key>. The key is the only thing protecting every trigger on your account; treat it like a password and never commit it. - Fire a test request and read the body
curl -d '{\"value1\":\"test\"}' -H \"Content-Type: application/json\" https://maker.ifttt.com/trigger/buybox_lost/with/key/<key>; a real send answers 200 with plain text starting "Congratulations!" - check for that text, not a JSON field.
Environment file and a cron entry for a 15-minute check (flock -n prevents overlapping runs)
# .env (keep it out of git: the webhook key fires every trigger on your IFTTT account)
export SELLERMAGNET_API_KEY="your-key-here"
export IFTTT_WEBHOOKS_KEY="your-ifttt-webhooks-key"
export IFTTT_EVENT="buybox_lost" # must match the event name in your Applet's trigger
export MY_SELLER_ID="A1MYSELLER0001" # your sellerId as it appears in offers[]
# crontab -e: every 15 minutes, 3 ASINs = 288 credits a day; flock -n skips a run while the last one still runs
*/15 * * * * cd /opt/buybox && . ./.env && flock -n .lock .venv/bin/python buybox_ifttt_alert.py >> alert.log 2>&1
The response contract this script relies on - a plain-text success body and a JSON 401 on a bad key - is reproduced consistently across third-party integrations that talk to this endpoint (a published community reference implementation and a shell notifier that checks for the "Congratulations" substring, and a third-party Webhooks reference documenting the 401 JSON error shape; all checked 2026-11-29). IFTTT's own Webhooks documentation page sits behind a connected account and is not a citable public URL, which is why this post relies on reproduced third-party documentation rather than IFTTT's own page directly, and states the response bodies as checked facts rather than assumed ones.
What should you check when a LOST alert fires?
The alert tells you who holds the Buy Box and at what total price, not why Amazon featured that offer. Amazon's US help page Becoming the Featured Offer (Seller Central, checked 2026-10-23) lists what it weighs: the total price including shipping, a fast and specific delivery promise, free shipping, free returns and seller performance, and an out-of-stock offer cannot be featured. Its Featured Offer guide on sell.amazon.com adds that fulfilling orders yourself can be just as effective as FBA. Start with the gap between the holder's price and your offer in the message, then your delivery date and stock. The Buy Box price gap guide shows why the lowest price alone does not decide it.
How many credits does a Buy Box alert cost?
One offers call per ASIN per check, so the SellerMagnet cost is the number of ASINs times the number of checks; IFTTT's Webhooks trigger is free to fire for this volume. With a 2-check confirmation the worst-case delay before IFTTT hears about a loss is about two intervals. Errors add to the SellerMagnet bill in different ways: a 404 is billed once and not retried, a 502 or 503 is billed on every attempt, a 500 is refunded, and the free gate errors (400 for a missing parameter, 401, 403) cost nothing. The Buy Box monitoring interval guide compares intervals in more detail, and Pricing lists the plans.
| Check interval | Credits per day | Credits per 30 days | Worst-case alert delay |
|---|---|---|---|
| Every 15 minutes | 96 | 2,880 | about 30 minutes |
| Every hour | 24 | 720 | about 2 hours |
| Every 4 hours | 6 | 180 | about 8 hours |
| Once a day | 1 | 30 | about 2 days |

Frequently Asked Questions
Do I need to build an IFTTT applet before this script can send anything?
Yes, once: connect the Webhooks service at ifttt.com/maker_webhooks, then create one Applet with Webhooks "Receive a web request" as the trigger (event name, e.g. buybox_lost) and whatever action you want it to fan out to (a push notification, an email, a Slack message, a Google Sheet row). The script only ever fires the trigger; IFTTT runs the action side.
Why does this script never call resp.json() on a successful send?
Because there is nothing to parse. A successful trigger answers HTTP 200 with a plain-text body, documented and reproduced the same way by every third-party integration that calls this endpoint: "Congratulations! You've fired the {event} event" (checked against a community-maintained reference implementation and a published shell notifier that checks for the literal substring "Congratulations", 2026-11-29; IFTTT's own Webhooks documentation page requires a connected account to view and is not citable as a public URL). This script matches that: success is resp.status_code == 200 and the substring in resp.text, never resp.json(). That is the opposite of every earlier channel in this series, which always answers success with a JSON body and reserves plain text, if anything, for a failure.
So when does this script see JSON at all?
Only on the one documented failure: a wrong or regenerated webhook key answers HTTP 401 with a JSON body, {"errors": [{"message": "You sent an invalid key."}]} (checked 2026-11-29 against a third-party Webhooks reference that reproduces IFTTT's own error shape). The script reads errors[0].message from that body and stops without retrying, since resending the same key changes nothing.
What happens on a 429 or a 5xx from maker.ifttt.com?
IFTTT's own action-side documentation says only that "requests may be rate limited", with no documented status code, Retry-After header or JSON error shape for this trigger endpoint, unlike Pushbullet's X-Ratelimit-* headers or Telegram's retry_after field earlier in this series. The script treats 429, 500, 502 and 503 the same way: wait 5 seconds and resend the identical payload once; a second failure in a row is logged and left unreported rather than looped.
Why guard against a 200 that is not the documented text?
A 200 status alone is not proof the trigger fired; the script also checks for the "Congratulations" substring before calling it sent. If IFTTT ever changes this response body, the script fails safe (logs it as unreported) instead of silently claiming success on a response it never actually verified.
What happens when my SellerMagnet credits run out?
The API answers 401 (or 403 during a burst), which is not billed. The script stops instead of calling the remaining ASINs, and the next run tries again once credits are back.
Bottom line: compare buyBox.sellerId with your own seller ID, keep a streak per ASIN, and fire one IFTTT Webhooks trigger per run - read the plain-text success marker, never resp.json(), and only expect real JSON on the documented 401. To see who held the Buy Box and for how long after the fact, use the Buy Box history API; a free account includes 150 credits to try the alert.