---
title: "POST /projects/{projectId}/charts/query"
method: POST
path: "/projects/{projectId}/charts/query"
---

# POST /projects/{projectId}/charts/query

`POST /projects/{projectId}/charts/query`

## Request

- Base URL: `https://api.caveman.so/api/v1`
- URL: `https://api.caveman.so/api/v1/projects/{projectId}/charts/query`
- Auth: one of:
  - OAuth 2
    - Authorization code: `/api/v1/oauth/authorize`
    - Token URL: `/api/v1/oauth/token` scopes: `trace:read_metadata`
  - HTTP bearer
  - API key in cookie `cave_access`
  - API key in cookie `__Secure-cave_identity.session_token`

POST /api/v1/projects/{projectId}/charts/query on the Caveman Cloud control plane. Requires the trace:read_metadata scope. Exposed to autonomous agents as the query action of the caveman_charts tool (read access). Run a chart spec (time series, top list or big number) over requests, spans, tool executions or evals; open the traces behind a point; read the field catalog, presets, data-driven suggestions and filter values.

## Query parameters

- `sample_data` boolean

## Request body

- object
  - `chart` object, required
    - `id` string
    - `title` string, required
    - `type` 'timeseries' | 'toplist' | 'bignumber', required
    - `source` 'requests' | 'spans' | 'tools' | 'evals', required
    - `preset` string, nullable
    - `measures` object[], required
      - `label` string
      - `field` string
      - `agg` 'count' | 'sum' | 'avg' | 'min' | 'max' | 'count_distinct' | 'percentile'
      - `p` number
      - `expr` string
    - `filters` object
      - `row` string
      - `trace` string
    - `group_by` string
    - `options` object
      - `unit` 'duration' | 'cost' | 'count' | 'percent' | 'bytes'
      - `viz` 'line' | 'bar'
      - `stacked` boolean
      - `interval` 'auto' | 'hour' | 'day' | 'week'
      - `sort` 'value_desc' | 'value_asc' | 'name_asc' | 'name_desc'
      - `limit` integer
    - `layout` object
      - `w` unknown, required
      - `h` unknown, required
    - `section_id` string, nullable
  - `range` object, required
    - `preset` '1h' | '6h' | '24h' | '3d' | '7d' | '14d' | '30d' | '60d' | '90d'
    - `from` string, date-time
    - `to` string, date-time
  - `dashboard` object
    - `filters` string[]
    - `search` string
    - `group_by` string

## Response `2XX`

Successful response. Exact status depends on synchronous or durable delivery outcome.

## Other responses

- `4XX`: Structured failure. `error.code` is stable; `error.request_id` is echoed in the x-cave-request-id header.
- `5XX`: Structured failure. `error.code` is stable; `error.request_id` is echoed in the x-cave-request-id header.

---

[API](https://skmtc.dev/caveman/apis/caveman-cloud-api.md) - [All operations](https://skmtc.dev/caveman/apis/caveman-cloud-api/llms.txt) - [OpenAPI document](https://skmtc.dev/caveman/apis/caveman-cloud-api/revisions/508312d01cfc?raw)
