query_metrics
Query aggregated metrics for brand performance, competitors, sources, citations, and response trends. Use query_rows for individual records.
Mentions: from "response_mentions". Citations: from "citations". On either, where { is_website: true } selects the brand; { is_competitor: true } selects competitors; { entity_id: { eq: "" } } selects one entity. Filter/group models by model_category (display names like "ChatGPT", "Claude"), never "model". Dimensions vary by cube; source_mentions has no prompt/model dimensions. Group by week (Monday start) or month wherever date groups. prompt_status is the paused flag (true = paused).
Measures: count, count_distinct, avg, sum, min, max; per-measure where enables conditional aggregation. Use compare for two date ranges. When grouping by IDs, use alsoSelect for names: entity_id/entity_name, prompt_id/prompt_text, prompt_topic_id/topic_name (prompts uses topic_id).
Cited pages mentioning competitors but not the brand: from "sources", where { source_mentions_entity: { hasSome: [competitorIds], hasNone: [brandId] } }. Also works on "source_mentions". Checks all stored page mentions per URL/website. Date/model on sources scope AI responses; extracted page content may be older than the live page.
Content-hub attribution: on "sources", where { is_attributed_content: true }; by: ["content_id"], alsoSelect: ["content_title"]. Add content_type to by for type, or group by content_type alone. Read articles from "contents" via query_rows.
Schedule: select one "default" or custom/archived UUID from the catalog, or an array of them to combine schedules. Omit for caller default (current page in Ask Athena); explicit schedule overrides it. Top-level prompt_schedule_kind/id equality filters remain supported but must not conflict with schedule. Historical provenance is independent of current prompt membership; website-level cubes are unaffected.
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": {
"from": "<from>",
"measures": "<measures>",
"website_id": "<website_id>"
},
"name": "query_metrics"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | No | GROUP BY dimensions. Omit for scalar result. | |
| from | Yes | Dataset to query. Cubes and their contracts: Each cube lists its selectable fields, then: filter-only (usable only in where), alsoSelect (name←id: group by the id, pass the name in alsoSelect), groupable (the only fields accepted in by), max limit (the most rows one call returns), and order by index (dims in orderBy that are not in by must follow this order, skipping allowed). websites: created_at, default_language, industry, normalized_url, org_id, website_id, website_name, website_url | groupable: website_id, org_id, industry, default_language | max limit 1000 (default 100) | order by index: website_id competitors: created_at, entity_id, entity_name, website_id | alsoSelect: entity_name←entity_id | groupable: website_id, entity_id | max limit 1000 (default 100) | order by index: website_id, entity_id prompts: created_at, is_paused, language, monthly_searches, prompt_id, prompt_text, prompt_type, topic_id, topic_name, total_value, website_id | filter-only: prompt_tag_ids | alsoSelect: topic_name←topic_id | groupable: website_id, topic_id, prompt_type, is_paused | max limit 1000 (default 100) | order by index: website_id, monthly_searches, total_value, prompt_id responses: cited, company_count, country, date, location_id, model_category, persona_id, prompt_id, prompt_is_deleted, prompt_language, prompt_status, prompt_text, prompt_topic_id, prompt_type, prompt_variation, response_id, sentiment, sentiment_score, target_identifiers, target_rank, topic_name, website_id, content | filter-only: is_base_prompt, prompt_tag_ids, response_mentions_entity | alsoSelect: prompt_text←prompt_id, topic_name←prompt_topic_id | groupable: website_id, date, prompt_id, model_category, sentiment, prompt_type, prompt_topic_id, persona_id, location_id | max limit 100 (default 100) | order by index: website_id, date, prompt_id, response_id response_mentions: country, date, entity_id, entity_name, identifier, is_website, location_id, mention_id, model_category, persona_id, position, prompt_id, prompt_is_deleted, prompt_language, prompt_status, prompt_text, prompt_topic_id, prompt_type, rank, rank_percentile, response_id, topic_name, website_id | filter-only: is_competitor, prompt_tag_ids, ranked_count, response_mentions_entity | alsoSelect: entity_name←entity_id, prompt_text←prompt_id, topic_name←prompt_topic_id | groupable: website_id, date, entity_id, is_website, prompt_id, model_category, prompt_topic_id, persona_id, location_id | max limit 10000 (default 1000) | order by index: website_id, date, entity_id attributes: attribute_id, attribute_mention_id, attribute_name, country, date, entity_id, entity_name, is_website, location_id, model_category, persona_id, positive, prompt_id, prompt_is_deleted, prompt_language, prompt_status, prompt_text, prompt_topic_id, prompt_type, response_id, topic_name, website_id | filter-only: is_competitor, prompt_tag_ids, response_mentions_entity | alsoSelect: entity_name←entity_id, attribute_name←attribute_id, prompt_text←prompt_id, topic_name←prompt_topic_id | groupable: website_id, date, entity_id, attribute_id, positive, is_website, prompt_topic_id | max limit 10000 (default 1000) | order by index: website_id, date, entity_id, attribute_id sources: content_id, content_title, content_type, country, date, domain, full_url, location_id, model_category, normalized_url, persona_id, prompt_id, prompt_is_deleted, prompt_language, prompt_status, prompt_text, prompt_topic_id, prompt_type, response_id, source_id, topic_name, website_id | filter-only: is_attributed_content, prompt_tag_ids, response_mentions_entity | alsoSelect: prompt_text←prompt_id, topic_name←prompt_topic_id, content_title←content_id | groupable: website_id, date, domain, normalized_url, full_url, prompt_id, model_category, prompt_topic_id, content_id, content_type | max limit 10000 (default 1000) | order by index: website_id, date, domain citations: citation_id, country, date, domain, entity_id, entity_name, is_website, location_id, model_category, normalized_url, persona_id, prompt_id, prompt_is_deleted, prompt_language, prompt_status, prompt_text, prompt_topic_id, prompt_type, response_id, source_id, topic_name, website_id | filter-only: is_competitor, prompt_tag_ids, response_mentions_entity | alsoSelect: entity_name←entity_id, prompt_text←prompt_id, topic_name←prompt_topic_id | groupable: website_id, date, entity_id, domain, normalized_url, source_id, prompt_id, model_category, prompt_topic_id | max limit 10000 (default 1000) | order by index: website_id, date, entity_id, domain source_mentions: date, domain, entity_id, entity_name, is_website, normalized_url, source_unique_id, website_id | filter-only: is_competitor | alsoSelect: entity_name←entity_id | groupable: website_id, date, entity_id, is_website, domain, normalized_url, source_unique_id | max limit 10000 (default 1000) | order by index: website_id, domain, date, entity_id topics: created_at, topic_description, topic_id, topic_name, website_id | groupable: website_id, topic_id | max limit 1000 (default 100) | order by index: website_id, topic_id contents: content_id, content_type, created_at, date, effective_date, normalized_url, sheet_id, status, title, topic_id, topic_name, updated_at, url, website_id | alsoSelect: topic_name←topic_id, title←content_id | groupable: website_id, status, topic_id, content_type | max limit 1000 (default 100) | order by index: website_id, effective_date, created_at, content_id | |
| limit | No | Max rows to return. | |
| where | No | WHERE filter (before grouping). | |
| having | No | HAVING filter (after grouping). References measure aliases and by dims. | |
| compare | No | Compare the same measures across two slices. Each base measure `m` expands to `m_<baseline.label>` and `m_<current.label>`; the result also gets `m_delta` (= current − baseline) and `m_pct_change` (= (current − baseline) / baseline, null when baseline = 0). For a min/max of `date`, `m_delta` is in days and `m_pct_change` is null. Default labels are 'baseline' and 'current'; override per side for non-temporal compares (e.g. brand vs competitors). One scan; orderBy on `m_delta` works push-down. | |
| orderBy | No | ORDER BY. Measure aliases and by dims allowed. | |
| measures | Yes | Aggregate expressions keyed by output column name. Example: { total: { fn: 'count_distinct', of: 'response_id' } } | |
| schedule | No | One schedule from the catalog ("default" or a custom/archived UUID), or an array of them to combine their data. Omit to use the caller default. The retired "manual" token is accepted as a deprecated alias of "default". Website-level cubes are unaffected. | |
| alsoSelect | No | Label dimensions carried via any(). Must be determined by a by dim (cube's dependentDims). Example: entity_name when entity_id is in by. | |
| website_id | Yes | The website to query. Must be a website your credentials can access. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | Yes | ||
| notice | No |