Developers · What Sales And Ads do
Developers
Advertising
The signed-in /ads endpoint behind Search Term Cleanup, Send Sales Back and the Weekly Ad Report Email, and what Stattery calls on the ad platforms.
The /ads Endpoint
The Advertising screens in the Stattery app read GET /ads?site=<site> (with part for one sub-tab) and change things with POST /ads and a JSON body { site, op, ... }. Both need a signed-in session. Every POST below needs the Advertising permission on the site.
AI assistants use the MCP tools instead: see AI Assistants.
Search Term Cleanup
GET /ads?site=<site>&part=terms&from=<day>&to=<day> gives the Search Terms sub-tab’s data: queue, applied, dismissed, accounts, missing, waste, from, to, made, running, nextAt, and log for people with the Advertising permission.
| op | body | what it does |
|---|---|---|
strun | { site, op } | Check now: runs the weekly check right away. |
stapply | { site, op, ids } or { site, op, all: true } | Adds each search as an exact-match negative keyword on its campaign. |
stundo | { site, op, ids: [one] } | Removes the negative keyword Stattery added. |
stdismiss | { site, op, ids } | Keeps searches off future queues for their campaign. |
strestore | { site, op, ids } | Puts dismissed searches back. |
What Stattery Calls On The Ad Platforms
- Google Ads API:
search_term_viewand, for Performance Max,campaign_search_term_view(searchStream); the account’s keywords (ad_group_criterion);campaignCriteria:mutateto create and remove a campaign-level negative keyword (negative: true,keyword.matchType: EXACT). - Microsoft Advertising API v13:
SearchQueryPerformanceReportRequest(Reporting, Submit and Poll);EntityNegativeKeywords(POST to add, DELETE to remove,QueryByEntityIdsto find one already there) withEntityType: CampaignandMatchType: Exact.
Send Sales Back
See Send Sales Back for what is sent and when.
GET /ads?site=<site>: each connection inconnsalso hasreconnect(a Google sign-in without Data Manager’s scope; Accounts asks people to reconnect only once Stattery sends sales through Data Manager, which isn’t switched on yet),secondary(Stattery’s conversion doesn’t count toward bidding),dupes(the account’s other purchase conversions:[{ name, kind, primary }],primarytrue when it counts toward bidding),dupesAt,dupesErr, andqueuecounts by status:queued,sending,sent,failed(refused by the platform),expired(the click is more than 90 days old),skipped(no longer a paid sale).POST /ads { site, op: 'convcheck', id }: runs the purchase tracking check (Check Purchase Tracking) for one connection. Read only. Answers with the connections list.POST /ads { site, op: 'pick', id, account }with an account that’s already connected reconnects it (the new sign-in replaces the old one) and answersreconnected: <connection id>.
What Is Sent, Per Platform
- Google, today:
customers/{id}:uploadClickConversionswithorderId. - Google, once sending through Data Manager is switched on:
POST https://datamanager.googleapis.com/v1/events:ingest(scopehttps://www.googleapis.com/auth/datamanager), one destination (operatingAccountGOOGLE_ADS with the ad account,loginAccountthe manager account when there is one,productDestinationIdthe “Stattery sale” action), up to 2,000 events per request:adIdentifiers.gclid(or gbraid, wbraid),conversionValue,currency,eventTimestamp(RFC 3339, UTC),transactionId(the order id),eventSource(WEB for website checkouts, OTHER for the rest). No consent fields. - Microsoft:
CampaignManagement/v13/OfflineConversions/Apply, up to 1,000 per request, ConversionTime in UTC.
No MCP tool reads or changes ad connections or Send Sales Back; turning it on stays a person’s choice in Accounts.
Weekly Ad Report Email
See Weekly Ad Report Email for what the email holds and who gets it.
The Email
- Schedule: Mondays, 7 AM in the site’s time zone (its chat hours’ zone, else the account’s), covering Monday to Sunday of the week before in the account’s stats calendar. A Monday that is missed is skipped, not sent late.
- Sent only when that week had ad spend or paid clicks.
- Each email has
List-UnsubscribeandList-Unsubscribe-Post: List-Unsubscribe=One-Click(RFC 8058) headers. - Extra recipients are double opt-in: a confirmation link (good for 7 days) must be confirmed with the page’s button; opening the link alone changes nothing.
The API
All of these return { adw: { site, max, ready, owner: { email, on, by, at }, rcpts: [{ email, status, by, created, confirmed, unsub, sends, lastSend, expired, resendAt }] } }. status is pending (waiting to confirm), on or off (unsubscribed).
| op | body | what it does |
|---|---|---|
adwowner | { site, op, on } | Turns the owner’s copy on or off. |
adwadd | { site, op, email } | Adds an address and sends its confirmation email. |
adwresend | { site, op, email } | Sends the confirmation email again (an address that hasn’t confirmed yet). |
adwremove | { site, op, email } | Takes an address off the list. |
adwsend | { site, op, week? } | Emails the person signed in a copy of the latest whole week, or of the week starting week (a Monday, YYYY-MM-DD). Also answers sent: { to, from, toDay }. |
GET /ads?site=<site>&part=accounts includes the same adw object for people with the Advertising permission. There is no MCP tool for the weekly report: its figures are the Advertising report’s own, which the existing ad tools already read.