Skip to main content

Analytics API

Enterprise feature

Embedding is an Enterprise feature that Mitzu support switches on for your organisation. See Embedded analytics for setup, and send the authentication headers with every call.

Reading assets​

All of these run as the X-Mitzu-User user. A workspace or asset that user can't open returns 404, the same as an id that doesn't exist. Drafts and archived items are left out.

Method and pathReturns
GET /projects/{workspace_id}/embed/display-settings{"workspace_id", "name", "timezone_offset", "label_colors", "branding"}; timezone_offset is in hours. branding has logo and cover, each {"id", "content_type", "updated_at"} or null; id changes when the image is replaced
GET /projects/{workspace_id}/embed/branding/{logo|cover}The workspace's logo or cover image, with its Content-Type; 404 when it isn't set. Serve it to the browser from your backend so the API key stays there
GET /projects/{workspace_id}/embed/catalog/propertiesProperties you can group by: {"items": [{"id", "name", "type", "source"}]}. Use the id (for example dimension:users.country) in group_by
GET /projects/{workspace_id}/embed/dashboards{"items": [{"id", "name", "description", "updated_at"}]}
GET /projects/{workspace_id}/embed/dashboards/{dashboard_id}Dashboard with pages, cards and the layout Mitzu draws
GET /projects/{workspace_id}/embed/insightsSaved insights: {"items": [{"id", "name", "description", "chart_type", "updated_at"}]}
GET /projects/{workspace_id}/embed/insights/{insight_id}One insight with its chart_type and a readable summary
GET /projects/{workspace_id}/embed/cohortsCohorts: {"items": [{"id", "name", "description", "kind", "entity", "size", "updated_at"}]}
GET /projects/{workspace_id}/embed/cohorts/{cohort_id}One cohort
GET /projects/{workspace_id}/embed/cohorts/{cohort_id}/membersIds of the members Mitzu stores for the cohort (uploaded and saved member lists): {"items": ["id", ...], "next_cursor"}. Pass next_cursor back as ?cursor=; ?limit= is at most 1000
GET /projects/{workspace_id}/embed/annotationsAnnotations shown on charts: {"items": [{"id", "text", "description", "from", "to", "color"}]}

Responses never contain owner names or emails, SQL or Mitzu's internal insight format.

Changing assets​

Method and pathWhat it does
POST /projects/{workspace_id}/embed/dashboards/{dashboard_id}/cardsBody {"insight_id", "page_id"?}. Adds the insight as a full-width card at the end of the page (the first page when page_id is missing) and returns 201 {"card_id", "dashboard"} with the dashboard as GET returns it. Needs an Editor licence, the Member role in the workspace and edit rights on the dashboard, otherwise 403
POST /projects/{workspace_id}/embed/cohorts/{cohort_id}/refreshBody {}. Recomputes the cohort's members in the background, works for every kind of cohort, and returns 202 {"run_id", "status": "running", "poll_after_ms"}. Anyone who can read an uploaded list can refresh it. The other kinds run a warehouse query, so they need a role that can query the warehouse (an Editor licence and the Member role); otherwise 403
GET /projects/{workspace_id}/embed/cohorts/{cohort_id}/refresh/{run_id}{"status", "size", "computed_at", "members", "members_truncated"}, plus message when status is failed. status is running, done or failed. members holds the first 1000 ids in sorted order. A finished refresh also updates the cohort's size and updated_at. Only the user and key that started a refresh can read it. A refresh they call while their refresh of the same cohort is running returns that run's run_id. A refresh fails without storing anything when the cohort is edited or deleted while it runs, when an uploaded list is replaced while it runs, or when it hasn't finished within 15 minutes. A refresh that finishes after another refresh of the same cohort returns its own result and leaves the newer stored size in place. When too many refreshes are running, the call returns 409 busy

Dashboard layout​

Mitzu packs dashboard cards into rows. layout.pages[].rows[] gives you the same rows: each row has a height (short, tall or divider) and cards whose widths add up to 12 columns.

{
"id": "d1", "name": "Sales overview", "description": "",
"pages": [{"id": "p1", "name": "Overview", "position": 0}],
"layout": {"columns": 12, "pages": [{"page_id": "p1", "rows": [
{"height": "short", "cards": [{"id": "c1", "width": 4}, {"id": "c2", "width": 8}]}
]}]},
"cards": [
{"id": "c1", "type": "insight", "view": "chart",
"insight": {"id": "i1", "name": "Orders", "chart_type": "number"}},
{"id": "c2", "type": "text", "markdown": "## Notes"},
{"id": "c3", "type": "divider", "text": "Funnels"}
]
}

Reading data​

Method and pathReturns
POST /projects/{workspace_id}/embed/insights/{insight_id}/dataOne insight's data. GET works too and uses the defaults
POST /projects/{workspace_id}/embed/dashboards/{dashboard_id}/dataEvery insight card's data
POST /projects/{workspace_id}/embed/dashboards/{dashboard_id}/cards/{card_id}/dataOne card's data
GET /projects/{workspace_id}/embed/runs/{run_id}A run that wasn't ready yet

The request body sets optional overrides:

{
"date_range": {"last": 30, "unit": "day"},
"time_group": "day",
"group_by": ["dimension:users.device_type"],
"cache": "prefer",
"wait_seconds": 10
}
  • date_range is {"last": n, "unit": "day" | "week" | "month"} or {"from": "2026-01-01", "to": "2026-01-31"} (plain dates, nothing else in the object). last counts back from the workspace's end date (Workspace settings → Insights). Leave date_range out to use the insight's own date range.
  • time_group is total, hour, day, week, month, quarter or year.
  • group_by breaks the insight down by these properties, like a dashboard's breakdown filter. On dashboard data, fields you leave out keep the dashboard's defaults one by one: sending only time_group keeps its date range, and "group_by": [] clears its default breakdown.
  • cache is prefer (fresh cached result when there is one), only (never run a query; an insight with no cached result is failed with "code": "not_cached") or refresh (always run).
  • card_ids (dashboard data only) limits the answer to those cards; 404 when none of them is an insight card on the dashboard.
  • wait_seconds (0 to 20) waits for a run before answering. Each API key has at most two waiting calls at a time, and fewer when the server is busy; a call that can't wait answers at once, and you poll as for any running result.

Insight data​

{
"insight_id": "i1", "status": "ready", "computed_at": "2026-11-24T10:00:00Z",
"source": "cache", "run_id": null,
"chart": {"type": "line", "x_axis": {"label": "Day", "kind": "time"},
"y_axis": {"label": "Orders", "suffix": ""}, "series_label": "Country"},
"series": [{"key": "DE", "label": "DE", "color": "#5470c6", "comparison": false,
"points": [{"x": "2026-11-01", "y": 120, "text": "120"}]}],
"table": {"columns": [{"key": "Day", "label": "Day"}], "rows": [["2026-11-01"]],
"incomplete_cells": []},
"applied": {"date_range": {"last": 30, "unit": "day"}, "time_group": null, "group_by": []},
"view": "chart",
"truncated": false
}

status is ready, stale (an older result while a new one runs), running (poll /runs/{run_id} after poll_after_ms) or failed (with a message; a query that fails is failed even when an older result exists). table holds at most 500 rows; truncated is true when the result had more. Dashboard data returns {"dashboard_id", "cards": [<insight data> + "card_id"]}; one card that fails doesn't fail the others. view is chart or table, as the card shows it, on every response. applied lists the overrides that took effect: time_group is null when the insight has no time axis (a single number), and group_by is [] when the insight can't be broken down by those properties.

chart.type is one of line, bar, horizontal_bar, stacked_bar, stacked_area, percentage_stacked_bar, percentage_stacked_area, pie, number, heatmap, geo_country, sankey or pivot_table. Funnels and retention come as bar or line series; a funnel point is one step with its conversion y, its users and the dropoff share. A point's text is plain text, for example 61.9% · 337. x_axis.kind is time when the x values are dates, otherwise category. Per type:

  • table holds the same rows and columns Mitzu shows under the chart; use it for pivot_table and for cards whose view is table. The columns that label rows keep their text; in every other column, cells are numbers wherever Mitzu shows a number. A column of percentages or durations has a suffix: % (27.5 means 27.5%) or secs (durations in seconds). incomplete_cells lists [row, column] positions of periods that aren't over yet, which Mitzu marks with *. When the API can't tell which columns are labels, the table is left as Mitzu shows it, with text cells: results computed before 20 November 2026 until they are refreshed, and chat charts that aren't over time (a chat trend chart converts its date and AVG columns). A column that mixes units, such as a pivot with segments on its rows, also stays text.
  • number adds big_number: {"value", "text", "label", "comparison_text", "change", "direction"}. comparison_text is the previous period's value as text, change the relative change (0.12 is +12%) and direction up, down or flat.
  • percentage_stacked_* series hold percentages (28.3 means 28.3%).
  • heatmap has one series per row with a numeric x per column.
  • geo_country series use country codes as x.
  • sankey adds sankey: {"nodes": [{"id", "label", "step"}], "links": [{"source", "target", "value"}]}. <drop-off> nodes are users who stopped there.