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

# Tải tài liệu tri thức

> Trích văn bản, tạo embedding và lưu tài liệu theo tòa nhà.

Thiếu quyền `manage_ai_knowledge` bị từ chối. File đã trùng nội dung trong tòa nhà không được tải lại. Tài liệu, các đoạn và audit được lưu cùng transaction sau khi tạo embedding.

Không có GET danh sách tài liệu trên route này; giao diện admin tải danh sách qua repository phía server.


## OpenAPI

````yaml openapi.json POST /admin/ai/knowledge
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/knowledge:
    post:
      tags:
        - AI
      summary: Tải tài liệu và lập chỉ mục
      description: >-
        Cần quyền AI và manage_ai_knowledge, same-origin. Tệp
        TXT/MD/CSV/JSON/PDF/DOCX/XLSX tối đa 10 MB; nội dung tối đa 1.000.000 ký
        tự. Không có GET trên endpoint này.
      operationId: uploadAiKnowledge
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    Tệp văn bản được hỗ trợ; kiểm tra extension, MIME và nội
                    dung trích xuất.
                title:
                  type: string
                  minLength: 1
                  maxLength: 200
                category:
                  type: string
                  enum:
                    - general
                    - accounting
                    - operations
                    - residents
                    - maintenance
                    - services
                    - safety
                    - legal
                  default: general
              required:
                - file
                - title
              additionalProperties: true
      responses:
        '201':
          description: Tài liệu sau khi tạo embedding, lưu đoạn và audit.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    properties:
                      document:
                        $ref: '#/components/schemas/Document'
                    required:
                      - document
                    additionalProperties: true
                required:
                  - success
                  - data
                additionalProperties: true
        '400':
          description: invalid-knowledge.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: forbidden-origin hoặc forbidden.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: request-too-large khi vượt giới hạn request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: knowledge-unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: ai-not-configured.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - AdminBearer: []
        - AdminCookie: []
components:
  schemas:
    Document:
      type: object
      properties:
        id:
          type: integer
        title:
          type: string
        category:
          type: string
        fileName:
          type: string
        status:
          type: string
        chunkCount:
          type: integer
        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.