> ## 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.

# Get a Query History request

One API request with the SQL it generated, to the data source and to Cube Store, and how long each query waited and ran. Covers the deployment's production API requests that queried data (REST, GraphQL, SQL and WebSocket), as the Query History page in Cube Cloud shows them; requests to development branches and metadata calls are left out. How far back it reaches is the deployment's Query History retention.


## OpenAPI

````yaml /api-reference/api.yaml get /api/v1/deployments/{deploymentId}/query-history/requests/{id}
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: Databricks Metric View Publication
  - name: Databricks Metric View Integration
  - name: Snowflake Semantic View Sync
  - name: Folders
  - name: Reports
  - name: External Documents
  - name: Workbooks
  - name: Workbook Promotions
  - name: Dashboard Exports
  - name: Notifications
  - name: Scheduled Tasks
  - name: Workspace
  - name: Agents
  - name: Users
  - name: Users Admin
  - name: API Keys
  - name: Roles
  - 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
  - name: Audit Log
  - name: Chat History
  - name: Data Model History
  - name: Ossie Conversion
  - name: Query History
  - name: Report Deliveries
paths:
  /api/v1/deployments/{deploymentId}/query-history/requests/{id}:
    get:
      tags:
        - Query History
      summary: Get a Query History request
      operationId: getQueryHistoryRequest
      parameters:
        - in: path
          name: deploymentId
          required: true
          schema:
            type: integer
        - in: path
          name: id
          required: true
          schema:
            type: string
          description: 'The `id` a listed request carries: `<epochMs>-<spanId>`.'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryHistoryRequestDetail'
          description: ''
components:
  schemas:
    QueryHistoryRequestDetail:
      properties:
        apiType:
          description: '`rest`, `graphql`, `sql` or `ws`.'
          oneOf:
            - type: string
            - type: 'null'
        cacheType:
          description: >-
            Where the answer came from: `cube` (a pre-aggregation in Cube
            Store), `cube-suboptimal` (Cube Store with a suboptimal plan),
            `base` (the data source), `internal` (Cube’s in-memory cache) or
            `none`.
          type: string
        durationMs:
          description: Time to the API response.
          oneOf:
            - type: number
            - type: 'null'
        error:
          oneOf:
            - type: string
            - type: 'null'
        id:
          description: >-
            Pass to `GET …/query-history/requests/{id}`. It is the id in the
            request’s Query History link in Cube Cloud, not `requestId`.
          type: string
        isPlayground:
          type: boolean
        isSubscription:
          type: boolean
        preAggregations:
          description: The pre-aggregations the request used, as APM recorded them.
          oneOf:
            - type: string
            - type: 'null'
        query:
          description: 'The query as the API received it: REST query JSON, or the SQL text.'
          oneOf:
            - type: string
            - type: 'null'
        requestId:
          description: The request id the client sent or Cube assigned.
          type: string
        responseBytes:
          oneOf:
            - type: number
            - type: 'null'
        securityContext:
          description: The security context JSON.
          oneOf:
            - type: string
            - type: 'null'
        spanId:
          type: string
        sqlQueries:
          description: >-
            The SQL the request generated, oldest first: up to 100 queries, each
            to the data source or Cube Store.
          items:
            $ref: '#/components/schemas/QueryHistorySqlQuery'
          type: array
        status:
          $ref: '#/components/schemas/QueryHistoryRequestDetailStatus'
          description: >-
            `success`, `error`, `running` (no response yet), or `noResponse` (no
            response, and silent for five minutes).
        timestamp:
          description: When the request arrived, ISO 8601 UTC.
          type: string
        usedPreAggregations:
          type: boolean
      required:
        - sqlQueries
        - id
        - requestId
        - spanId
        - timestamp
        - status
        - cacheType
        - usedPreAggregations
        - isPlayground
        - isSubscription
      type: object
    QueryHistorySqlQuery:
      properties:
        durationMs:
          oneOf:
            - type: number
            - type: 'null'
        error:
          oneOf:
            - type: string
            - type: 'null'
        executionDurationMs:
          description: Time the data source spent executing.
          oneOf:
            - type: number
            - type: 'null'
        executor:
          $ref: '#/components/schemas/QueryHistorySqlQueryExecutor'
        params:
          description: The values bound to the SQL’s placeholders, in order.
          items: {}
          type: array
        queueDurationMs:
          description: Time spent waiting in the query queue.
          oneOf:
            - type: number
            - type: 'null'
        spanId:
          type: string
        sql:
          oneOf:
            - type: string
            - type: 'null'
        timestamp:
          type: string
      required:
        - spanId
        - timestamp
        - params
        - executor
      type: object
    QueryHistoryRequestDetailStatus:
      enum:
        - success
        - error
        - running
        - noResponse
      type: string
    QueryHistorySqlQueryExecutor:
      enum:
        - dataSource
        - cubeStore
      type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Token authentication. Send `Authorization: Bearer <YOUR_TOKEN>`.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.