Global Finalist2026 Amazon Ads Partner Awards

Developer API · Prompt library · 04 of 10

Stock-out guard for advertised products

Days of cover for every ASIN you advertise, with a warning before ads keep running on a product that is about to run out.

Key scope
RRead-only key
Build time
30 minutes
Stack
Python script on a daily cron

For: Brands with hero products and FBA lead times.

Paste this into Claude, ChatGPT or Cursor

Read https://www.sellermate.ai/api-docs first. It documents the SellerMate Public API: REST over HTTPS, X-API-Key auth, and every tool with its parameters is on that page. Every tool is POST https://api.sellermate.ai/public/v1/tools/{name} with a JSON body.

Build me a stock-out guard for one Amazon account.

Every morning:
- Get current inventory per ASIN with get_inventory
- Get the last 14 days of units sold per advertised ASIN with get_advertised_product_performance
- Compute days of cover = available units / average daily units
- List every advertised ASIN with less than [14] days of cover, with its ad spend in the last 7 days
- Post the list to Slack, worst first, and say how much ad spend is at risk

Resolve the account with get_user_context. Use the seller's SKU and title in the output, not just the ASIN.

Rules:
- My key is in the SELLERMATE_API_KEY environment variable. Send it as the X-API-Key header. Never hard-code it or log it.
- Call get_user_context first and use the accounts it returns. Don't invent account ids.
- Report tools are paginated (page, page_size up to 500, pagination.hasMore). Walk every page.
- On a 429, wait for the Retry-After header and retry. On a 401 or 403, stop and tell me.
- Show me the plan and the code before running anything that writes.

Stack: Python 3 with requests, Slack webhook in SLACK_WEBHOOK_URL.

Fill in anything in [brackets] before you paste, or leave it and the assistant will ask. The first line sends it to the docs, where every tool is listed.

What you get

  • Days of cover for every advertised ASIN, recalculated daily
  • A ranked list of products that will run out while ads are still spending
  • The ad spend at risk, so the warning has a number on it

Before you paste

  • Read-only key. Inventory needs the Seller Central connection, which starts on Pro.
  • Seasonal products skew the 14-day average; widen the window for those.

Make it yours

Once it works, ask the assistant for one of these.

  • Pause campaigns for products under 3 days of cover with update_campaign, behind an --apply flag.
  • Use get_fired_alerts to include the alerts SellerMate already raised.
Book Demo