InsightsPreview an unsaved config

Preview an unsaved config

Run an insight config in-memory and return the same payload as the saved-insight runner — without persisting anything. Use it for a builder's live "Run" on a draft. Requires an agency key (ak_) and ?location_id=. Charges the query rate-limit allowance. Identical drafts are served from a 120-second cache so keystroke-driven previews are free to repeat.

curl -X POST "https://mythic-analytics.gulp.workers.dev/builder/insights/preview?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"
    }
  },
  "dateRange": {},
  "granularity": "hour"
}'
{}
POST
/insights/preview
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; table, bar and number can also draw kind: attribution; the others draw a kind: trend spec (line/table want an interval, number/bar/pie usually don't). Analysis panels: constraints → table/number/bar, correlation → line/table, scanner_summary → pie/bar/line/table/number.

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

Exactly one of query or analysis. query is an explore spec — the same object POST /client/v1/data/query takes (trend, funnel, or attribution for ad spend, CPA and ROAS); the full grammar is on the Explore queries page and a per-type walkthrough on the Insight config reference. analysis runs a constraint finder, correlation or scanner summary as the viewer (not on public or embedded dashboards). Any other key is stored verbatim as display settings and never read by the runner, except metric on an attribution number.

dateRangeobject

Optional override of config.query.date_range, e.g. { "preset": "7d" } or { "preset": "custom", "from": "2026-08-01", "to": "2026-08-31" }. Presets: 24h, 7d, 14d, 30d, 90d, 365d, custom.

granularitystring

Optional override of config.query.interval (trends only).

Options: hour, day, week, month
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; table, bar and number can also draw kind: attribution; the others draw a kind: trend spec (line/table want an interval, number/bar/pie usually don't). Analysis panels: constraints → table/number/bar, correlation → line/table, scanner_summary → pie/bar/line/table/number.

Allowed values:numberlinebarpietablefunnel
configobject
Required

Exactly one of query or analysis. query is an explore spec — the same object POST /client/v1/data/query takes (trend, funnel, or attribution for ad spend, CPA and ROAS); the full grammar is on the Explore queries page and a per-type walkthrough on the Insight config reference. analysis runs a constraint finder, correlation or scanner summary as the viewer (not on public or embedded dashboards). Any other key is stored verbatim as display settings and never read by the runner, except metric on an attribution number.

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

Optional override of config.query.date_range, e.g. { "preset": "7d" } or { "preset": "custom", "from": "2026-08-01", "to": "2026-08-31" }. Presets: 24h, 7d, 14d, 30d, 90d, 365d, custom.

granularitystring

Optional override of config.query.interval (trends only).

Allowed values:hourdayweekmonth

Responses

Query result for the draft — the explore response (series + buckets for a trend, steps for a funnel) with meta, the echoed config, the compiled sql, and cached. Documented under the Queries group (POST /insights/{id}/query).