SKILL.md
Spotify Ads API — Reporting
Pull reporting data from the Spotify Ads API. Read settings from the active platform settings file.
Setup
Set the plugin root and define the request wrapper:
PLUGIN_ROOT="${CODEX_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-.}}"
api() { "$PLUGIN_ROOT/scripts/api-request.sh" report "$@"; }
Before the first Ads API v3 call, read and follow $PLUGIN_ROOT/skills/api-reference/references/live-openapi.md.
To retrieve settings values (TOKEN, ADACCOUNTID, AUTOEXECUTE, BASEURL, SDKHEADER, SKILLHEADER, PLUGIN_VERSION) for use outside API calls, run api --env. The output is eval-safe, so eval $(api --env) assigns them all.
Operations
aggregate (default if no argument)
Get aggregated campaign metrics.
Prompt for:
- entitytype — What to report on:
CAMPAIGN,ADSET,AD, orAD_ACCOUNT - fields — Metrics to include. Parameter name is
fields, NOTreport_fields.
Suggested: IMPRESSIONS, SPEND, CLICKS, REACH, FREQUENCY, COMPLETES Full list: IMPRESSIONS, SPEND, CLICKS, REACH, FREQUENCY, LISTENERS, NEWLISTENERS, STREAMS, COMPLETES, COMPLETIONRATE, STARTS, FIRSTQUARTILES, MIDPOINTS, THIRDQUARTILES, VIDEOVIEWS, CTR, OFFSPOTIFY_IMPRESSIONS
- granularity (HOUR, DAY, LIFETIME — default LIFETIME)
- reportstart / reportend (ISO 8601; required for DAY/HOUR, do not send for LIFETIME)
- entityids + entityids_type (optional — filter to specific IDs)
- includeparententity (optional, boolean — include parent info for AD_SET/AD)
Important: Array query parameters must use repeated parameter names, NOT comma-separated. Validation guardrails:
limitmust be 1-50.entitytypemust be exactlyCAMPAIGN,ADSET,AD, orAD_ACCOUNT.- If
entityidsis present, always includeentityids_type. - If
statusesis present, always includeentitystatustype; it must match the status owner. - Do not use
segments,dimensions,groupBy, or async-reportmetricsnames on aggregate reports. - Do not include
reportstartorreportendwhengranularity=LIFETIME; useDAYfor date-ranged reporting. - For
DAY, use UTC midnight timestamps for both start and end, e.g.2026-05-01T00:00:00Z. - Do not guess conversion metric names. Valid aggregate conversion-style fields include
PAGEVIEWS,LEADS,ADDTOCART,PURCHASES,REVENUE,RETURNONADSPEND,AVERAGEORDERVALUE,STARTCHECKOUT, andSIGNUPS.
api GET "ad_accounts/{ad_account_id}/aggregate_reports?\
entity_type=CAMPAIGN&\
fields=IMPRESSIONS&fields=SPEND&fields=CLICKS&fields=REACH&fields=FREQUENCY&\
granularity=LIFETIME&\
limit=50"
Granularity constraints:
LIFETIME: do not sendreportstartorreportendDAY: date range must be within 90 days and both timestamps must be UTC midnightHOUR: date range must be within the last 2 weeks
Format the response as a readable table with stats broken out per entity. Filter out rows with zero impressions for cleaner output.
totals
Get deduplicated metrics aggregated across multiple campaigns, ad sets, or ads. Reach and frequency are deduplicated across all specified entities.
Prompt for:
- entitytype (required) —
CAMPAIGN,ADSET, orAD(AD_ACCOUNT not supported here; useaggregateinstead) - entity_ids (required) — Up to 50 entity IDs to aggregate across
- granularity (required) —
LIFETIMEorDAY(HOUR not supported for totals) - fields (required) — Metrics:
IMPRESSIONS,CLICKS,CTR,REACH,FREQUENCY - reportstart / reportend (required for DAY, optional for LIFETIME)
api GET "ad_accounts/{ad_account_id}/aggregate_reports/totals?\
entity_type=AD_SET&\
entity_ids=$ID1&entity_ids=$ID2&\
granularity=LIFETIME&\
fields=IMPRESSIONS&fields=REACH&fields=FREQUENCY"
Format the response showing aggregated stats per time period (one row for LIFETIME, one row per day for DAY).
insights
Get audience insight breakdowns.
Prompt for:
- insightdimension —
ACTAND_SET,AGE,AUDIENCE,CITY,COUNTRY,FORMAT,
GENDER, GENRE, INTERESTS, METRO, PLACEMENT, PLATFORM, PODCASTEPISODETOPIC, REGION, or TONE
- fields — Metrics to include. Use repeated
fieldsparams. Insight reports do not allow
ECPCL, FREQUENCY, OFFSPOTIFYIMPRESSIONS, PAIDLISTENS_FREQUENCY, SKIPS, SPEND, STARTS, or UNMUTES.
- entity_ids — One ad set or campaign ID to analyze (only one ID at a time)
- entityidstype — Required when
entityidsis set; useADSETorCAMPAIGN - statuses + entitystatustype (optional; must match the entity type used in
entityidstype)
Insight report guardrails:
- Insight reports support one
entity_idsvalue at a time — either an ad set ID or a campaign ID. - Always send
entityidstypematching the entity:AD_SETfor ad set IDs,CAMPAIGNfor campaign IDs. - Do not send
entitytypeon insight reports;entitytype=ADSETdoes not substitute forentityidstype=ADSET. - Do not send
reportstart,reportend,granularity, orlimit; insight reports are LIFETIME only. - Use only the listed
insightdimensionvalues. Do not useLOCATION,GEO,DMA,STATE,ZIP,POSTAL,POSTALCODE,MARKET,DEVICE,OS,ARTIST,AGERANGE, orCITYNAME. - For geo breakdowns, map user language to valid dimensions: country ->
COUNTRY, region/state ->REGION, metro/DMA ->METRO, city ->CITY.
api GET "ad_accounts/{ad_account_id}/insight_reports?\
insight_dimension=GENDER&\
fields=IMPRESSIONS&fields=CLICKS&fields=CTR&\
entity_ids=$ENTITY_IDS&\
entity_ids_type=AD_SET"
Format results showing the breakdown by the selected dimension.
Handling 422 — Insufficient Data: Insight data becomes available only after an ad has delivered enough activity to meet reporting thresholds. If the API returns HTTP 422 with one of these error codes, the entity does not yet have enough data:
ILLEGAL.INSIGHTREPORT.INSUFFICIENTIMPRESSIONSILLEGAL.INSIGHTREPORT.INSUFFICIENTREACHILLEGAL.INSIGHTREPORT.INSUFFICIENTLISTENERS
When this happens:
- Inform the user that the entity hasn't met the minimum data threshold yet
- Suggest checking back later — poll no more than once per day
- If the ad's flight has ended, stop retrying approximately two weeks after the end date (additional data is unlikely after that point)
async-create
Create an async CSV report for download.
Prompt for:
- name (2-120 chars, only alphanumeric, underscore, hyphen)
- granularity (DAY or LIFETIME)
- dimensions — What to group by:
- ADACCOUNTNAME, CAMPAIGNNAME, CAMPAIGNSTATUS, CAMPAIGNOBJECTIVE - ADSETNAME, ADSETSTATUS, ADSETBUDGET, ADSETCOSTMODEL - AD_NAME
- metrics — What to measure:
- IMPRESSIONSONSPOTIFY, IMPRESSIONSOFFSPOTIFY, SPEND, CLICKS - REACH, FREQUENCY, LISTENERS, NEWLISTENERS, STREAMS - ADCOMPLETES, CTR, CPM, COMPLETION_RATE
- report_start (required if granularity=DAY)
- report_end (optional)
- campaign_ids (optional — filter to specific campaigns)
- statuses (optional, default: [ACTIVE])
- insightdimension (optional) — Break down the report by a delivery insight dimension:
ACTANDSET,AGE,AUDIENCE,CITY,COUNTRY,FORMAT,GENDER,GENRE,INTERESTS,METRO,PLACEMENT,PLATFORM,PODCASTEPISODE_TOPIC,REGION, orTONE. Only supported with LIFETIME granularity.
Async report guardrails:
- Async report
dimensionsare entity metadata columns only. Do not putCITY,COUNTRY,REGION,DMA,POSTALCODE,LOCATION,AGE,GENDER,PLATFORM,DEVICE, orOSindimensions; useinsightdimensionwithgranularity=LIFETIMEfor async CSV delivery insight breakdowns, orinsight_reportsfor direct JSON insight results. - Use request fields
dimensionsandmetrics, notgroupBy,fields,dateRange, orentityType. - If
granularity=DAY, includereport_start; use UTC midnight timestamps for date boundaries.
api POST "ad_accounts/{ad_account_id}/async_reports" \
'{
"name": "...",
"granularity": "DAY",
"dimensions": ["CAMPAIGN_NAME", "AD_SET_NAME"],
"metrics": ["IMPRESSIONS_ON_SPOTIFY", "SPEND", "CLICKS"],
"report_start": "2025-01-01T00:00:00Z",
"report_end": "2025-01-31T00:00:00Z"
}'
After creating, show the report ID and suggest checking status with async-status.
async-status <report_id>
Check the status of an async report and get the download URL when ready.
api GET "ad_accounts/{ad_account_id}/async_reports/$REPORT_ID"
If complete, display the download URL. If still processing, report the status and suggest checking again later. If the status is FAILED, inform the user that report generation failed and suggest retrying by creating a new async report with async-create.
Execution Behavior
- If
auto_executeistrue, execute directly. - If
auto_executeisfalse, present the curl command and ask for confirmation. - Always format report data in readable tables when possible.
- For large result sets, summarize key metrics and offer to show full data.