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

# Create File Category

> Create a new file category in the specified workspace, requiring at least one sample file and at least one field configuration.

Supports one-stop creation: you can pass the `tables` parameter to create tables with nested fields simultaneously.




## OpenAPI

````yaml /docflow-global/en/rest-api/openapi.bundle.yaml post /api/app-api/sip/platform/v2/category/create
openapi: 3.0.0
info:
  title: DocFlow API
  description: >-
    DocFlow REST API, providing file upload and file processing result retrieval
    capabilities
  version: 2.8.4
servers:
  - url: https://docflow.textin.ai
security:
  - ApiId: []
    SecretCode: []
paths:
  /api/app-api/sip/platform/v2/category/create:
    post:
      tags:
        - File Category
      summary: Create File Category
      description: >
        Create a new file category in the specified workspace, requiring at
        least one sample file and at least one field configuration.


        Supports one-stop creation: you can pass the `tables` parameter to
        create tables with nested fields simultaneously.
      operationId: createCategory
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                workspace_id:
                  type: string
                  description: Workspace ID
                  example: '1234567890'
                name:
                  type: string
                  description: File category name
                  example: Invoice
                  maxLength: 50
                category_prompt:
                  type: string
                  description: Prompt for classification
                  example: >-
                    VAT invoice, including fields such as invoice code, invoice
                    number, etc.
                  maxLength: 150
                description:
                  type: string
                  description: File category description
                extract_model:
                  type: string
                  description: |
                    Extraction model
                    - Auto: Automatically matches the extraction model
                    - Acgpt: Fast speed with stable extraction results
                    - Acgpt-VL: VLM, suitable for simple extraction (≤10 pages)
                    - DF-M1: Suitable for complex document understanding
                  example: Acgpt
                  enum:
                    - Auto
                    - Acgpt
                    - Acgpt-VL
                    - DF-M1
                sample_files:
                  type: array
                  description: >-
                    Sample file list, at least one sample file must be uploaded,
                    a category can have at most 20 sample files
                  items:
                    type: string
                    format: binary
                  minItems: 1
                  maxItems: 10
                fields:
                  type: array
                  description: >-
                    Field configuration list, at least one field must be
                    configured
                  items:
                    $ref: '#/components/schemas/CategoryFieldConfig'
                  minItems: 1
                tables:
                  type: array
                  description: >-
                    Optional, table configuration list (one-stop creation),
                    supports nested fields
                  items:
                    $ref: '#/components/schemas/CategoryTableConfig'
                with_detail:
                  type: boolean
                  description: >
                    Whether to return full details. When true, the response
                    includes complete category info (with fields, tables,
                    samples).

                    When not set or false, only category_id is returned.
              required:
                - workspace_id
                - name
                - extract_model
                - sample_files
                - fields
      responses:
        '200':
          description: Successfully created file category
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/CodeMessage'
                  - type: object
                    properties:
                      result:
                        type: object
                        properties:
                          category_id:
                            type: string
                            description: File category ID
                            example: '1234567890'
                          name:
                            type: string
                            description: >-
                              File category name (returned when
                              with_detail=true)
                          description:
                            type: string
                            description: >-
                              File category description (returned when
                              with_detail=true)
                          category_prompt:
                            type: string
                            description: >-
                              Classification prompt (returned when
                              with_detail=true)
                          extract_model:
                            type: string
                            description: Extraction model (returned when with_detail=true)
                          enabled:
                            type: integer
                            description: Enabled status (returned when with_detail=true)
                          fields:
                            type: array
                            description: Field list (returned when with_detail=true)
                            items:
                              $ref: '#/components/schemas/CategoryField'
                          tables:
                            type: array
                            description: Table list (returned when with_detail=true)
                            items:
                              $ref: '#/components/schemas/CategoryTable'
                          samples:
                            type: array
                            description: Sample list (returned when with_detail=true)
                            items:
                              $ref: '#/components/schemas/CategorySample'
                        required:
                          - category_id
components:
  schemas:
    CategoryFieldConfig:
      type: object
      properties:
        name:
          type: string
          description: Field name
          example: Invoice Code
        description:
          type: string
          description: Field description
          example: Invoice code description
        prompt:
          type: string
          description: Semantic extraction prompt
        use_prompt:
          type: boolean
          description: Whether to use semantic prompt
        alias:
          type: array
          description: >-
            Field aliases. On update: omit=no change, empty array []=clear
            aliases, non-empty array=override
          items:
            type: string
          example:
            - Invoice No.
            - Bill Number
        identity:
          type: string
          description: >-
            Export field name. On update: omit=no change, empty string ""=clear,
            non-empty=override
          example: invoice_number
        multi_value:
          type: boolean
          description: Whether to enable multi-value extraction
        duplicate_value_distinct:
          type: boolean
          description: >-
            Whether to deduplicate values, only effective when multi_value is
            true
        transform_settings:
          $ref: '#/components/schemas/TransformSettings'
    CategoryTableConfig:
      type: object
      description: Table configuration for one-stop creation (with nested fields)
      properties:
        name:
          type: string
          description: Table name
          example: Detail Table
          maxLength: 50
        prompt:
          type: string
          description: Table semantic extraction prompt
          maxLength: 200
        collect_from_multi_table:
          type: boolean
          description: Merge multiple tables
        extract_model:
          type: string
          description: Table-level extraction model
          enum:
            - Auto
            - Acgpt
            - Acgpt-VL
            - DF-M1
        fields:
          type: array
          description: Nested field list within the table
          items:
            $ref: '#/components/schemas/CategoryFieldConfig'
      required:
        - name
    CodeMessage:
      type: object
      properties:
        code:
          type: integer
          description: Status code
          example: 200
        msg:
          type: string
          description: Status description
      required:
        - code
        - msg
    CategoryField:
      allOf:
        - $ref: '#/components/schemas/CategoryFieldConfig'
        - type: object
          properties:
            id:
              type: string
              description: Field ID
              example: '1234567890'
            enabled:
              $ref: '#/components/schemas/EnabledStatus'
            extract_model:
              type: string
              description: >
                Field extraction model

                - Auto: Automatically matches the extraction model

                - Acgpt: Fast speed with stable extraction results

                - Acgpt-VL: VLM, suitable for simple extraction (≤10 pages)

                - DF-M1: Suitable for complex document understanding

                - For table fields, inherits from the table model; for regular
                fields, uses field-level config; legacy data inferred from
                category config
              example: Acgpt
    CategoryTable:
      type: object
      properties:
        id:
          type: string
          description: Table ID
          example: '1234567890'
        name:
          type: string
          description: Table name
          example: Table 1
        description:
          type: string
          description: Table description
          example: Table description
        prompt:
          type: string
          description: Table semantic extraction prompt
          example: Extract item name, quantity and amount from each row
        collect_from_multi_table:
          type: boolean
          description: Merge multiple tables
          example: true
        extract_model:
          type: string
          description: Table-level extraction model (Auto/Acgpt/Acgpt-VL/DF-M1)
          example: Acgpt
        fields:
          type: array
          items:
            $ref: '#/components/schemas/CategoryField'
    CategorySample:
      type: object
      description: File category sample
      properties:
        sample_id:
          type: string
          description: Sample ID
          example: '1234567890'
        file_name:
          type: string
          description: File name
          example: invoice_sample.pdf
      required:
        - sample_id
        - file_name
    TransformSettings:
      type: object
      description: >-
        Field output transform configuration. Formats the extraction result
        before output.
      properties:
        type:
          type: string
          description: >
            Transform type, determines which transform rule to apply:

            - `datetime`: Normalize the extraction result to a specified date
            format

            - `enumerate`: Restrict the extraction result to one of the preset
            enumeration values

            - `regex`: Match and replace the extraction result using regular
            expressions
          enum:
            - datetime
            - enumerate
            - regex
        datetime_settings:
          type: object
          description: Datetime formatting configuration. Required when type=datetime.
          properties:
            format:
              type: string
              description: >-
                Target date format. The extraction result will be normalized to
                this format.
              example: yyyy-MM-dd
        enumerate_settings:
          type: object
          description: Enumeration constraint configuration. Required when type=enumerate.
          properties:
            items:
              type: array
              description: >-
                Allowed enumeration values. If the extraction result is not in
                this list, mismatch_action applies.
              items:
                type: string
              example:
                - VAT Special Invoice
                - VAT General Invoice
                - Electronic Invoice
        regex_settings:
          type: object
          description: Regex transform configuration. Required when type=regex.
          properties:
            match:
              type: string
              description: Regex pattern for matching or capturing the extraction result
              example: ^(\d{4})-(\d{2})-(\d{2})$
            replace:
              type: string
              description: Replacement expression, supports $1, $2 capture group references
              example: $1/$2/$3
        mismatch_action:
          type: object
          description: >-
            How to handle extraction results that don't match the transform rule
            (applies to all types, optional).
          properties:
            mode:
              type: string
              description: >
                Handling mode:

                - `default`: Output the specified default value (requires
                default_value)

                - `warning`: Keep the original extraction result, flag a warning
                for manual review
              enum:
                - default
                - warning
            default_value:
              type: string
              description: Output value when mode=default
              example: N/A
    EnabledStatus:
      type: integer
      description: |
        Enabled status
        - 0: Disabled
        - 1: Enabled
        - 2: Draft
      enum:
        - 0
        - 1
        - 2
  securitySchemes:
    ApiId:
      type: apiKey
      in: header
      name: x-ti-app-id
    SecretCode:
      type: apiKey
      in: header
      name: x-ti-secret-code

````