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

# Đọc lịch sử AI

> Đọc danh sách cuộc trò chuyện hoặc tin nhắn theo chủ và tòa nhà.

GET trả 401 cả khi không có phiên lẫn khi không có quyền route AI. POST cùng route phân biệt 401 thiếu phiên và 403 thiếu quyền. Danh sách thread lấy tối đa 50 mục; tin nhắn lấy tối đa 100 mục cũ đến mới.


## OpenAPI

````yaml openapi.json GET /admin/ai/chat
openapi: 3.0.3
info:
  title: 'Taho: Mini App và AI'
  version: source-review-2026-10-07
  description: >-
    Đặc tả biên soạn trong docs từ handler và service hiện tại. Không phải
    endpoint Swagger do application phục vụ; không xác nhận kết nối provider
    hoặc UAT.
servers: []
security: []
tags:
  - name: Mini App
  - name: Admin Mini App
  - name: AI
paths:
  /admin/ai/chat:
    get:
      tags:
        - AI
      summary: Đọc lịch sử trò chuyện AI
      description: >-
        Giới hạn theo tòa nhà và chủ cuộc trò chuyện. Handler trả unauthorized
        401 cho cả thiếu phiên hoặc thiếu quyền route trong GET.
      operationId: readAiHistory
      parameters:
        - name: threadId
          in: query
          required: false
          schema:
            type: string
          description: >-
            Có giá trị: đọc tối đa 100 tin nhắn theo thứ tự cũ đến mới. Không
            có: đọc tối đa 50 cuộc trò chuyện.
      responses:
        '200':
          description: Danh sách thread hoặc tin nhắn của thread.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    oneOf:
                      - type: object
                        properties:
                          threads:
                            type: array
                            items:
                              $ref: '#/components/schemas/Thread'
                        required:
                          - threads
                        additionalProperties: true
                      - type: object
                        properties:
                          threadId:
                            type: string
                          messages:
                            type: array
                            items:
                              $ref: '#/components/schemas/Message'
                        required:
                          - threadId
                          - messages
                        additionalProperties: true
                required:
                  - success
                  - data
                additionalProperties: true
        '400':
          description: >-
            invalid-chat-request, gồm thread không thuộc chủ/tòa nhà hoặc không
            tồn tại.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: ai-unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - AdminBearer: []
        - AdminCookie: []
components:
  schemas:
    Thread:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        model:
          type: string
        createdAt:
          type: string
        updatedAt:
          type: string
      additionalProperties: true
    Message:
      type: object
      properties:
        id:
          type: integer
        role:
          type: string
        content:
          type: string
        citations:
          type: array
          items:
            type: string
        createdAt:
          type: string
      additionalProperties: true
    Error:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details: {}
          required:
            - code
            - message
          additionalProperties: true
      required:
        - success
        - error
      additionalProperties: true
  securitySchemes:
    AdminBearer:
      type: http
      scheme: bearer
      description: Token phiên quản trị, vẫn phải qua route/action và active tower checks.
    AdminCookie:
      type: apiKey
      in: cookie
      name: taho_jwt

````

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