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

# 创建协同规则

> 为抽取应用创建转人工审核的触发规则。

接入流程和规则命中语义见[人机协同](/api-reference/collaboration)。保存后请查询规则，核对实际保存的条件。


## OpenAPI

````yaml api-reference/adp-api.yaml POST /open/agentic_doc_processor/{tenant_name}/v1/collaboration/rules/create
openapi: 3.1.0
info:
  title: ADP API
  version: 1.0.0
  description: >-
    Laiye ADP 官方 OpenAPI
    接口规范，覆盖文档抽取、解析与转换，抽取应用管理、Webhook、人机协同、积分查询，以及工作流发现、运行、导出和文件管理。
  license:
    name: MIT
    identifier: MIT
servers:
  - url: https://adp.laiye.com
    description: ADP 生产环境
security: []
tags:
  - name: 文档抽取
    description: 从上传的文档中抽取结构化字段。
  - name: 文档解析
    description: 识别上传文档中的文字、版面块和位置信息。
  - name: 文档转换
    description: 将 PDF、Office、OFD 和图片转换为页面图片或电子表格结构。
  - name: 应用管理
    description: 创建、修改、删除和查询抽取应用及配置。
  - name: Webhook
    description: 查询事件目录并管理事件回调。
  - name: 账户
    description: 查询账户积分和使用情况。
  - name: 工作流
    description: 查询业务工作流模板、运行工作流应用并查询执行结果。
  - name: 工作流文件
    description: 上传和管理工作流应用使用的文件。
  - name: 人机协同
    description: 配置审核触发规则，查询协同任务并提交人工修正。
paths:
  /open/agentic_doc_processor/{tenant_name}/v1/collaboration/rules/create:
    post:
      tags:
        - 人机协同
      summary: 创建人机协同规则
      description: >-
        为应用创建一组命中后进入人工审核的触发条件；每个应用使用一组规则。


        保存后必须查询规则并核对名称、条件和组合逻辑；不支持的自然语言条件可能返回 success 但没有保存。rule_status
        当前回读不可靠，需验证实际启停效果。


        HTTP 200 不保证业务成功，请检查 code。


        接入步骤与当前限制见[人机协同](/api-reference/collaboration)。
      operationId: createCollaborationRule
      parameters:
        - $ref: '#/components/parameters/TenantName'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CollaborationRuleRequest'
            example:
              app_id: app_abc123
              rule_name: 发票人工审核
              rule_status: true
              rule:
                - rule_dimension: 发票号码
                  rule_setting: 等于 INV-AUDIT-001
              rule_logic: 1
      responses:
        '200':
          description: 业务响应。请检查 code，并在写入后回查业务结果。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollaborationEmptyResponse'
              example:
                code: success
                message: ''
                tips: null
                data: {}
        '401':
          description: 缺少 API Key。
        '404':
          description: API Key 无效或请求不可访问。
        '422':
          $ref: '#/components/responses/ValidationError'
      security:
        - ApiKeyAuth: []
components:
  parameters:
    TenantName:
      name: tenant_name
      in: path
      required: true
      description: 租户名称，默认 laiye。
      schema:
        type: string
        default: laiye
  schemas:
    CollaborationRuleRequest:
      type: object
      properties:
        app_id:
          type: string
          description: 应用 ID。请使用当前账号已发布的标准自定义抽取应用的实际 ID。
          example: app_abc123
        rule_name:
          type: string
          description: 规则名称。当前最多 50 个字符，同一账号下跨应用不能重名。
          minLength: 1
          maxLength: 50
        rule_status:
          type: boolean
          default: true
          description: 是否启用规则。false 用于停用；查询接口当前可能仍返回 true，需通过实际抽取核验启停效果。
        rule:
          type: array
          items:
            $ref: '#/components/schemas/CollaborationRuleItem'
          minItems: 1
          maxItems: 100
          description: 审核触发条件列表，1–100 条。
        rule_logic:
          type: integer
          default: 1
          enum:
            - 1
            - 2
          description: 1=任一条件命中（OR）；2=所有条件命中（AND）。只传 1 或 2，其他值当前可能被误接受。
      required:
        - app_id
        - rule_name
        - rule
    CollaborationEmptyResponse:
      type: object
      properties:
        code:
          type: string
          description: >-
            业务结果码。成功为 success；失败可能为 server_error、http_server_error
            等字符串，必须检查，不能只看 HTTP 200。
        message:
          type: string
        tips:
          type:
            - string
            - 'null'
        data:
          anyOf:
            - type: object
            - type: 'null'
    CollaborationRuleItem:
      type: object
      properties:
        rule_dimension:
          type: string
          description: >-
            审核维度：整体文档、文档置信度或已发布的字段名称。当前优先使用名称与 key 一致的普通字段；系统维度和名称/key
            不同的字段需先验证实际触发效果。
        rule_setting:
          type: string
          description: 触发人工审核的自然语言条件，例如“等于 INV-AUDIT-001”。条件命中后进入人工审核。
      required:
        - rule_dimension
        - rule_setting
    HTTPValidationError:
      type: object
      description: FastAPI/Pydantic 请求参数校验错误。
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorItem'
      required:
        - detail
    ValidationErrorItem:
      type: object
      additionalProperties: true
      properties:
        type:
          type: string
          description: 校验错误类型。
        loc:
          type: array
          description: 错误字段在请求中的位置。
          items:
            oneOf:
              - type: string
              - type: integer
        msg:
          type: string
          description: 可读的错误说明。
        input:
          description: 导致校验失败的输入值。
        ctx:
          type: object
          additionalProperties: true
          description: 校验器提供的补充上下文。
        url:
          type: string
          format: uri
          description: Pydantic 错误说明链接。
      required:
        - type
        - loc
        - msg
  responses:
    ValidationError:
      description: 参数校验错误。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HTTPValidationError'
          example:
            detail:
              - type: greater_than
                loc:
                  - query
                  - limit
                msg: Input should be greater than 0
                input: 0
                ctx:
                  gt: 0
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: 生产环境 API Key，可在 ADP 平台的「我的 API」中查看。请确保 API Key 有效且属于生产环境。

````

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