Back to Cube

Introduction

docs-mintlify/api-reference/introduction.mdx

1.7.168.3 KB
Original Source

Cube exposes three HTTP API families, each for a different job and with slightly different authentication:

APIWhat it's forAuthentication
Core Data APIQuery your data model over HTTP — run queries (/v1/load) and read metadata (/v1/meta)Cube API token (a JWT) sent directly in the Authorization header — no prefix
AI APIStream conversations with Cube AI agents (/chat/stream-chat-state)Cube API key with the Api-Key prefix
Platform APIManage Cube — deployments, data models, reports, workbooks, users, policies, and moreBearer prefix for REST and SCIM 2.0

The exact header for each is shown above. The Platform and SCIM schemes are detailed on the Authentication page; the Core Data and AI headers are also documented on their own reference pages.

Available endpoints

Each API family has its own base URL — copy the exact host from the Cube interface where noted. Only HTTPS is accepted, and every request must be authenticated (see Authentication).

Core Data API

Base URL — your deployment's data API host (the /cubejs-api base path is configurable):

text
https://{deployment}.{region}.cubecloudapp.dev/cubejs-api
EndpointPath
JSON queryPOST /v1/load
SQL queryPOST /v1/cubesql
MetadataGET /v1/meta

AI API

Base URL — your agent's Chat API URL (copy it from Admin → Agents → Chat API URL):

text
https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}
EndpointPath
Stream chat statePOST /chat/stream-chat-state

Platform API

Base URL — your tenant host:

text
https://{tenant}.cubecloud.dev

Endpoints live under three path prefixes on that host, all taking the same token:

PrefixWhat it covers
/api/v1/…Management of deployments, workspace content, users, policies, and embedding
/build/api/v1/…Data model authoring — files, uploads, dev mode, and branches. Routed to the build workers that own a deployment's data model.
/api/scim/v2/…SCIM 2.0 user and group provisioning

Resources by entity:

EntityResourceVersion
Deployments/api/v1/deploymentsv1
Deployment Creation/build/api/v1/deploymentsv1
Environments/api/v1/deployments/{deploymentId}/environmentsv1
Env Variables/api/v1/deployments/{deploymentId}/env-varsv1
Regions/api/v1/regionsv1
Data Model/build/api/v1/deployments/{deploymentId}v1
Data Model Uploads/build/api/v1/deployments/{deploymentId}/data-modelv1
GitHub/api/v1/githubv1
GitHub Connection/build/api/v1/deployments/{deploymentId}/github/connectv1
dbt Sync/api/v1/deployments/{deploymentId}/dbt-syncv1
Folders/api/v1/deployments/{deploymentId}/foldersv1
Reports/api/v1/deployments/{deploymentId}/reportsv1
Workbooks/api/v1/deployments/{deploymentId}/workbooksv1
Notifications/api/v1/deployments/{deploymentId}/notificationsv1
Workspace/api/v1/deployments/{deploymentId}v1
Users Admin/api/v1/usersv1
User Attributes/api/v1/user-attributesv1
User Attribute Values/api/v1/user-attribute-valuesv1
Tenant Settings/api/v1/tenant/settingsv1
OAuth Integrations/api/v1/oauth-integrationsv1
User OAuth Tokens/api/v1/user-oauth-tokensv1
OIDC Token Configs/api/v1/oidc-token-configsv1
App Theme/api/v1/app-configv1
Embed/api/v1/embedv1
Embed Tenants/api/v1/embed-tenantsv1
Dashboard Embed Access/api/v1/deployments/{deploymentId}/workbooks/{workbookId}/embed-accessv1
Users (SCIM)/scim/v2/UsersSCIM 2.0
Groups (SCIM)/scim/v2/GroupsSCIM 2.0

Client libraries

Core Data API

Query the Core Data API from JavaScript or TypeScript with Cube's JS client, @cubejs-client/core, which also ships React, Vue, and Angular bindings and a WebSocket transport for real-time updates. See the JavaScript SDK reference for full usage.

bash
npm install @cubejs-client/core

Platform API

The recommended way to call the Platform API from JavaScript or TypeScript is the official client, @cube-dev/platform-client. It wraps the OpenAPI spec on this site with end-to-end types for every endpoint, request, and response, plus optional React Query bindings.

<CodeGroup>
bash
npm install @cube-dev/platform-client
bash
yarn add @cube-dev/platform-client
bash
pnpm add @cube-dev/platform-client
</CodeGroup>

Create a client with your tenant's base URL and an auth header (see Authentication), then call any endpoint through the fully-typed fetchClient:

ts
import { createCubePlatformClient } from '@cube-dev/platform-client';

const client = createCubePlatformClient({
  baseUrl: 'https://<tenant>.cubecloud.dev',
  // Returned on every request — provide the Platform API auth header.
  getHeaders: () => ({ Authorization: `Bearer ${process.env.CUBE_API_KEY}` }),
});

const { data, error } = await client.fetchClient.GET('/api/v1/deployments/', {
  params: { query: { first: 50 } },
});

for (const deployment of data?.items ?? []) {
  console.log(deployment.id, deployment.name);
}

React Query bindings

The @cube-dev/platform-client/react-query entry point adds a provider and typed hooks built on @tanstack/react-query (a peer dependency alongside react):

tsx
import { createCubePlatformClient } from '@cube-dev/platform-client';
import {
  CubePlatformApiProvider,
  useCubePlatformApiQuery,
} from '@cube-dev/platform-client/react-query';

const client = createCubePlatformClient({ baseUrl, getHeaders });

function App() {
  return (
    <CubePlatformApiProvider client={client}>
      <Deployments />
    </CubePlatformApiProvider>
  );
}

function Deployments() {
  const { data } = useCubePlatformApiQuery('get', '/api/v1/deployments/');
  return <ul>{data?.items.map((d) => <li key={d.id}>{d.name}</li>)}</ul>;
}
<Info> Schema types are exported as `PlatformApiSchemas` (e.g. `PlatformApiSchemas['Deployment']`). See the package [`CHANGELOG`](/api-reference/changelog) for release notes and breaking changes. </Info>