> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cube.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Issue a Cube API token for Usage Analytics

**🔒 Admin only.** Requires administrator privileges — the authenticated principal (API key, embed JWT, or any bearer token) must belong to a user with the admin role.

Issues a short-lived Cube API token for Cube's internal **Usage Analytics** deployment — the data shown on **Admin → Usage Analytics** — so you can query your own usage and billing data programmatically (REST API, BI tools, scripts) instead of only through the embedded page.

The token is scoped to your account: it carries the same server-resolved security context as the embedded Usage Analytics page, so queries only ever see your own data. Send it as `Authorization: Bearer <token>` on requests to the returned `apiUrl` (the deployment's [Cube REST API](https://cube.dev/docs/product/apis-integrations/rest-api)).

Tokens expire after \~24 hours (see `expiresAt`). Issue a fresh one per session or scheduled refresh — issuing is idempotent and cheap.

Requires Usage Analytics to be enabled for the account, otherwise `404` is returned.


## OpenAPI

````yaml /api-reference/api.yaml post /api/v1/usage-analytics/token
openapi: 3.1.0
info:
  title: Cube Platform API
  version: 1.0.0
  description: >-
    Programmatically manage Cube: deployments and everything scoped to them

    (environments, folders, reports, workbooks, notifications, workspace, and
    agents),

    plus account-level users, groups, policies, embedding, and AI settings.
    Data-model

    authoring, dev mode, branches, and uploads live under /build/api/v1 — same
    host and

    token, routed to the build pods.
servers:
  - url: https://{tenant}.cubecloud.dev
    description: Your tenant host. Replace the whole host if you use a custom domain.
    variables:
      tenant:
        default: your-tenant
        description: Your Cube tenant subdomain
security:
  - bearerAuth: []
tags:
  - name: Deployments
  - name: Deployment Creation
  - name: Environments
  - name: Env Variables
  - name: Regions
  - name: Data Model
  - name: Data Model Uploads
  - name: GitHub
  - name: GitHub Connection
  - name: dbt Sync
  - name: Folders
  - name: Reports
  - name: Workbooks
  - name: Notifications
  - name: Workspace
  - name: Users Admin
  - name: User Attributes
  - name: User Attribute Values
  - name: Tenant Settings
  - name: OAuth Integrations
  - name: User OAuth Tokens
  - name: OIDC Token Configs
  - name: App Theme
  - name: Embed
  - name: Embed Tenants
  - name: Dashboard Embed Access
  - name: Usage Analytics
  - name: OpenAPI Spec
paths:
  /api/v1/usage-analytics/token:
    post:
      tags:
        - Usage Analytics
      summary: Issue a Cube API token for Usage Analytics
      operationId: createToken
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageAnalyticsTokenResponse'
          description: ''
components:
  schemas:
    UsageAnalyticsTokenResponse:
      properties:
        apiUrl:
          description: >-
            Base URL of the Usage Analytics deployment’s Cube REST API (e.g.
            `https://<host>/cubejs-api/v1`). Query it with the returned token.
          type: string
        deploymentId:
          description: Id of the Usage Analytics deployment the token was issued for.
          type: integer
        expiresAt:
          oneOf:
            - type: string
              description: >-
                When the token expires, as an ISO-8601 timestamp. Request a new
                token before this moment — issuing one is idempotent and cheap.
            - type: 'null'
        token:
          description: >-
            A short-lived JWT for the Usage Analytics deployment, carrying this
            tenant’s security context. Send it as `Authorization: Bearer
            <token>` on requests to `apiUrl`.
          type: string
      required:
        - token
        - apiUrl
        - deploymentId
      type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Token authentication. Send `Authorization: Bearer <YOUR_TOKEN>`.'

````