> ## Documentation Index
> Fetch the complete documentation index at: https://developer.duplik.cn/llms.txt
> Use this file to discover all available pages before exploring further.

> Update a document's metadata and rebuild its retrieval tags

# Update Knowledge Document Metadata



## OpenAPI

````yaml put /v1/knowledge/{knowledge_id}/document/{document_id}/metadata
openapi: 3.1.0
info:
  title: spectra-server
  description: The API for Spectra Backend.
  version: 0.1.0
servers:
  - url: https://api-spectra.duplik.cn
security: []
paths:
  /v1/knowledge/{knowledge_id}/document/{document_id}/metadata:
    put:
      tags:
        - Knowledge
      summary: Update Knowledge Document Metadata
      description: >-
        Update a document's `metadata_info` in place. The body is merged into
        the existing metadata: fields you pass are overwritten, fields you leave
        out keep their current value.


        Two things this call does beyond storing the fields. Passing `title`
        **also renames the document** — `name` becomes that title, and the
        original file name is not kept; omit `title` and `name` is untouched.
        And the document's tags are rebuilt from the resulting metadata, which
        is what `entity_names` pre-filtering reads, so writing `entity_names` as
        `"key:value"` (for example `["model:SY500"]`) makes a retrieval request
        carrying the same values hard-filter to this document.


        Passing `pdf_parsing_mode` or `audio_parsing_mode` with a value
        different from the current one re-triggers parsing of the document. The
        metadata is also re-synced to the search index.


        `null` values are dropped before the merge, so a field cannot be cleared
        through this endpoint. The document must belong to the knowledge base in
        the path.
      operationId: >-
        update_knowledge_document_metadata_v1_knowledge__knowledge_id__document__document_id__metadata_put
      parameters:
        - name: knowledge_id
          in: path
          required: true
          schema:
            type: string
            title: Knowledge Id
            description: Knowledge base ID
          description: Knowledge base ID
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            title: Document Id
            description: Document to update
          description: Document to update
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DocumentMetadataInfoUpdate'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - HTTPBearer: []
components:
  schemas:
    DocumentMetadataInfoUpdate:
      properties:
        title:
          anyOf:
            - type: string
            - type: 'null'
          title: Title
          description: Document title. Passing it also renames the document
        entity_names:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Entity Names
          description: >-
            Tags. Values written as "key:value" drive metadata pre-filtering at
            retrieval time
        published_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Published At
        content_at:
          anyOf:
            - type: integer
            - type: 'null'
          title: Content At
        time_periods:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Time Periods
        summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary
        external_user:
          anyOf:
            - type: string
            - type: 'null'
          title: External User
        document_scope:
          anyOf:
            - type: integer
            - type: 'null'
          title: Document Scope
          description: Visibility scope of the document
        language:
          anyOf:
            - type: string
            - type: 'null'
          title: Language
        custom_data:
          anyOf:
            - type: object
            - type: 'null'
          title: Custom Data
          description: >-
            Free-form key-values. Stored, indexed and returned, but never used
            for filtering. Replaced as a whole, not deep merged
        pdf_parsing_mode:
          anyOf:
            - type: integer
              enum:
                - 1
                - 2
                - 3
            - type: 'null'
          title: Pdf Parsing Mode
          description: >-
            Changing it re-triggers parsing. 1: page, 2: section (recommended),
            3: section v2
        audio_parsing_mode:
          anyOf:
            - type: integer
              enum:
                - 1
                - 2
            - type: 'null'
          title: Audio Parsing Mode
          description: >-
            Changing it re-triggers parsing. 1: transcript, 2: speaker
            diarization
      type: object
      title: DocumentMetadataInfoUpdate
    Document:
      properties:
        created_at:
          type: integer
          title: Created At
        updated_at:
          type: integer
          title: Updated At
        org_id:
          type: string
          maxLength: 20
          title: Org Id
        user_id:
          type: string
          maxLength: 20
          title: User Id
        overall_summarize_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Overall Summarize Enabled
          description: Generate an overall summary. Boolean
          default: true
        smart_indexing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Smart Indexing Mode
          description: >-
            Smart indexing mode. 0: disabled (recommended), 1: standard, 2:
            advanced
          default: 0
        smart_indexing_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Smart Indexing Enabled
          description: >-
            Enable smart indexing. Boolean. Takes effect only together with
            smart_indexing_mode 2 (advanced); leaving it false is recommended
            unless the corpus needs it, as it adds noticeable processing time
            and token cost
          default: true
        split_media_enabled:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Split Media Enabled
          description: Generate media segments. Boolean
          default: true
        pdf_parsing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Pdf Parsing Mode
          description: 'PDF parsing mode. 1: page, 2: section (recommended), 3: section v2'
          default: 2
        pdf_parsing_element_types:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Pdf Parsing Element Types
          description: 'pdf parsing element list, eg: [1, 2]. 1: table, 2: image, 3: formula'
          default:
            - 1
            - 2
        read_pdf_pages:
          anyOf:
            - type: string
            - type: 'null'
          title: Read Pdf Pages
          description: 'read pdf pages, Example: ''1,3,4'' or ''1,4-end'' or ''all'''
        audio_parsing_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Audio Parsing Mode
          description: 'audio parsing mode, 1: transcript, 2: speaker diarization'
        audio_chunk_mode:
          anyOf:
            - type: integer
            - type: 'null'
          title: Audio Chunk Mode
          default: 1
        dataset_id:
          type: string
          title: Dataset Id
        file_id:
          type: string
          title: File Id
        name:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Name
        document_type:
          anyOf:
            - type: integer
            - type: 'null'
          title: Document Type
          default: 1
        next_step:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Next Step
          description: next step
          default: true
        llm:
          anyOf:
            - type: object
            - type: 'null'
          title: Llm
          default: {}
        metadata_info:
          type: object
          title: Metadata Info
          default: {}
        task_priority:
          anyOf:
            - type: integer
            - type: 'null'
          title: Task Priority
          description: task priority
        description:
          anyOf:
            - type: string
              maxLength: 512
            - type: 'null'
          title: Description
          default: ''
        summary:
          anyOf:
            - type: string
            - type: 'null'
          title: Summary
          default: ''
        step_status:
          anyOf:
            - type: integer
            - type: 'null'
          title: Step Status
          default: 100
        status:
          anyOf:
            - type: integer
            - type: 'null'
          title: Status
          default: 1
        process_status:
          anyOf:
            - type: integer
            - type: 'null'
          title: Process Status
          default: 100
        version:
          anyOf:
            - type: integer
            - type: 'null'
          title: Version
          default: 2
        splitter_type:
          anyOf:
            - type: integer
            - type: 'null'
          title: Splitter Type
          default: 1
        splitter:
          type: object
          title: Splitter
          default: {}
        sections:
          items:
            type: object
          type: array
          title: Sections
          default: []
        content_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Content Text
          description: ''
        trim_text:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Trim Text
          description: ''
          default: true
        document_id:
          type: string
          title: Document Id
      type: object
      required:
        - org_id
        - user_id
        - dataset_id
        - file_id
        - document_id
      title: Document
    ErrorResponse:
      properties:
        code:
          type: integer
          title: Code
        message:
          type: string
          title: Message
      type: object
      required:
        - code
        - message
      title: ErrorResponse
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````