Developer API · Prompt library · 06 of 10
Campaign, target and search-term performance landing in a Google Sheet every morning, with no exports.
For: Teams that live in spreadsheets.
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 Google Apps Script that fills a Google Sheet from the SellerMate API every morning at 7am.
Three tabs, one per tool, each cleared and rewritten with yesterday-to-30-days-ago data:
- Campaigns: get_campaign_performance
- Targets: get_targeting_performance
- Search terms: get_search_term_performance
Columns in this order where present: date range, campaign, ad group, target or search term, impressions, clicks, spend (cost), sales (attributedSales14d), orders (purchases), ACoS, ROAS, CPC, CVR. Add a Summary tab with totals from each tool's summary object and a "last updated" timestamp.
Store the key with PropertiesService under SELLERMATE_API_KEY and read the account id from a Config tab. Walk every page using page and page_size 500.
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: Google Apps Script. Include the trigger setup steps.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.
Once it works, ask the assistant for one of these.