Key takeaways:
- Amazon PPC automation on the Amazon Ads API is a data pipeline plus a rules engine. It pulls reports and hourly Marketing Stream data, computes bids, budgets, keywords and negatives, and writes the changes back through the Sponsored Products v3 endpoints.
- Most of the engineering goes into data correctness. Attribution settles over several days, reports look back only about 95 days, and the stream can deliver duplicates. Store your own history and upsert on stable keys.
- Bids should come from revenue per click × target ACoS. Smooth low-click data with a prior, cap every change, and wait for a cooldown before the next one.
- Harvesting and negation are statistical decisions. Promote a search term when its conversion evidence is strong, and block it when the chance of seeing zero orders at a normal conversion rate becomes small.
- Every write needs guardrails: one owner per entity, floors and ceilings, a dry-run mode, an audit log and a rollback.
Amazon PPC automation with the Amazon Ads API means software that reads your advertising data, decides what to change, and makes those changes in your account through Amazon's official advertising interface. A good build does four jobs in a loop:
- Ingest reports and near-real-time data.
- Compute bids, budgets, new keywords and negatives against your targets.
- Execute the changes in safe batches.
- Verify what happened.
This guide is the engineering view: endpoints, data model, the maths behind each rule, and the guardrails that stop automation from doing damage. If you want the plain-English overview first, read How to Automate Amazon PPC: Rules, Scripts and AI.
The architecture of an Amazon Ads API automation
Treat the system as six layers. Each one can be tested on its own, and the rules engine never calls Amazon directly. Keeping decisions separate from execution is what makes dry runs, backtests and rollbacks possible.
Read this flowchart as text
- Scheduler hourly and daily jobs
- Ingestion Reports v3, Marketing Stream, SP-API
- Warehouse fact tables by day, hour, target
- Feature layer CVR, RPC, CPC, days of cover
- Rules engine pure functions, no API calls
- Guardrails pass?
- Executor batched v3 writes, retries
- Hold and alert a person reviews
- Audit log and snapshot before and after values
- Monitoring spend, ACoS, error rate
The same loop drives every rule in this guide. Only the feature you compute and the entity you write change.
Authentication, profiles and regional endpoints
The Amazon Ads API uses Login with Amazon (LWA) OAuth 2.0. When an advertiser authorizes your application, you receive a refresh token. You exchange it at the LWA token endpoint for an access token that lasts about an hour. Cache the access token and refresh it shortly before it expires, not on every call.
Every request carries three headers:
| Header | Value |
|---|---|
Authorization |
Bearer <access token> |
Amazon-Advertising-API-ClientId |
your LWA client ID |
Amazon-Advertising-API-Scope |
the profile ID of the account and marketplace |
Call GET /v2/profiles to list profiles. Each profile is one advertiser in one marketplace, so a brand selling in the US, Canada and UK has at least three. Requests go to the regional host for that profile:
- North America:
advertising-api.amazon.com - Europe, which also covers the UK, the Middle East and India:
advertising-api-eu.amazon.com - Far East, which covers Japan and Australia:
advertising-api-fe.amazon.com
Implementation notes:
- Store refresh tokens encrypted, for example with a cloud key management service, and never in source control or logs. A refresh token gives full advertising access to that account.
- Key everything by profile ID. Campaign, ad group, keyword and target IDs are only unique within a profile. Your primary keys should include it.
- Keep marketplace rules per profile. Currency, time zone, minimum bid and budget rules differ by marketplace. The US minimum bid for Sponsored Products, for example, is $0.02.
Ingestion: Reports v3 and Amazon Marketing Stream
You need two kinds of data. Reports give settled, complete metrics by day. Marketing Stream gives hourly traffic and conversion data pushed to you as it happens.
Reports v3 (asynchronous)
Create a report with POST /reporting/reports and the content type application/vnd.createasyncreportrequest.v3+json. Poll GET /reporting/reports/{reportId} until the status is COMPLETED, then download the gzipped JSON from the returned URL. A search-term request looks like this:
{
"name": "sp-search-term-daily",
"startDate": "2026-11-01",
"endDate": "2026-11-26",
"configuration": {
"adProduct": "SPONSORED_PRODUCTS",
"reportTypeId": "spSearchTerm",
"groupBy": ["searchTerm"],
"timeUnit": "DAILY",
"format": "GZIP_JSON",
"columns": ["date", "campaignId", "adGroupId", "keywordId", "matchType",
"searchTerm", "impressions", "clicks", "cost",
"purchases7d", "sales7d", "unitsSoldClicks7d"]
}
}
The report types an automation usually needs:
| Report type | Grain | Used for |
|---|---|---|
spCampaigns |
campaign × day | budget pacing, spend alerts |
spTargeting |
keyword or target × day | bid optimization |
spSearchTerm |
search term × keyword × day | harvesting and negatives |
spAdvertisedProduct |
advertised ASIN × day | ASIN-level ACoS, stock-aware rules |
spPurchasedProduct |
purchased ASIN × day | halo sales, cross-sell analysis |
Four rules keep this data correct:
- Warehouse your own history. Reporting looks back only about 95 days for Sponsored Products. Rules that need longer baselines, such as seasonality or 52-week comparisons, need your own copy.
- Re-pull a restatement window every day. Sales are credited back to the date of the click, and conversions keep arriving for days afterwards. Each night, re-request the last 14 days and upsert on
(profileId, date, campaignId, adGroupId, keywordId or targetId, searchTerm). Never append. - Exclude immature days from decisions. Treat the most recent two to three days as incomplete. A bid rule that reads yesterday's ACoS will always see too few sales and cut bids that are working.
- Use one attribution window consistently. For sellers, Sponsored Products reports use a 7-day window (
sales7d,purchases7d). Do not compare it with 14-day Sponsored Brands figures in the same calculation.
Amazon Marketing Stream (push, hourly)
Marketing Stream delivers hourly datasets to a queue in your own AWS account (Amazon SQS, or Kinesis Data Firehose), with no polling. Subscribe per profile and dataset through the stream subscriptions endpoints. The datasets that matter for PPC automation are:
sp-traffic: impressions, clicks and cost by hour.sp-conversion: attributed conversions by hour.budget-usage: how much of each campaign's budget has been spent, and when.
Engineering notes:
- Delivery is at-least-once. Messages can arrive twice or out of order. Deduplicate on the message's idempotency identifier, and make your upserts idempotent.
- Hourly data is for pacing and dayparting, not for judging bids. Use it to see when spend and sales happen. Make profitability decisions on the settled daily reports.
- Conversions arrive late. Hourly conversion rows keep updating after the hour has passed, so the same restatement logic applies.
The data model and feature layer
Store facts at the finest grain you need and compute features on top. A practical core:
fact_target_day: profile, date, campaign, ad group, keyword or target ID, impressions, clicks, cost, orders, sales, units.fact_search_term_day: the same plussearchTermandmatchType.fact_hour: profile, campaign, hour (in the marketplace's time zone), traffic and conversion from the stream.dim_entity: the current state of every campaign, ad group, keyword, target and product ad, refreshed from the/sp/*/listendpoints, including state, bid and budget.fact_inventory: available units by SKU from the Selling Partner API (see Amazon SP-API Explained for Brand Owners).change_log: every change your system makes, with old value, new value, rule ID, inputs and request ID.
Core features, over a window such as the last 14 or 30 mature days:
- CVR = orders ÷ clicks
- RPC (revenue per click) = sales ÷ clicks
- CPC = cost ÷ clicks
- ACoS = cost ÷ sales
- AOV = sales ÷ orders
- Days of cover = available units ÷ average daily units sold
Smoothing low-volume data
Most keywords have too few clicks for their raw conversion rate to mean anything: 1 order from 3 clicks is not a 33% conversion rate. Shrink each entity toward its parent with a Beta prior:
CVR_smoothed = (orders + k × CVR_parent) ÷ (clicks + k)
Here CVR_parent is the conversion rate of the ad group or advertised ASIN, and k is the prior strength in clicks (often 20–50). With few clicks, the estimate stays close to the parent. As clicks accumulate, the keyword's own data takes over. Apply the same idea to AOV and RPC = CVR_smoothed × AOV_smoothed.
Bid automation: the maths and the decision flow
The bid that meets a target ACoS is the target CPC:
target_CPC = RPC × target_ACoS = CVR × AOV × target_ACoS
Your target ACoS comes from unit economics and the keyword's job. Start from break-even ACoS = profit before ad spend ÷ price. Then set the target below break-even for profit keywords, near break-even for ranking keywords, and separately for brand terms (see Break-Even ACoS on Amazon: How to Calculate It Per ASIN).
Two subtleties:
- Bid is not CPC. Amazon runs a second-price-style auction, so actual CPC usually lands below your bid, and dynamic bidding and placement adjustments raise the effective bid. Track the ratio
CPC ÷ bidper entity and solve for the bid:bid_target = target_CPC ÷ (CPC ÷ bid). - Move gradually. Apply a step cap, for example ±15–20% per cycle. Wait for a cooldown before the next change, typically three to seven days, so the data after a change has matured.
Read this flowchart as text
- Keyword or target last 30 mature days
- Clicks at or above minimum?
- No change keep collecting data
- Changed within cooldown?
- Compute smoothed CVR, AOV and RPC
- target CPC = RPC x target ACoS
- Convert to bid with CPC to bid ratio
- Clamp: step cap, floor, ceiling, marketplace minimum
- Change bigger than noise threshold?
- Write to change set with reason
In code, the rule is a pure function, with no I/O and no API calls:
def propose_bid(e, cfg):
"""e: features for one keyword/target over mature days; returns a change or None."""
if e.clicks < cfg.min_clicks or e.days_since_change < cfg.cooldown_days:
return None
cvr = (e.orders + cfg.k * e.parent_cvr) / (e.clicks + cfg.k)
aov = (e.sales + cfg.k_aov * e.parent_aov) / (e.orders + cfg.k_aov)
target_cpc = cvr * aov * e.target_acos
ratio = max(min(e.cpc / e.bid, 1.0), 0.3) if e.bid and e.cpc else 0.8
raw = target_cpc / ratio
step = max(min(raw, e.bid * (1 + cfg.max_up)), e.bid * (1 - cfg.max_down))
new_bid = round(max(min(step, e.bid_ceiling), e.bid_floor, cfg.marketplace_min_bid), 2)
if abs(new_bid - e.bid) < cfg.noise:
return None
return {"entity": e.id, "field": "bid", "old": e.bid, "new": new_bid,
"rule": "bid.target_acos.v3", "inputs": {"cvr": cvr, "aov": aov, "ratio": ratio}}
Zero-sale entities need their own branch. With no orders, RPC is zero and the formula would push the bid to the floor. Use the probability test in the next section to decide whether the entity has had a fair chance. Until it has, reduce the bid in small steps rather than cutting it in one move. See Amazon Bid Optimization: How Often and How Much to Change Bids for the strategy side.
Search-term harvesting and negative keywords
Harvesting moves proven search terms from discovery campaigns (auto, broad, phrase) into exact-match or product-targeting campaigns, where you control the bid. Negation stops spend on terms that have had a fair chance and did not convert. Both are statistical decisions.
When to negate. If a term converted at a reference rate p, such as the ad group's smoothed CVR, the chance of seeing zero orders in n clicks is (1 − p)^n. When that probability drops below your tolerance, for example 5%, the term is very likely converting below p.
An illustrative example: with p = 10%, 0.9^n < 0.05 once n ≥ 29 clicks. Add a spend floor as well, for example cost ≥ 1.5 × your target cost per order, so cheap terms are not blocked too early.
When to harvest. Promote a term when it has at least two orders, a smoothed ACoS at or below target, and it is not already targeted as exact.
- Keywords: create an exact keyword in the performance campaign, with a starting bid from the term's observed CPC, or the target CPC if that is lower. Then add a negative exact for the term in the source ad group, so your campaigns do not compete for the same query.
- ASINs: when the "search term" is an ASIN (
B0…), create a product target with anasinSameAsexpression instead of a keyword.
Read this flowchart as text
- Search term x ad group last 30 mature days
- Already exact-targeted or negated?
- Skip
- Orders at least 2 and ACoS at or below target?
- Is the term an ASIN?
- Create product target asinSameAs in performance campaign
- Create exact keyword in performance campaign
- Add negative in source ad group
- Zero orders and chance of zero below 5 percent and spend above floor?
- Add negative exact or negative phrase if the root fails
- Change set and log
Details that separate a good build from a noisy one:
- Normalize terms before comparing. Lowercase, trim, collapse spaces and treat close plurals consistently. Amazon matches some variants, so duplicates waste effort and can create conflicting negatives.
- Choose the negative's scope deliberately. Ad-group negatives keep discovery open elsewhere. Campaign-level negatives (
/sp/campaignNegativeKeywords) block a term everywhere in that campaign. Use negative phrase only when a root word is consistently irrelevant, never for a root that also appears in converting terms. - Protect brand and hero terms. Keep an allowlist of terms the system may never negate, such as your brand name and your main category terms.
- N-gram analysis catches what single terms hide. Split terms into 1-, 2- and 3-word fragments, aggregate clicks, orders and cost by fragment, and flag fragments with high spend and no orders as candidates for a person to review.
The manual version of this process is in How to Read the Amazon Search Term Report (and Act on It) and Negative Keywords on Amazon: How and When to Add Them.
Budget pacing, dayparting and inventory-aware rules
Budget pacing
The budget-usage dataset shows when each campaign uses its daily budget. A campaign that runs out at 2 p.m. misses the evening hours, which often convert well. Each hour, project when each campaign will run out from its spend rate. When a profitable campaign is projected to run out early and an unprofitable one has unused budget, move budget between them within a total cap. Budget changes go through PUT /sp/campaigns. Amazon's own budget rules (rule-based and schedule-based budget increases) are also available through the API and are often the simpler choice for events (see Amazon PPC Budgets: Out-of-Budget Campaigns Without Overspending).
Dayparting
From four or more weeks of hourly stream data, compute an hourly index:
index_h = CVR_h ÷ CVR_day
Smooth it across neighboring hours. If the pattern is stable and strong, schedule bid multipliers by hour, for example raising bids where the index is above 1.15 and lowering them where it is below 0.85. Dayparting means hourly writes, so it costs API calls and needs reliable scheduling in the marketplace's time zone. It is worth it only on accounts with enough hourly volume to show a real pattern. See Amazon PPC Dayparting: Does It Work, and When?.
Stock-aware rules
Ads that keep spending while stock runs out speed up the stock-out and can hurt rank afterwards. Join SP-API inventory data to your advertised ASINs and compute days of cover. When cover falls below your replenishment lead time, lower bids on that ASIN's keywords step by step. When it falls below a hard floor, pause its product ads (state: PAUSED), and restore them when stock is back.
Read this flowchart as text
- Hourly: budget usage, traffic, conversions Daily: inventory by SKU
- Days of cover below lead time?
- Below hard floor?
- Pause product ads for the ASIN
- Step bids down on its targets
- Profitable campaign projected to run out before evening?
- Move budget from campaigns with unused, unprofitable budget
- Stable hourly CVR pattern?
- Apply hourly bid multipliers
- No change
- Change set, log and alert
Writing changes safely: the executor
The executor takes a change set (a list of proposed edits) and applies it through the Sponsored Products v3 endpoints, for example PUT /sp/keywords, PUT /sp/targets, PUT /sp/campaigns and POST /sp/negativeKeywords. Each uses its own versioned media type, such as application/vnd.spKeyword.v3+json.
- Batch by entity type and profile, within the documented per-request limits.
- Handle multi-status responses. v3 write calls return per-item success and error arrays, so one request can partly succeed. Record each item's result, retry only failed items that can be retried, and send validation errors to a person.
- Respect rate limits. Throttling returns HTTP 429. Honor the
Retry-Afterheader, and otherwise back off exponentially with jitter. Throttling limits vary by endpoint and load, so do not hard-code a request rate. - Re-read before writing. Fetch the entity's current state just before the write. If someone changed the bid in the console since your rule ran, skip the change and log a conflict rather than overwriting a person's decision.
- Make writes idempotent. Give each change set an ID and record which items were applied, so a crashed job can resume without applying anything twice.
Read this flowchart as text
- Change set from rules
- Guardrails owner, caps, allowlist, budget ceiling
- Dry-run mode?
- Write report only
- Re-read current state
- State matches rule input?
- Skip and log conflict
- Batched v3 write
- HTTP 429 or retryable error?
- Back off with jitter, retry failed items
- Record per-item results and before snapshot
Guardrails, conflicts and testing
Most failures in PPC automation are not bad maths. They are systems that change too much, too often, or fight with something else. Build these in from the start:
- One owner per entity. If a campaign uses "dynamic bids, up and down", Amazon already raises bids in real time (up to 100% for top of search and up to 50% for other placements). Your bid rule and placement adjustments (up to 900%) stack on top. Decide which mechanism owns the bid and tag the entity, so other rules skip it.
- Floors, ceilings and portfolio caps. Set a per-entity bid ceiling, for example a multiple of the target CPC; a daily cap on total budget increases; and a portfolio-level spend ceiling the system can never exceed.
- Change budgets per run. Limit how many entities one run may change, for example 20% of active targets. A bug then cannot touch the whole account at once.
- Event mode. Conversion rates and CPCs shift around Prime Day, Black Friday and other peaks. Switch rules to a loosened or paused profile for the event window and exclude those days from baselines afterwards.
- Kill switch. One flag that stops all writes immediately, checked by the executor before every batch.
Test in four stages before the system writes on its own:
- Unit tests for every rule function with fixed inputs, including the edge cases: zero clicks, zero sales, and an entity at its ceiling.
- Backtest the rules on warehoused history to see how many changes they would have made, in which direction and how large. This checks behavior and volume. It cannot prove a result, because the auction would have reacted to your changes.
- Shadow mode: run on live data in dry-run mode for two to four weeks while a person reviews the proposed changes.
- Canary: apply writes to a small set of campaigns first, compare them with similar campaigns that stayed manual, then widen.
Common mistakes in Ads API automation
- Judging bids on immature data. Using the last one to three days undercounts sales and drives bids down in a loop.
- Appending instead of upserting reports. Restated days get double-counted and ACoS looks better than it is.
- No profile in the primary key. IDs collide across accounts, and changes land on the wrong entity.
- Negating on clicks alone. Ignoring price and conversion rate blocks good, expensive terms early and leaves cheap, bad ones running.
- Harvesting without negating the source. The new exact keyword and the original broad or auto campaign then compete for the same query, and your own CPC rises.
- Overwriting manual edits. Without a re-read before writing, the system silently reverses decisions your team made in the console.
- No log. If you cannot answer "what changed, when, why and by which rule", you cannot debug a drop in sales.
How WeSpark builds Amazon Ads API automation
We build PPC automation on our own Amazon Ads API access, following the architecture above:
- a warehouse with a restatement window;
- rules as tested functions;
- an executor with guardrails, dry runs and a full change log you can read.
We start in shadow mode, agree the thresholds with you, and only then let the system write. Our weekly search-term process, bid method and change control are the same ones the automation follows:
Budget allocation and hourly bidding follow B17 · How we allocate your budget and E8 · Adjusting bids by time of day. If you want the whole job handled, our Amazon PPC management service starts with an audit of your account.
Frequently asked questions
What is the Amazon Ads API?
It is Amazon's official programming interface for advertising. Software can use it to create and manage Sponsored Products, Sponsored Brands and Sponsored Display campaigns, set bids and budgets, and download performance reports. Access requires an approved developer application, and each advertiser must grant permission from their own Amazon Ads login.
What is the difference between the Amazon Ads API and the SP-API?
The Amazon Ads API controls advertising: campaigns, keywords, bids, budgets and ad reports. The Selling Partner API (SP-API) covers the selling side: listings, orders, inventory, pricing and fees. A complete PPC automation usually uses both, for example to lower ad spend when inventory runs low.
How often should automated rules change bids?
Daily runs are common, but each entity should change at most once per cooldown period, typically three to seven days. That gives the new bid time to collect data and for delayed conversions to arrive before the next decision. Hourly changes are reserved for dayparting and budget pacing.
What is Amazon Marketing Stream used for?
Marketing Stream pushes hourly traffic, conversion and budget-usage data to your own AWS queue. It is the right source for intraday decisions such as budget pacing and dayparting. Profitability decisions should still be made on the settled daily reports.
Is it safe to let software change my Amazon ads?
Yes, when the system has guardrails. Those include caps on every change, bid floors and ceilings, an allowlist of protected terms, a dry-run mode, a kill switch and a log of every edit. You can also revoke API access from your Amazon Ads account at any time.
How many clicks does a search term need before it is negated?
It depends on your conversion rate, not a fixed number. If a term should convert at about 10%, there is less than a 5% chance of seeing zero orders after roughly 29 clicks. With a lower expected conversion rate, the term needs more clicks before you can judge it.
