📊

Validate Chart Configuration

Validate a chart spec against a dataset schema without fetching data or rendering. Returns errors and warnings before you commit to a visualize call.

POST /v1/validate-chart
curl -X POST "https://analytics.toolkitapi.io/v1/validate-chart" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "dataset_id": "ds_abc123",
    "chart_spec": {
      "chart_type": "bar",
      "x": "region",
      "y": "revenue",
      "aggregation": "sum",
      "sort": {"by": "revenue", "direction": "desc"},
      "limit": 20
    }
  }'
import httpx

resp = httpx.post(
    "https://analytics.toolkitapi.io/v1/validate-chart",
    json={
    "dataset_id": "ds_abc123",
    "chart_spec": {
      "chart_type": "bar",
      "x": "region",
      "y": "revenue",
      "aggregation": "sum",
      "sort": {"by": "revenue", "direction": "desc"},
      "limit": 20
    }
  },
)
print(resp.json())
const resp = await fetch("https://analytics.toolkitapi.io/v1/validate-chart", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "dataset_id": "ds_abc123",
    "chart_spec": {
      "chart_type": "bar",
      "x": "region",
      "y": "revenue",
      "aggregation": "sum",
      "sort": {"by": "revenue", "direction": "desc"},
      "limit": 20
    }
  }),
});
const data = await resp.json();
console.log(data);
# See curl example
Response 200 OK
{
  "valid": true,
  "errors": [],
  "warnings": [
    "Field 'limit' is set but aggregation is 'sum'; limit applies after aggregation and may hide data."
  ]
}

Description

Validate a chart spec against a dataset schema without fetching data or rendering. Returns errors and warnings before you commit to a visualize call.

How to Use

1

1. Obtain a `dataset_id` from `/v1/analyze` or `/v1/datasets/bundle`. 2. Build the `chart_spec` you intend to pass to `/v1/visualize`. 3. `POST` both to `/v1/validate-chart`. 4. If `valid` is `false`, inspect `errors` to surface actionable messages to the user or agent. 5. Review `warnings` for non-blocking issues that could affect chart quality. 6. Once `valid` is `true`, proceed with `/v1/visualize`.

About This Tool

The **Validate Chart** endpoint checks a `chart_spec` against the schema of an existing `dataset_id` without loading any row data or rendering a chart. It returns a `valid` flag, a list of blocking `errors`, and a list of non-blocking `warnings` in a single lightweight call.

Because validation is purely schema-level, it is orders of magnitude faster and cheaper than a full `/v1/visualize` call. Use it as a pre-flight check whenever user input is involved — for example, when an AI agent is constructing a chart spec or when a UI provides a live "check" button before rendering.

Why Use This Tool

Start using Validate Chart Configuration now

Get your free API key and make your first request in under a minute.