> ## 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. A prompt, answer or SQL longer than 20,000 characters, or an error longer than 2,000, is cut and ends in `…`. Each turn also lists its `steps`: every reply the agent wrote, with its reasoning, and every tool it called, with its input, in the order they began; their texts are cut the same way. Each query carries up to 100 of its result `rows`.

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: 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: 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'
        steps:
          description: >-
            Everything the agent did in the turn, in the order it began: each
            reply with its reasoning, and each tool call. When any step has no
            `startedAt`, the steps are in the order they last changed instead.
            Returned only when reading a single thread.
          oneOf:
            - items:
                $ref: '#/components/schemas/ChatHistoryStep'
              type: array
            - 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:
        columns:
          description: >-
            The column name of each `rows` cell. Returned only when reading a
            single thread. Null when `rows` is.
          oneOf:
            - items:
                type: string
              type: array
            - type: 'null'
        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: How many rows the query returned.
          oneOf:
            - type: integer
            - type: 'null'
        rows:
          description: >-
            The result rows the agent saw, at most 100; `rowCount` says how many
            the query returned. Returned only when reading a single thread. Null
            when the query returned no result, as when it failed or was stopped.
          oneOf:
            - items:
                type: array
                items: {}
              type: array
            - 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
    ChatHistoryStep:
      properties:
        input:
          description: 'Tool steps: the arguments the agent passed, as JSON.'
          oneOf:
            - type: string
            - type: 'null'
        messageId:
          description: The message id; a query's step shares its `messageId`.
          type: string
        reasoning:
          description: >-
            Model steps: the model's reasoning, as the model reported it; some
            models report only a summary, and a stopped step may hold only its
            start. Null when it reported none.
          oneOf:
            - type: string
            - type: 'null'
        startedAt:
          description: >-
            When the step began. Null for steps recorded before Cube stored step
            times.
          oneOf:
            - type: string
            - type: 'null'
        status:
          description: 'Tool steps: `incomplete` when the tool never returned.'
          oneOf:
            - $ref: '#/components/schemas/ChatHistoryStepStatus'
            - type: 'null'
        text:
          description: >-
            Model steps: what the agent wrote, such as a note before calling
            tools or its answer.
          oneOf:
            - type: string
            - type: 'null'
        tool:
          description: 'Tool steps: the tool the agent called.'
          oneOf:
            - type: string
            - type: 'null'
        type:
          $ref: '#/components/schemas/ChatHistoryStepType'
          description: '`model` for a reply the agent wrote, `tool` for a tool it called.'
      required:
        - type
        - messageId
      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
    ChatHistoryStepStatus:
      enum:
        - success
        - error
        - incomplete
      type: string
    ChatHistoryStepType:
      enum:
        - model
        - tool
      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.