> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-fix-template-upload-size-guidance.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Document Metadata in Batch

> Update metadata values for multiple documents in a single request.



## OpenAPI

````yaml /en/api-reference/openapi_service.json post /datasets/{dataset_id}/documents/metadata
openapi: 3.0.1
info:
  description: >-
    REST API for Dify applications and knowledge bases. Application endpoints
    authenticate with an app API key; knowledge endpoints authenticate with a
    dataset API key.
  title: Dify Service API
  version: 1.0.0
servers:
  - description: >-
      Base URL of the Dify Service API. For self-hosted deployments, replace it
      with your own API base URL.
    url: https://{api_base_url}
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: Host and path of the API base URL, without the `https://` prefix.
security:
  - ApiKeyAuth: []
tags:
  - description: Operations related to chat messages and interactions.
    name: Chat Messages
  - description: File upload and preview operations.
    name: Files
  - description: Operations related to end user information.
    name: End Users
  - description: User feedback operations.
    name: Feedback
  - description: Operations related to managing conversations.
    name: Conversations
  - description: Text-to-Speech and Speech-to-Text operations.
    name: Audio
  - description: Operations to retrieve application settings and information.
    name: Applications
  - description: Operations related to managing annotations for direct replies.
    name: Annotations
  - description: Endpoints for resuming paused workflows that require human input.
    name: Human Input
  - description: Operations for executing and managing workflows.
    name: Workflow Runs
  - description: Operations related to text generation and completion.
    name: Completion Messages
  - description: >-
      Operations for managing knowledge bases, including creation,
      configuration, and retrieval.
    name: Knowledge Bases
  - description: >-
      Operations for creating, updating, and managing documents within a
      knowledge base.
    name: Documents
  - description: Operations for managing document chunks and child chunks.
    name: Chunks
  - description: >-
      Operations for managing knowledge base metadata fields and document
      metadata values.
    name: Metadata
  - description: Operations for managing knowledge base tags and tag bindings.
    name: Tags
  - description: Operations for retrieving available models.
    name: Models
  - description: >-
      Operations for managing and running knowledge pipelines, including
      datasource plugins and pipeline execution.
    name: Knowledge Pipeline
paths:
  /datasets/{dataset_id}/documents/metadata:
    post:
      tags:
        - Metadata
      summary: Update Document Metadata in Batch
      description: Update metadata values for multiple documents in a single request.
      operationId: batchUpdateDocumentMetadata
      parameters:
        - description: >-
            Knowledge base ID. See [List Knowledge
            Bases](/en/api-reference/knowledge-bases/list-knowledge-bases).
          in: path
          name: dataset_id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                operation_data:
                  description: Document metadata update operations, one entry per document.
                  items:
                    properties:
                      document_id:
                        description: >-
                          ID of the document to update. See [List
                          Documents](/en/api-reference/documents/list-documents).
                        type: string
                      metadata_list:
                        description: Metadata fields to set on the document.
                        items:
                          properties:
                            id:
                              description: >-
                                Metadata field ID. See [List Metadata
                                Fields](/en/api-reference/metadata/list-metadata-fields).
                              type: string
                            name:
                              description: Metadata field name.
                              type: string
                            value:
                              description: >-
                                Metadata value. Can be a string, number, or
                                `null`.
                          required:
                            - id
                            - name
                          type: object
                        type: array
                      partial_update:
                        default: false
                        description: >-
                          Whether to partially update metadata, keeping existing
                          values for unspecified fields.
                        type: boolean
                    required:
                      - document_id
                      - metadata_list
                    type: object
                  type: array
              required:
                - operation_data
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                success:
                  summary: Response Example
                  value:
                    result: success
              schema:
                properties:
                  result:
                    description: Operation result.
                    type: string
                type: object
          description: Document metadata updated successfully.
        '400':
          content:
            application/json:
              examples:
                invalid_param:
                  summary: invalid_param
                  value:
                    code: invalid_param
                    message: >-
                      Another document metadata operation is running, please
                      wait a moment.
                    status: 400
          description: >-
            `invalid_param` : Another metadata operation is already running for
            a document in this request.
        '403':
          content:
            application/json:
              examples:
                forbidden_1:
                  summary: forbidden (api access)
                  value:
                    code: forbidden
                    message: Dataset api access is not enabled.
                    status: 403
                forbidden_2:
                  summary: forbidden (rate limit)
                  value:
                    code: forbidden
                    message: >-
                      Sorry, you have reached the knowledge base request rate
                      limit of your subscription.
                    status: 403
          description: >-
            - `forbidden` : Dataset api access is not enabled.

            - `forbidden` : Sorry, you have reached the knowledge base request
            rate limit of your subscription.
        '404':
          content:
            application/json:
              examples:
                not_found_1:
                  summary: not_found (knowledge base)
                  value:
                    code: not_found
                    message: Dataset not found.
                    status: 404
                not_found_2:
                  summary: not_found (document)
                  value:
                    code: not_found
                    message: Document not found.
                    status: 404
                not_found_3:
                  summary: not_found (metadata)
                  value:
                    code: not_found
                    message: Metadata not found.
                    status: 404
          description: >-
            - `not_found` : Knowledge base not found.

            - `not_found` : A document referenced in `operation_data` does not
            exist in this knowledge base.

            - `not_found` : A metadata field referenced in `metadata_list` does
            not exist in this knowledge base.
components:
  securitySchemes:
    ApiKeyAuth:
      bearerFormat: API_KEY
      description: >-
        Every request authenticates with an API key: `Authorization: Bearer
        {API_KEY}`. App endpoints take an app API key; knowledge endpoints take
        a knowledge base API key ([Get
        Started](/en/api-reference/guides/get-started)).


        Keep keys server-side; never embed them in client code. Requests with a
        missing or invalid key fail with HTTP `401` (`unauthorized`).
      scheme: bearer
      type: http

````