/api/agent

POST /api/agent/v1/metric

Changed on

Save a previously constructed query as a named metric.

A metric is a reusable aggregation (a Card of type metric): the underlying query must have exactly one aggregation and at most one date/datetime grouping. The query parameter accepts a query_handle (UUID) returned by construct_query, or a base64-encoded MBQL string. MCP callers should always use the handle. Optionally specify display type, description, collection, and visualization settings. If collection_id is omitted the metric is saved to the caller's personal collection. Pass an explicit null to save it to the root collection. The response collection_path is the saved location.

post/api/agent/v1/metric

Request

  • Base URL
    (relative, and the document was published on a file host, not at the API’s origin)
  • Auth
    API key in header X-API-Key

Request body

collection_idinteger nullable

value must be an integer greater than zero.

descriptionstring nullable
display'table' | 'bar' | 'line' | 'pie' | 'scatter' | 'area' | 'row' | 'combo' | 'pivot' | 'scalar' | 'smartscalar' | 'gauge' | 'progress' | 'funnel' | 'map' | 'waterfall' | 'sankey'

Display types accepted by Card. Validates LLM-passed values so a bogus value (e.g. "potato") gets a 400 rather than persisting junk.

namestring required

value must be a non-blank string.

querystring required

value must be a non-blank string.

visualization_settingsobject nullable

Value must be a map.

Response

Successful response

collection_idinteger nullable required

value must be an integer greater than zero.

collection_pathstring required
descriptionstring nullable required
displaystring required
idinteger required

value must be an integer greater than zero.

namestring required

value must be a non-blank string.

urlstring required

Changes