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

# 材料分类

> 材料分类。默认分类以医疗票据和保险常用文件为主。


支持两种输入方式(互斥)：

- **方式一**：传 material_id 或 batch_id 指定已上传的材料

- **方式二**：直接上传文件(multipart/form-data 或 file_urls)


同时传文件和 material_id/batch_id 会返回 400 错误



## OpenAPI

````yaml POST /doc-agent/api/v1/capability/material/classify
openapi: 3.0.3
info:
  description: |-
    CapabilityService 独立子能力服务
     提供文件上传、图像质检、材料分类、材料抽取等独立能力，不依赖案件流程。
     通过 batch_id 和 material_id 串联各能力调用。

     ## 典型调用流程
     1. 上传文件 → UploadFiles，获得 batch_id 和 material_id 列表
     2. (可选)图像质检 → CheckImageQuality，可独立调用，也可用上传返回的 material_id
     3. (可选)材料分类 → ClassifyMaterial，可独立调用，也可用上传返回的 material_id
     4. 材料抽取 → ExtractMaterial，传入 material_id 列表，返回每个材料的状态和结果
     5. 轮询 → 重复调用 ExtractMaterial 直到所有材料完成，或等待 callback_url 回调
     注: 质检和分类可独立调用，不依赖抽取流程；抽取接口的 material_ids 必须来自上传接口。
     注: ExtractMaterial 幂等，已完成的材料不会重新抽取，失败的材料会自动重试。

     ## 错误响应
     所有接口错误均返回 HTTP 非 200 状态码，body 格式: {"code": 400, "msg": "错误描述"}
     常见错误码:
       400 — 参数校验失败(缺少必填字段、文件数超限等)
       403 — 认证失败(x-ti-app-id 或 x-ti-secret-code 缺失/无效)
       404 — 资源不存在(material_id / batch_id 无效)
       500 — 内部处理异常

     错误响应示例:
       {"code": 404, "msg": "material not found"}
       {"code": 404, "msg": "batch not found"}
       {"code": 400, "msg": "material_ids or batch_id is required"}
       {"code": 400, "msg": "material does not belong to the specified batch"}
       {"code": 400, "msg": "files or file_urls is required"}
       {"code": 400, "msg": "所有材料必须属于同一批次"}
       {"code": 403, "msg": "x-api-key 或 x-ti-app-id/x-ti-secret-code 不能为空"}
  title: CapabilityService API
  version: 0.0.1
servers:
  - url: https://agents.textin.com/
security: []
tags:
  - name: CapabilityService
paths:
  /doc-agent/api/v1/capability/material/classify:
    post:
      tags:
        - CapabilityService
      description: |-
        材料分类。默认分类以医疗票据和保险常用文件为主。


        支持两种输入方式(互斥)：

        - **方式一**：传 material_id 或 batch_id 指定已上传的材料

        - **方式二**：直接上传文件(multipart/form-data 或 file_urls)


        同时传文件和 material_id/batch_id 会返回 400 错误
      operationId: CapabilityService_ClassifyMaterial
      parameters:
        - in: header
          name: x-ti-app-id
          required: true
          schema:
            type: string
        - in: header
          name: x-ti-secret-code
          required: true
          schema:
            type: string
      requestBody:
        content:
          multipart/form-data:
            example:
              files: '@门诊收费票据01.png'
              material_id: 8ffe03ce-4714-4b50-8daf-afee06002cc3
            schema:
              properties:
                batch_id:
                  description: 批次 ID(处理批次下所有材料)
                  example: 661be601-65c7-4025-af0f-20d357dfb090
                  type: string
                file_urls:
                  description: URL 上传(与 material_id/batch_id 互斥)，JSON 数组格式
                  example: '["https://example.com/file1.pdf"]'
                  type: string
                files:
                  description: 文件二进制上传(支持多文件)
                  format: binary
                  type: string
                material_id:
                  description: 已上传材料的 ID(处理单个材料，与 files/file_urls 互斥)
                  example: 8ffe03ce-4714-4b50-8daf-afee06002cc3
                  type: string
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              example:
                code: 200
                data:
                  materials:
                    - category: 费用与结算
                      material_id: 8ffe03ce-4714-4b50-8daf-afee06002cc3
                      material_type: 医疗门诊收费票据(电子)
                    - category: 费用与结算
                      material_id: 27734e23-3482-42a3-98d7-1bdb369118bc
                      material_type: 住院费用明细清单
                message: OK
              schema:
                properties:
                  code:
                    description: 业务状态码
                    example: 200
                    type: integer
                  data:
                    $ref: >-
                      #/components/schemas/capability.v1.CapabilityClassifyResponse
                  message:
                    description: 状态说明
                    example: OK
                    type: string
                type: object
          description: OK
components:
  schemas:
    capability.v1.CapabilityClassifyResponse:
      properties:
        materials:
          description: 各材料的分类结果
          items:
            $ref: '#/components/schemas/capability.v1.MaterialClassifyResult'
          type: array
      type: object
    capability.v1.MaterialClassifyResult:
      properties:
        category:
          description: 大类名称
          type: string
        material_id:
          description: 材料 ID
          type: string
        material_type:
          description: 小类名称
          type: string
      type: object

````