ads_create_workflow_execution

Run an AMC SQL query over the store's AMC data (an ad-hoc execution).

readAmazon Adsads.amc-reporting

Answers at once with an execution id; poll ads_get_workflow_execution, then read the rows with ads_get_workflow_execution_download_urls. Check a new query with dry_run first: AMC validates it in seconds without running it. Amazon Ads API · createWorkflowExecution · POST /amc/reporting/{instanceId}/workflowExecutions Docs: https://advertising.amazon.com/API/docs/en-us/amc-reporting#tag/Workflow-executions/operation/createWorkflowExecution

Call it

In an AI client (MCP)

tools/call
{
  "name": "ads_create_workflow_execution",
  "arguments": {
    "store": "myStore-US",
    "country_code": "<country_code>",
    "sql_query": "<sql_query>"
  }
}

From code (Tool API)

curl -X POST https://api.sellersheetai.com/api/v1/tools/ads_create_workflow_execution \
  -H "Authorization: Bearer $SELLERSHEET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"store":"myStore-US","country_code":"<country_code>","sql_query":"<sql_query>"}'
Early access — the Tool API is open on request, contact us.

Arguments

NameTypeDescription
storerequiredstringthe store ref `<store>-<CC>` (name-country, e.g. 'myStore-US') — one of get_user_context's store_refs, verbatim.
country_coderequiredstringthe Ads profile's 2-letter country code (e.g. 'US').
sql_queryrequiredstringAMC SQL; line breaks are joined into one line for Amazon. The final SELECT must aggregate (GROUP BY dimensions, SUM / COUNT(DISTINCT user_id)).
time_window_typestringwhich days of data the query reads; EXPLICIT needs time_window_start and time_window_end. Amazon's default is MOST_RECENT_DAY. Allowed: ALL | CURRENT_MONTH | EXPLICIT | MOST_RECENT_DAY | MOST_RECENT_WEEK | PREVIOUS_MONTH.ALLCURRENT_MONTHEXPLICITMOST_RECENT_DAYMOST_RECENT_WEEKPREVIOUS_MONTH
time_window_startstringEXPLICIT only — 'YYYY-MM-DDTHH:MM:SS'.
time_window_endstringEXPLICIT only — 'YYYY-MM-DDTHH:MM:SS', exclusive.
time_window_time_zonestringthe window's IANA zone, e.g. 'Asia/Dubai' (the marketplace's own day); default UTC.
parameter_valuesobjectvalues for parameters the SQL declares.
dry_runbooleantrue to validate the SQL and the time window only — nothing is computed, no Amazon quota is used; the run then ends SUCCEEDED (valid, no rows) or REJECTED with Amazon's reason.

Result

Every tool answers {notification, data, human_action}; data carries:

  • data.workflow_execution_id — pass to ads_get_workflow_execution.
  • data.status — PENDING at first.

Body (Amazon schema)

timeWindowType: ALL | CURRENT_MONTH | EXPLICIT | MOST_RECENT_DAY | MOST_RECENT_WEEK | PREVIOUS_MONTH
+ 15 more: additionalAcrResultsReceivers, advertisers, disableAggregationControls, dryRun,
  maxCertifiedTime, maxDimensionTime, parameterValues, requireSyntheticData, skipPublish, timeWindowEnd,
  timeWindowStart, timeWindowTimeZone, workflow, workflowExecutionTimeoutSeconds, workflowId
Full schema: the Docs link above.

Gotchas

  • Gate: none — a report request; it reads the advertiser's own AMC data.
  • AMC runs at most 10 queries at a time per instance; wait for one to finish before starting more.
  • For numbers that no longer change, query amazon_attributed_events_by_conversion_time: its window is complete once it ends. The by_traffic_time table (the SP console's view) keeps adding purchases for up to 30 days after the window.
  • A SQL keyword as a column alias (`hour`, `date`) is REJECTED as unparsable.
  • Outputting user_id or another VERY_HIGH column is REJECTED.
  • spend is in microcents: divide by 100,000,000 for the currency.
  • For Sponsored Products the detail_page_view / add_to_cart columns of the attributed-events tables are 0; join the clickers in sponsored_ads_traffic to `conversions` (event_subtype 'shoppingCart') on user_id instead.

On this page

Actions

View as Markdown

Ask an assistant

Ask ChatGPTAsk Claude