InsightsValidate a config (no query)

Validate a config (no query)

Shape check for an insight configno query runs. Applies the same rules as the write path: config.query must be a valid explore spec (unknown keys, limits, date ranges, maths, filters) and its kind must match insight_type. Requires an agency key (ak_) and ?location_id=. Use it on every edit; run /insights/preview when you also need data.

curl -X POST "https://mythic-analytics.gulp.workers.dev/builder/insights/validate?location_id=acme-retail" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
  "insight_type": "number",
  "config": {
    "query": {
      "kind": "trend",
      "date_range": {
        "preset": "30d"
      },
      "interval": "day",
      "series": [
        {
          "event": "$pageview",
          "math": "dau",
          "label": "Visitors"
        }
      ],
      "compare": "previous_period"
    }
  }
}'
{
  "ok": false,
  "errors": [
    "insight_type "line" cannot draw a "funnel" query"
  ]
}
POST
/insights/validate
POST
Base URLstring

Target server for requests. Edit to use your own host.

Bearer Token
Bearer Tokenstring
Required

Builder key as a bearer token. Use an agency key (Bearer ak_...) for writes, or a viewer key (Bearer sk_...) for reads. Scoped keys (mcp_) with insights:read/insights:write are accepted too.

Builder key as a bearer token. Use an agency key (Bearer ak_...) for writes, or a viewer key (Bearer sk_...) for reads. Scoped keys (mcp_) with insights:read/insights:write are accepted too.
query
location_idstring

Client location to scope the request to. Required when authenticating with an agency key (ak_). Ignored for viewer keys (sk_).

Content-Typestring
Required

The media type of the request body

Options: application/json
insight_typestring
Required

Visualization only. funnel draws a kind: funnel spec; the others draw a kind: trend spec (line/table want an interval, number/bar/pie usually don't).

Options: number, line, bar, pie, table, funnel
configobject
Required

query is an explore spec — the same object POST /client/v1/data/query takes; the full grammar is on the Explore queries page and a per-type walkthrough on the Insight config reference. Any other key is stored verbatim as display settings and never read by the runner.

Request Preview
Response

Response will appear here after sending the request

Authentication

header
Authorizationstring
Required

Bearer token. Builder key as a bearer token. Use an agency key (Bearer ak_...) for writes, or a viewer key (Bearer sk_...) for reads. Scoped keys (mcp_) with insights:read/insights:write are accepted too.

Query Parameters

location_idstring

Client location to scope the request to. Required when authenticating with an agency key (ak_). Ignored for viewer keys (sk_).

Example:
acme-retail

Body

application/json
insight_typestring
Required

Visualization only. funnel draws a kind: funnel spec; the others draw a kind: trend spec (line/table want an interval, number/bar/pie usually don't).

Allowed values:numberlinebarpietablefunnel
configobject
Required

query is an explore spec — the same object POST /client/v1/data/query takes; the full grammar is on the Explore queries page and a per-type walkthrough on the Insight config reference. Any other key is stored verbatim as display settings and never read by the runner.

Example:
{"query":{"kind":"trend","date_range":{"preset":"30d"},"interval":"day","series":[{"event":"$pageview","math":"dau","label":"Visitors"}],"compare":"previous_period"}}

Responses

okboolean
errorsstring[]

Present only when ok is false.