To get an Amazon Buy Box lost alert sent through Pushsafer today, poll /amazon-product-offers for each of your ASINs, compare buyBox.sellerId with your own seller ID, and call POST /api once per run: https://www.pushsafer.com/api with k (your private key), m (the message, required, max 5,000 characters) and d (device or group, a for all devices) as a form-encoded body, no auth header at all. A successful send answers HTTP 200 OK with {"status": 1, "success": "message transmitted"}, but unlike every other channel in this series, a FAILED send does not come back as a standard 4xx/5xx: Pushsafer writes its own error code straight into the HTTP status line (250, 255, 260, 270, 280), so the script checks status_code == 200 directly rather than trusting raise_for_status(). The script below tells a lost Buy Box apart from a suppressed one, confirms a change on a second check, and costs one SellerMagnet credit per ASIN per check.
Key Takeaways
- Authentication is just the
kprivate key inside the form body, no header, no token and no signature - the key itself is the only credential the endpoint checks. - A FAILED send answers with its error code written into the HTTP STATUS LINE itself (
250invalid key,255invalid key or empty message,260empty message,270invalid device,280not enough API calls) - none of these are standard HTTP numbers, soraise_for_status()never fires on them and a script relying on it would silently miss every failure. - No Pushsafer status is documented as rate-limited or transient, unlike GroupMe's
420earlier in this series: the script never retries a failed send, it just leaves the run unreported for the next scheduled check. - There is no idempotency/de-dup key on the message endpoint at all; only the cron's own
flock -nlock (not Pushsafer) stops an overlapping run from double-posting. - 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; 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 with one send.
How is Pushsafer's error code different from every other channel in this series?
Every other channel so far puts the real outcome in a JSON field riding inside a normal HTTP response: Lark and Viber answer HTTP 200 for success and failure alike and hide the truth in a code/status field, GroupMe answers 201 with no body at all on success. Pushsafer (pushsafer.com/en/pushapi, checked 2026-11-29) does something neither of those does: on a failure, the error's own numeric code becomes the HTTP status line, so the response reads literally as HTTP/1.0 250 invalid key, with the SAME information repeated in the JSON body ({"status": 0, "error": "invalid key"}). A script that only checks resp.raise_for_status() - the normal requests pattern for catching HTTP errors - would see no exception at all, because 250/255/260/270/280 fall outside the 4xx/5xx range that method checks.
| Response | Reading | Pushsafer message |
|---|---|---|
| buyBox.sellerId is your sellerId | mine | BACK, after a confirmed return |
| 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 Pushsafer?
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 post_to_pushsafer() sends every queued line as one POST /api call and reads the HTTP status code directly, never raise_for_status(), to decide what happened. 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. buyBox.totalPrice is rounded to 2 decimal places before it goes into the message, because the field itself is NOT pre-rounded by the API (it can arrive as something like 18.489999999999998). No status is retried: 250/255/260/270 are setup mistakes and 280 is a quota problem, so all five are left for a human to fix rather than retried blind, and the message body is capped at the documented 5,000-character limit.
buybox_pushsafer_alert.py - offers check, 2-check confirmation, one status-checked POST per run
import json
import os
import re
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 Pushsafer 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
PUSHSAFER_API = "https://www.pushsafer.com/api"
PUSHSAFER_PRIVATE_KEY = os.environ["PUSHSAFER_PRIVATE_KEY"] # pushsafer.com/dashboard; the only credential checked
PUSHSAFER_DEVICE = os.environ.get("PUSHSAFER_DEVICE", "a") # "a" = all devices, or a device/group id
MAX_BODY_CHARS = 5000 # pushsafer.com/pushapi_ext: m (message) caps at 5,000 characters,
# though "the push notification will show fewer characters
# depending on the system" - only the client app shows all of it
MAX_LINES = 60 # keeps the batch comfortably under the 5,000-char message limit
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", "")
price = box.get("totalPrice")
price = round(price, 2) if isinstance(price, (int, float)) else price # buyBox.totalPrice is NOT pre-rounded
detail = f"held by {box.get('sellerName', 'unknown')} ({holder}, {box.get('fulfillmentType', '?')}) at {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[str]:
"""Advance the streak for every ASIN, return the lines to push 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(f"{asin}: LOST, {detail}")
elif reading == "mine":
lines.append(f"{asin}: BACK, you hold the Buy Box again")
return lines
def post_to_pushsafer(lines: list[str]) -> bool:
"""One POST per run to /api. pushsafer.com/en/pushapi (checked 2026-11-29) documents a successful send as
plain HTTP 200 OK carrying {"status": 1, "success": "message transmitted", "available": N,
"message_ids": "..."}. Every FAILURE answers with the error encoded TWICE: in the JSON body
({"status": 0, "error": "..."}) AND, unlike any other channel in this series, inside the HTTP status
LINE ITSELF - the documented examples show literal response lines like "HTTP/1.0 250 invalid key" and
"HTTP/1.0 280 not enough API calls". 250/255/260/270/280 are not real HTTP semantics (requests' own
raise_for_status() only fires on 4xx/5xx, so it would stay silent on all of these), so the script checks
resp.status_code == 200 directly rather than anything in the 2xx/4xx/5xx range, and reads the JSON body
only to log which named error it got."""
if not lines:
return False
if len(lines) > MAX_LINES:
lines = lines[:MAX_LINES] + [f"...and {len(lines) - MAX_LINES} more"]
text = "Amazon Buy Box change, confirmed on 2 checks:\n" + "\n".join(lines)
if len(text) > MAX_BODY_CHARS:
text = text[:MAX_BODY_CHARS - 20] + "\n...(truncated)"
payload = {"k": PUSHSAFER_PRIVATE_KEY, "t": "Amazon Buy Box alert", "m": text, "d": PUSHSAFER_DEVICE}
resp = requests.post(PUSHSAFER_API, data=payload, timeout=30)
try:
body = resp.json()
except ValueError:
body = {}
if resp.status_code == 200 and body.get("status") == 1:
# pushapi_ext: "available" is the remaining account-wide API-call allowance, not credits spent on
# this send specifically - logged here only as a sanity read, never used to decide retry/stop.
print(f"[pushsafer] {text}")
return True
# No status in Pushsafer's own docs is named as transient/rate-limited the way GroupMe's 420 is, so
# nothing here is retried blind: a real setup problem (250 invalid key, 255 invalid key or empty
# message) and a quota problem (280 not enough API calls) are both left for a human to fix, and a
# timeout or outage is left for the next scheduled run, exactly like every other stop in this script.
err = body.get("error", "") if isinstance(body, dict) else ""
print(f"[pushsafer] HTTP {resp.status_code}{f' ({err})' if err else ''}, left unreported")
return False
def main() -> None:
session = new_session()
state = _load_state()
lines = check(session, state)
sent = post_to_pushsafer(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; [pushsafer] = the message sent)
--- run 1 (illustrative ASIN and seller)
1 checked, 0 alert(s) sent
--- run 2, B0EXAMPLE2 lost (1st sighting, not yet confirmed)
1 checked, 0 alert(s) sent
--- run 3, same reading confirmed
[pushsafer] Amazon Buy Box change, confirmed on 2 checks:
B0EXAMPLE2: LOST, held by Example Outlet (A2OTHERSELLER0, FBA) at 18.49 USD
1 checked, 1 alert(s) sent
--- run 4, back to mine (1st sighting, not yet confirmed)
1 checked, 0 alert(s) sent
--- run 5, back to mine, confirmed
[pushsafer] Amazon Buy Box change, confirmed on 2 checks:
B0EXAMPLE2: BACK, you hold the Buy Box again
1 checked, 1 alert(s) sent
What the script actually POSTs (curl equivalent, illustrative values)
curl -s -X POST https://www.pushsafer.com/api \\
-d k=Exampl3Priv4teKey20c \\
-d t="Amazon Buy Box alert" \\
-d d=a \\
--data-urlencode m="Amazon Buy Box change, confirmed on 2 checks:
B0EXAMPLE2: LOST, held by Example Outlet (A2OTHERSELLER0, FBA) at 18.49 USD"
# HTTP/1.0 200 OK
# {"status":1,"success":"message transmitted","available":1823,"message_ids":"1324312:118"}

How do I get a Pushsafer private key?
- Create a free Pushsafer accountSign up at pushsafer.com and install the Pushsafer app (iOS/Android/desktop) on the device(s) that should receive the alert.
- Copy your private keyThe Pushsafer dashboard shows a 20-character private key at the top of the page. That is the only credential the message API checks - no header, no OAuth.
- Send a test message
curl -s -X POST https://www.pushsafer.com/api -d k=<private_key> -d m=hello -d d=a; a successful call answersHTTP/1.0 200 OKwith{"status":1,"success":"message transmitted", ...}and the message lands on every registered device. - Pick a device or group id for scoping (optional)The dashboard's Devices tab lists each registered device's numeric id, and lets you create a device group; set
PUSHSAFER_DEVICEto that id instead ofato alert a single device or group rather than every device on the account.
Environment file and a cron entry for a 15-minute check (flock -n prevents overlapping runs)
# .env (keep it out of git: the private key alone is enough for anyone to push to your devices)
export SELLERMAGNET_API_KEY="your-key-here"
export PUSHSAFER_PRIVATE_KEY="Exampl3Priv4teKey20c" # from the Pushsafer dashboard
export MY_SELLER_ID="A1MYSELLER0001" # your sellerId as it appears in offers[]
# export PUSHSAFER_DEVICE="a" # "a" = all devices (default); or a device/group id
# 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_pushsafer_alert.py >> alert.log 2>&1
Pushsafer's own API reference (pushsafer.com/en/pushapi and pushsafer.com/pushapi_ext, checked 2026-11-29) describes the contract the script relies on: /api needs only k and m (t title and d device/group are optional, message capped at 5,000 characters, title at 255), a successful call answers plain HTTP/1.0 200 OK with {"status": 1, "success": "message transmitted", "available": N, "message_ids": "..."}, and a failed call's error CODE rides in the HTTP status line itself (250 invalid key, 255 invalid key or empty message, 260 empty message, 270 invalid device, 280 not enough API calls), repeated in the JSON body's error field. None of those are standard 4xx/5xx numbers and none are documented as transient, so 250 is a real setup problem that must not be retried unchanged, and 280 is a real quota stop, not something a retry fixes.
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; Pushsafer itself is free for this volume (its own quota is on API calls to pushsafer.com, unrelated to SellerMagnet credits). With a 2-check confirmation the worst-case delay before Pushsafer 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
Does Pushsafer answer with a normal HTTP status code?
Only on success. pushsafer.com/en/pushapi (checked 2026-11-29) documents a successful send as plain HTTP/1.0 200 OK with a JSON body ({"status": 1, "success": "message transmitted", "available": N, "message_ids": "..."}), but every FAILURE answers with the error CODE written straight into the status line itself: the docs show literal examples like HTTP/1.0 250 invalid key and HTTP/1.0 280 not enough API calls. 250/255/260/270/280 are not real HTTP semantics, so Python's requests.Response.raise_for_status() (which only fires on the standard 4xx/5xx range) stays completely silent on all of them - a script that relies on it for error handling would treat every one of these as a normal response and never know the send failed.
What do the 250/255/260/270/280 codes mean?
Per pushsafer.com/en/pushapi: 250 is an invalid private key, 255 is an invalid key or an empty message, 260 is an empty message on its own, 270 is an invalid device or device group id, and 280 means the account is out of API calls for the period. Every one of them repeats the same reason in the JSON body's error field, so the script logs that text even though it never changes what happens next (the run is left unreported either way).
Can an alert go to just one phone instead of every device?
Yes. The d parameter takes a for all of the account's registered devices (the script's default), a single numeric device id, several device ids separated by |, or a device group id created in the Pushsafer dashboard. There is no per-call title override beyond the t parameter (max 255 characters) and the message itself (m, required, max 5,000 characters, though "the push notification will show fewer characters depending on the system" per the docs - only the Pushsafer client app itself shows all of it).
Does a failed send get retried, like GroupMe's 420 earlier in this series?
No. Pushsafer's own API reference names no status as rate-limited or otherwise transient the way GroupMe documents 420 ("Enhance Your Calm"). 250/255/260/270 are setup mistakes that retrying the same payload cannot fix, and 280 is a quota problem that retrying only makes worse. The script never retries a Pushsafer send at all: a real failure or a timeout is simply left unreported for the next scheduled run, same as every non-retried stop elsewhere in this series.
Is there an idempotency key, so a retried send can't double-post?
No. Pushsafer's message API takes no client-set de-duplication field at all (unlike, say, a source_guid). Since the script also never retries a send, a double-post can only happen if the SAME run is executed twice (for example an overlapping cron without a lock file) - the flock -n pattern in the cron example below is what actually prevents that, not anything Pushsafer provides.
Bottom line: compare buyBox.sellerId with your own seller ID, keep a streak per ASIN, and send one Pushsafer POST /api call per run - but check status_code == 200 directly, never raise_for_status(), since a failure's error code is the HTTP status line itself. 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.