data_query
Query data from Google Ads, Facebook Ads, Google Analytics, LinkedIn Ads, TikTok Ads, Microsoft Ads, Shopify, HubSpot, and 200+ other platforms. Use data_source_discovery, accounts_discovery and field_discovery first. Returns rows when completed; else pass schedule_id to get_async_query_results. Team- and data-source-level context arrives with data_source_discovery/accounts_discovery, and a narrowed accounts_discovery (≤3 accounts) inlines an account's own context — apply what you already have. Only when you are querying a specific account whose context you have not seen, read it first with get_business_context (ds_id + account_id) for reporting guidelines — e.g. which campaigns to exclude, how to segment data, preferred metrics.
If the user specifies reporting preferences during the conversation (e.g. "exclude brand campaigns", "always break out Advantage+ separately", "for this client we only look at last-click attribution"), ask whether to save these as context for future sessions using manage_business_context with action 'save'.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"ds_id": "<ds_id>"
},
"name": "data_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ds_id | Yes | Data source ID from data_source_discovery (e.g. 'FA', 'AW', 'GAWA') | |
| fresh | No | Skip stored results and run the query again. Use only to confirm a change right after a write, e.g. a budget or status update; it is slower and uses more quota. Only for campaign management data sources (e.g. Facebook Ads, Google Ads). Not available with API keys or for every client; the result notes say when it was not applied. | |
| fields | No | Field IDs from field_discovery, comma-separated. List dimensions before metrics (e.g. 'date,clicks,cost'); if unsure whether a field is a dimension or metric, check field_discovery. All fields must share a common report_type if the source uses report types. | |
| filters | No | Filter expression: field_name operator value, combined with AND/OR. Operators: ==, !=, >, >=, <, <=, =@ (contains), !@ (not contains), =~ (regex), !~ (not regex), [] (in list). Example: "country == US AND clicks > 100" | |
| compress | No | Always recommended. Returns completed rows as a compact text table whose columns are the requested field IDs. | |
| end_date | No | YYYY-MM-DD. Required when date_range_type=custom. | |
| max_rows | No | Max rows to return (default 1000). Higher values may be capped by your license. | |
| settings | No | Data source settings from data_source_discovery as a JSON object. Include report_type and all setting_ids here. report_type is a preference when the source picks the report from the fields; some sources treat it as a strict choice and refuse one that does not fit. TikTok Smart+: use platform_details.is_smart_plus in campaign_and_resource_get. | |
| timezone | No | IANA timezone (e.g. 'America/New_York'). Default: UTC. | |
| start_date | No | YYYY-MM-DD. Required when date_range_type=custom. | |
| ds_accounts | No | Account IDs from accounts_discovery, or free-text identifier when is_free_text_account_required=true. Required when has_account_list=true; ALL_ACCOUNTS queries every account of the connected logins: use only when the user asks for all accounts, as it can be slow or rate-limited on sources with many accounts. | |
| compare_show | No | perc_change (default), abs_change, or value | |
| compare_type | No | prev_range, prev_year, prev_year_weekday, or custom (with compare_start/end_date) | |
| date_range_type | No | A date range is required for nearly all data sources (is_date_range_required=true in data_source_discovery config). Use a relative range: last_7_days, last_30_days, last_90_days, last_month, this_month, yesterday, etc. (append '_inc' to include the current period), or 'custom' with start_date/end_date. Pass as a root-level parameter, NOT inside settings. | |
| compare_end_date | No | YYYY-MM-DD (when compare_type=custom) | |
| compare_start_date | No | YYYY-MM-DD (when compare_type=custom) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | ||
| error | No | ||
| notes | No | ||
| success | Yes | ||
| business_context | No |