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.
/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
{
"valid": true,
"errors": [],
"warnings": [
"Field 'limit' is set but aggregation is 'sum'; limit applies after aggregation and may hide data."
]
}
Description
How to Use
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
- Agent guardrails — let an LLM compose a chart spec and validate it before committing to the more expensive render step.
- UI live validation — call on every keystroke or field change to give instant feedback in a chart-builder UI.
- CI / data pipeline tests — assert that a set of canonical chart specs remain valid after a dataset schema change.
- Batch pre-flight — validate a collection of saved chart specs before scheduling an overnight report run.
Start using Validate Chart Configuration now
Get your free API key and make your first request in under a minute.