Skip to main content
Cube D3 supports embedding the analytics chat interface directly into your applications via an iframe or API. This allows you to give users a guided, semantic-layer-aware data assistant—anywhere in your product or portal.

Getting Started with Embedding

1. Enable Embedding

To enable the embedding feature:
  • You must have admin privileges in your Cube instance.
  • Navigate to Admin → API → Embed.
  • Click Enable Embedding.
Once enabled, you’ll be able to generate embed sessions using your API key.

2. Get Your API Key

To use the embedded chat, you need an API Key:
  • Navigate to Users → API Keys in your Cube admin panel.
  • Generate or copy your existing API key.
  • You’ll use this key to authenticate API calls for generating embed sessions.

3. Generate an Embed Session

Use the /api/v1/embed/generate-session endpoint to create a session for your user. This endpoint will automatically create (insert) or update the external user based on the externalId provided.
Accounts are limited to 10,000 external users. To increase this limit, please contact support.

Example (JavaScript)

const API_KEY = 'YOUR_API_KEY';

const session = await fetch('https://your-tenant.cubecloud.dev/api/v1/embed/generate-session', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Access-Token ${API_KEY}',
  },
  body: JSON.stringify({ 
    externalId: 'user@example.com',
    userAttributes: [ // optional - enables row-level security
      {
        name: 'city',
        value: 'San Francisco'
      },
      {
        name: 'department', 
        value: 'Sales'
      }
    ]
  }),
});

const data = await session.json();
const sessionId = data.sessionId;

4. Embedding via iframe

Use the session ID to embed the chat UI in your application:
<iframe
  title="Analytics Chat"
  src="https://your-tenant.cubecloud.dev/embed/chat?sessionId=YOUR_SESSION_ID"
></iframe>

User Attributes

User attributes enable row-level security and personalized chat responses by filtering data based on user permissions. The attributes you pass during session generation automatically filter data queries and responses.
User attributes must first be configured in your Cube D3 admin panel. See the User Attributes Administration Guide for setup instructions.
How it works:
  1. Configure attributes in your admin panel (e.g., city, department)
  2. Pass attributes during session generation
  3. Data is automatically filtered based on user permissions through access policies
  4. AI responses are personalized to the user’s context
Example use cases:
  • Sales reps only see data for their assigned territory
  • Regional managers see data filtered by their city
  • Department heads see only their department’s metrics
I