> ## 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 chat thread

**🔒 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.

One chat thread with all of its turns, oldest first. A turn is one prompt and everything the agent did to answer it: the final answer, the tools it called, and each query it ran with its SQL, status, row count and any thumbs-up/down feedback. Query result rows are never included. A prompt, answer or SQL longer than 20,000 characters, or an error longer than 2,000, is cut and ends in `…`.

Chat history export is in preview: when it is not enabled for the account, `404` is returned.


## OpenAPI

````yaml /api-reference/api.yaml get /api/v1/deployments/{deploymentId}/chat-history/threads/{chatId}
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: 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: Chat History
  - name: Ossie Conversion
  - name: Report Deliveries
paths:
  /api/v1/deployments/{deploymentId}/chat-history/threads/{chatId}:
    get:
      tags:
        - Chat History
      summary: Get a chat thread
      operationId: getChatHistoryThread
      parameters:
        - in: path
          name: deploymentId
          required: true
          schema:
            type: integer
        - in: path
          name: chatId
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatHistoryThread'
          description: ''
components:
  schemas:
    ChatHistoryThread:
      properties:
        agentId:
          description: Null for the Auto agent.
          oneOf:
            - type: integer
            - type: 'null'
        chatId:
          description: The thread id, as used in chat URLs and the Chat API.
          type: string
        createdAt:
          type: string
        initialContext:
          description: >-
            The surface inside the app the thread began on; null when it was not
            recorded.
          oneOf:
            - type: string
            - type: 'null'
        source:
          description: >-
            Where the thread was started; null for a source this API does not
            name.
          oneOf:
            - $ref: '#/components/schemas/ChatHistoryThreadSource'
            - type: 'null'
        title:
          oneOf:
            - type: string
            - type: 'null'
        turns:
          description: >-
            Oldest first. Present on a single thread, and on a list with
            `includeTurns=true`.
          oneOf:
            - items:
                $ref: '#/components/schemas/ChatHistoryTurn'
              type: array
            - type: 'null'
        updatedAt:
          description: When the thread last changed, normally its latest turn.
          type: string
        user:
          $ref: '#/components/schemas/ChatHistoryUser'
      required:
        - chatId
        - user
        - createdAt
        - updatedAt
      type: object
    ChatHistoryThreadSource:
      enum:
        - web
        - api
        - mcp
        - slack
        - scheduled
      type: string
    ChatHistoryTurn:
      properties:
        endedAt:
          description: >-
            The agent's last write in the turn. Null for turns recorded before
            Cube stored turn times.
          oneOf:
            - type: string
            - type: 'null'
        files:
          description: Names of files the user attached. Their content is never included.
          items:
            type: string
          type: array
        finalAnswer:
          description: >-
            The agent's last text reply in the turn; null when it answered only
            with a chart.
          oneOf:
            - type: string
            - type: 'null'
        index:
          description: Position in the thread, from 0.
          type: integer
        messageId:
          description: The id of the user message that opened the turn.
          type: string
        prompt:
          description: What the user asked, as they typed it.
          type: string
        queries:
          items:
            $ref: '#/components/schemas/ChatHistoryQuery'
          type: array
        startedAt:
          description: >-
            When the user sent the prompt. Null for turns recorded before Cube
            stored turn times.
          oneOf:
            - type: string
            - type: 'null'
        tools:
          description: Every tool the agent called in the turn, in first-call order.
          items:
            type: string
          type: array
      required:
        - index
        - messageId
        - prompt
        - files
        - tools
        - queries
      type: object
    ChatHistoryUser:
      properties:
        email:
          description: >-
            Null when the Cube user was deleted, or the embedded user had no
            email.
          oneOf:
            - type: string
            - type: 'null'
        externalId:
          description: Embedded users only.
          oneOf:
            - type: string
            - type: 'null'
        id:
          description: >-
            For a Cube user, their user id. For an embedded user, an id in a
            separate number space: identify them by `externalId`.
          type: integer
        name:
          description: Cube users only.
          oneOf:
            - type: string
            - type: 'null'
        type:
          $ref: '#/components/schemas/ChatHistoryUserType'
      required:
        - id
        - type
      type: object
    ChatHistoryQuery:
      properties:
        dataSource:
          description: The data source a `runSql` query ran on.
          oneOf:
            - type: string
            - type: 'null'
        error:
          oneOf:
            - type: string
            - type: 'null'
        feedback:
          description: The latest thumbs up or down on this query, if any.
          oneOf:
            - $ref: '#/components/schemas/ChatHistoryQueryFeedback'
            - type: 'null'
        messageId:
          description: The tool-call message id.
          type: string
        rowCount:
          description: Rows the query returned. The rows themselves are never included.
          oneOf:
            - type: integer
            - type: 'null'
        sql:
          description: The SQL the agent generated.
          oneOf:
            - type: string
            - type: 'null'
        status:
          $ref: '#/components/schemas/ChatHistoryQueryStatus'
          description: >-
            `incomplete` when the query never returned: the turn was stopped or
            failed.
        title:
          oneOf:
            - type: string
            - type: 'null'
        tool:
          description: >-
            `cubeSqlApi` for a query against the semantic layer, `runSql` for
            one against a warehouse data source.
          type: string
      required:
        - messageId
        - tool
        - status
      type: object
    ChatHistoryUserType:
      enum:
        - internal
        - external
      type: string
    ChatHistoryQueryFeedback:
      properties:
        createdAt:
          type: string
        isPositive:
          type: boolean
        userId:
          description: Who rated the query.
          oneOf:
            - type: integer
            - type: 'null'
      required:
        - isPositive
        - createdAt
      type: object
    ChatHistoryQueryStatus:
      enum:
        - success
        - error
        - incomplete
      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.