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

# 更新文件类别

> 更新指定文件类别的信息。

注意：设置 extract_model 时将级联覆盖该分类下所有字段和表格的抽取模型。

`category_keyword_rules` 不传或传 `null` 时不修改既有规则；传入有效对象时全量替换；仅传入 `{"positive_rules":[],"negative_rules":[]}` 时清空。`{}`、空白字符串和非法结构均返回参数错误。与同空间其他已启用类别的同类型规则组重复时返回冲突错误。参数校验错误码：`1005025065`–`1005025069`；跨类别规则组冲突复用 `1005015019`。




## OpenAPI

````yaml /docflow/cn/rest-api/openapi.bundle.yaml post /api/app-api/sip/platform/v2/category/update
openapi: 3.0.0
info:
  title: DocFlow API
  description: DocFlow REST API，提供文件上传和获取文件处理结果能力
  version: 2.14.1
servers:
  - url: https://docflow.textin.com
security:
  - ApiId: []
    SecretCode: []
paths:
  /api/app-api/sip/platform/v2/category/update:
    post:
      tags:
        - 文件类别
      summary: 更新文件类别
      description: >
        更新指定文件类别的信息。


        注意：设置 extract_model 时将级联覆盖该分类下所有字段和表格的抽取模型。


        `category_keyword_rules` 不传或传 `null` 时不修改既有规则；传入有效对象时全量替换；仅传入
        `{"positive_rules":[],"negative_rules":[]}`
        时清空。`{}`、空白字符串和非法结构均返回参数错误。与同空间其他已启用类别的同类型规则组重复时返回冲突错误。参数校验错误码：`1005025065`–`1005025069`；跨类别规则组冲突复用
        `1005015019`。
      operationId: updateCategory
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                workspace_id:
                  type: string
                  description: 空间ID
                  example: '1234567890'
                category_id:
                  type: string
                  description: 文件类别ID
                  example: '1234567890'
                name:
                  type: string
                  description: 文件类别名称
                  example: 发票
                  maxLength: 50
                category_prompt:
                  type: string
                  description: 用于分类的提示词
                  example: 增值税发票，包含发票代码、发票号码等字段
                  maxLength: 150
                category_keyword_rules:
                  type: object
                  allOf:
                    - $ref: '#/components/schemas/CategoryKeywordRules'
                  nullable: true
                  description: >
                    分类关键词规则。不传或
                    null=不修改；有效对象=全量替换；`positive_rules`、`negative_rules`
                    都为空数组=清空。

                    不接受 `{}` 或空白字符串。
                enabled:
                  $ref: '#/components/schemas/EnabledStatus'
                extract_model:
                  type: string
                  description: |
                    抽取模型，设置后级联覆盖所有字段和表格
                    - Auto: 智能匹配抽取模型
                    - Acgpt: 速度快，抽取结果稳定
                    - Acgpt-VL: 多模态，适用简单抽取（≤10 页）
                    - DF-M1: 适用复杂文档理解
                  example: Acgpt
                  enum:
                    - Auto
                    - Acgpt
                    - Acgpt-VL
                    - DF-M1
                with_detail:
                  type: boolean
                  description: |
                    是否返回完整详情。传 true 时响应返回分类自身信息（不含子层级字段/表格）。
                    不传或为 false 时仅返回 code/msg。
              required:
                - workspace_id
                - category_id
      responses:
        '200':
          description: 成功更新文件类别
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/CodeMessage'
                  - type: object
                    properties:
                      result:
                        description: with_detail=true 时返回分类自身信息，否则为 null
                        type: object
                        properties:
                          id:
                            type: string
                            description: 分类ID
                          name:
                            type: string
                            description: 分类名称
                          description:
                            type: string
                            description: 分类描述
                          category_prompt:
                            type: string
                            description: 分类提示词
                          category_keyword_rules:
                            $ref: '#/components/schemas/CategoryKeywordRules'
                          extract_model:
                            type: string
                            description: 抽取模型
                          enabled:
                            type: integer
                            description: 启用状态
components:
  schemas:
    CategoryKeywordRules:
      type: object
      description: |
        分类关键词规则。正向规则组间为 OR；命中任一反向规则组时排除该类别。
        同一类别最多 10 个正向规则组和 1 个反向规则组；同类型规则组不得重复，正向与反向规则不得包含相同关键词。
      properties:
        positive_rules:
          type: array
          description: 正向规则组，规则组之间为 OR
          maxItems: 10
          items:
            $ref: '#/components/schemas/CategoryKeywordRuleGroup'
        negative_rules:
          type: array
          description: 反向规则组，命中时排除该类别
          maxItems: 1
          items:
            $ref: '#/components/schemas/CategoryKeywordRuleGroup'
      required:
        - positive_rules
        - negative_rules
    EnabledStatus:
      type: integer
      description: |
        启用状态
        - 0: 禁用
        - 1: 启用
        - 2: 草稿
      enum:
        - 0
        - 1
        - 2
    CodeMessage:
      type: object
      properties:
        code:
          type: integer
          description: 状态码
          example: 200
        msg:
          type: string
          description: 状态描述
      required:
        - code
        - msg
    CategoryKeywordRuleGroup:
      type: object
      description: 分类关键词规则组。组内至少命中 min_hit 个关键词时该规则组命中。
      properties:
        group_name:
          type: string
          description: 规则组名称，仅用于展示
          maxLength: 50
          example: 发票核心要素
        min_hit:
          type: integer
          description: 规则组命中所需的最少关键词数，取值为 1 至 words 的数量
          minimum: 1
          example: 2
        words:
          type: array
          description: 关键词列表。每个关键词不得为空或超过 50 个字符，同一规则组内的关键词不得重复。
          minItems: 1
          maxItems: 20
          items:
            type: string
            minLength: 1
            maxLength: 50
          example:
            - 发票号码
            - 购买方名称
            - 价税合计
      required:
        - group_name
        - min_hit
        - words
  securitySchemes:
    ApiId:
      type: apiKey
      in: header
      name: x-ti-app-id
    SecretCode:
      type: apiKey
      in: header
      name: x-ti-secret-code

````

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