Skip to main content
Embedded Cube surfaces communicate with your host page over the browser postMessage API, in both directions:
  • Events (cube:event:*) travel embed → host. Subscribe to them to learn how a viewer interacts with the embed — when it loads, what they view, download, drill into, search for with AI, and any errors they hit. Feed them into your own analytics / event bus.
  • Actions (cube:action:*) travel host → embed. Send them to drive the embed from your app — switch the color scheme, set a filter, navigate, or refresh the data.
No SDK is required — it’s plain window.postMessage and a message listener.

Message envelope

Every message — in either direction — is a single object with the same shape:

Listening to events

Attach a single message listener to window. Always validate event.origin against your tenant’s origin and check data.source === "cube-embed" before trusting a message.

Event catalog

Every event payload is also delivered with the envelope’s surface field, so you can always tell which surface (dashboard, app, or chat) it came from — including AI queries, which report app when run inside the embedded app and chat on the standalone chat surface.

cube:event:ready

Emitted once per session, as soon as the embed authenticates and mounts. The handshake — the first event you receive, and the moment to record an “embed opened”.

cube:event:view

Emitted when a surface is viewed — on the initial load and again whenever the viewer navigates within the embed.

cube:event:navigate

Emitted when the viewer navigates within the embed (a route change). Use it to mirror the embed’s location in your own router or analytics.

cube:event:dashboard-loaded

Emitted when a dashboard has finished rendering all of its widgets — the “fully painted” signal (distinct from ready, which fires at mount, before data loads).

cube:event:download

Emitted when a viewer exports something — a widget’s data as CSV, or (in future) a dashboard image. Reports that an export happened and its shape — never the exported rows themselves.
The CSV download action on a dashboard widget only appears when the embed URL includes allowExport=true (see Dashboards → Allow CSV export). The event fires when a viewer uses it.

cube:event:drilldown

Emitted when a viewer drills into a measure (clicks a chart mark or table cell to see its detail rows).

cube:event:ai-query

Emitted around an AI / natural-language query — capturing what the viewer asked and the lifecycle stage. Fires wherever AI chat is used: the standalone chat surface, the dashboard agent, and the embedded app.

cube:event:error

Emitted when the embed surfaces an error (a render error, a query failure, an auth/session problem). fatal distinguishes an error that took the whole surface down from a recoverable one.

Sending actions

Send actions into the embed by posting a message to the iframe’s contentWindow. Always target your tenant’s origin (not "*") so the message can’t leak to another document if the iframe navigates away.

Action catalog

cube:action:set-color-scheme

Switch the embed’s color scheme at runtime.

cube:action:set-theme

Apply a brand theme (colors, fonts) to the embed at runtime. The payload is an embedTheme object — the same shape the Generate Session API accepts. Common fields are primaryColor, borderRadius, and font; see App customization for the full list.

cube:action:set-locale

Switch the embed’s UI language. Accepts a full code (es-ES), a short code (es), or a regional variant. See Localization for the list of supported languages and the other ways to set the language.

cube:action:set-filter

Push a filter into a dashboard. The filterUrlParameter is the same f_<semantic_view>.<dimension>=<JSON> form used to pre-set filters via URL, so you can capture a viewer’s filters and restore them later.

cube:action:navigate

Navigate the embed to an in-embed path.

cube:action:refresh

Re-run the embed’s queries and refresh its data. No payload.

Surfaces

Events come from one of three customer-facing surfaces, reported in the envelope’s surface field:

Security

  • Always validate event.origin against your tenant’s origin in your message listener, and check data.source === "cube-embed". Never act on a message that fails either check.
  • Target your tenant’s origin when sending actions (iframe.contentWindow.postMessage(msg, CUBE_ORIGIN)), not "*", so an action can’t be delivered to an unexpected document.

Complete example

A minimal host page that loads a signed dashboard embed, logs every event, and exposes buttons to drive it. Generate the session on your backend with the Generate Session API — see Signed embedding for the full flow.