Back to Cube

Introduction

docs-mintlify/api-reference/introduction.mdx

1.6.564.9 KB
Original Source

Programmatically manage your Cube Cloud account: work with deployments and the resources scoped to them (environments, folders, reports, workbooks, notifications, workspace items, and agents), manage account-level users, groups, policies, embedding, and AI settings over a REST API, and provision users and groups from your identity provider via SCIM 2.0.

Official client library

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: `Api-Key ${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>

Base URL

Both APIs are served from your Cube Cloud tenant host under /api:

text
https://<tenant>.cubecloud.dev/api

Endpoints live under two namespaces:

  • /api/v1/… — the REST management API (deployments and nested resources)
  • /api/scim/v2/… — the SCIM 2.0 user and group provisioning API

Only HTTPS calls are accepted. Authenticate every request — see Authentication.

Available endpoints

EntityResourceVersion
Deployments/v1/deploymentsv1
Environments/v1/deployments/{deploymentId}/environmentsv1
Folders/v1/deployments/{deploymentId}/foldersv1
Reports/v1/deployments/{deploymentId}/reportsv1
Workbooks/v1/deployments/{deploymentId}/workbooksv1
Notifications/v1/deployments/{deploymentId}/notificationsv1
Workspace/v1/deployments/{deploymentId}/workspacev1
Agents/v1/deployments/{deploymentId}/agentsv1
Metadata/v1/metav1
Users/v1/usersv1
Groups/v1/groupsv1
User Groups/v1/user-groupsv1
User Attributes/v1/user-attributesv1
Resource Policies/v1/resource-policiesv1
App Theme/v1/app-themev1
AI Engineer/v1/ai-engineerv1
Embed/v1/embedv1
Embed Tenants/v1/embed-tenantsv1
SCIM Users/scim/v2/UsersSCIM 2.0
SCIM Groups/scim/v2/GroupsSCIM 2.0