POST /queries/run from your own scripts, CI jobs, or internal tools with a bearer token from the API overview.
This is the HTTP surface behind the Costory MCP query tool and the Explorer UI. A query that works in chat or in the app works here with the same request body.
What you can query
Each item inqueries is a series. Every series needs a type and a single-letter name (a, b, c, …). Put human labels in alias, not in name.
Scope vs split:
filterCelscopes which rows to include (for example EC2 only).groupBysplits the result into series or rows (for example per environment).
cos_ prefix (cos_service_name, cos_environment). Untagged resources are CEL null (cos_environment == null).
A query in one call
Prefer adatePreset when one matches. Pass from and to only for custom ranges. Do not combine a preset with explicit dates.
compare: {} (or { "enabled": true }) and Costory derives the preceding period from your preset:
kind: series) or a comparison (kind: comparison) when compare is enabled.
Discover dimensions and metrics first
Before you invent CEL field names or metric ids, call the companion list endpoints:- List queryable dimensions for
groupByandfilterCelfields - List business metrics for saved
metricseries ids - List usage metrics for
usageseries ids
Diff tree for cost changes
When you need a rollup tree of what moved between two periods (not a flat Explorer comparison), use Run a cost-change diff tree. It requires an enabled comparison, a non-hourlyaggBy, and at least one groupBy on a single cost or usage series.
