Skip to main content

Explore iframe

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.

The explore editor is the only Mitzu page that can load in an iframe.

  1. Add the sites that may show it to the API key (Settings → API keys → Edit permissions → Allowed iframe sites), for example https://app.example.com.

  2. From your backend, create a one-time link for the user:

    POST /projects/{workspace_id}/embed/explore-links

    {
    "parent_origin": "https://app.example.com",
    "features": ["download", "user_profiles", "create_cohorts", "show_sql"],
    "start": {"insight_id": "i1"},
    "max_session_hours": 8
    }

    It returns {"url", "expires_at"}. The link works once, within 60 seconds.

  3. Put the URL in an iframe on that site:

    <iframe src="{url}" allow="clipboard-write" style="width: 100%; height: 800px; border: 0"></iframe>

The session lives in the iframe's memory (no third-party cookies), is renewed by Mitzu for up to max_session_hours (at most 8), and ends early, within a minute, when the user loses access to the workspace, the key loses the Embedding permission, or the site is removed from the key's allowed iframe sites. When Mitzu briefly can't check the session, the iframe retries instead of ending it. start is {} (blank), {"insight_id"}, {"definition"} (a chat chart's definition or an insight URL's m= value) or {"cohort_id"}, which opens the number of unique cohort members (users, or the cohort's entity such as accounts) with any event (or, when the workspace has "Any event" turned off, with its most frequent event that can be counted by the cohort's entity; 400 when there is none), for the user to break down or change. An insight_id or cohort_id the user can't read returns 404. A definition that isn't a chart definition, or that uses events, cohorts, insights, custom events or filter groups outside what the user can read in the workspace, returns 400. The session sees what the user can see in the workspace and can only open the link's workspace, and create_cohorts creates new cohorts only. show_sql turns on the editor's "Show SQL" menu item, which shows the generated query with the warehouse table names and the workspace data filter; without it the item is hidden.

Saving needs an Editor licence and the Member role in the workspace. Saved insights are the user's own, regular Mitzu insights.

The iframe posts messages to parent_origin only, and accepts none:

typeData
mitzu:ready
mitzu:resize{"height"}: the content's height in pixels, posted when it changes
mitzu:insight-saved{"insight_id", "name"}
mitzu:session-ended{"reason": "expired"}

The iframe learns parent_origin from the session, so it posts only after mitzu:ready. A link that was already used or has expired shows a message in the iframe and posts nothing; if mitzu:ready doesn't arrive, mint a new link.

End a user's iframe sessions from your backend with DELETE /embed/sessions/{email}.