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

# Update Document by File

> Deprecated. Use [Update Document](/en/api-reference/documents/update-document) instead. Updates an existing document by uploading a new file and re-triggers indexing.



## OpenAPI

````yaml /en/api-reference/openapi_service.json post /datasets/{dataset_id}/documents/{document_id}/update-by-file
openapi: 3.0.1
info:
  title: Dify Service API
  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.
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: >-
      Base URL of the Dify Service API. For self-hosted deployments, replace it
      with your own 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:
  - name: Chat Messages
    description: Operations related to chat messages and interactions.
  - name: Files
    description: File upload and preview operations.
  - name: End Users
    description: Operations related to end user information.
  - name: Feedback
    description: User feedback operations.
  - name: Conversations
    description: Operations related to managing conversations.
  - name: Audio
    description: Text-to-Speech and Speech-to-Text operations.
  - name: Applications
    description: Operations to retrieve application settings and information.
  - name: Annotations
    description: Operations related to managing annotations for direct replies.
  - name: Human Input
    description: Endpoints for resuming paused workflows that require human input.
  - name: Workflow Runs
    description: Operations for executing and managing workflows.
  - name: Completion Messages
    description: Operations related to text generation and completion.
  - name: Knowledge Bases
    description: >-
      Operations for managing knowledge bases, including creation,
      configuration, and retrieval.
  - name: Documents
    description: >-
      Operations for creating, updating, and managing documents within a
      knowledge base.
  - name: Chunks
    description: Operations for managing document chunks and child chunks.
  - name: Metadata
    description: >-
      Operations for managing knowledge base metadata fields and document
      metadata values.
  - name: Tags
    description: Operations for managing knowledge base tags and tag bindings.
  - name: Models
    description: Operations for retrieving available models.
  - name: Knowledge Pipeline
    description: >-
      Operations for managing and running knowledge pipelines, including
      datasource plugins and pipeline execution.
paths:
  /datasets/{dataset_id}/documents/{document_id}/update-by-file:
    post:
      tags:
        - Documents
      summary: Update Document by File
      description: >-
        Deprecated. Use [Update
        Document](/en/api-reference/documents/update-document) instead. Updates
        an existing document by uploading a new file and re-triggers indexing.
      operationId: updateDocumentByFile
      parameters:
        - name: dataset_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Knowledge base ID.
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Document ID.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: File to upload.
                data:
                  type: string
                  description: >-
                    JSON string containing configuration. Accepts the same
                    fields as [Create Document by
                    Text](/en/api-reference/documents/create-document-by-text)
                    (`indexing_technique`, `doc_form`, `doc_language`,
                    `process_rule`, `retrieval_model`, `embedding_model`,
                    `embedding_model_provider`) except `name` and `text`.
                  example: >-
                    {"indexing_technique":"high_quality","doc_form":"text_model","doc_language":"English","process_rule":{"mode":"automatic"}}
      responses:
        '200':
          description: Document updated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  document:
                    $ref: '#/components/schemas/Document'
                  batch:
                    type: string
                    description: Batch ID for tracking indexing progress.
              examples:
                success:
                  summary: Response Example
                  value:
                    document:
                      id: a8e0e5b5-78c6-4130-a5ce-25feb0e0b4ac
                      position: 1
                      data_source_type: upload_file
                      data_source_info:
                        upload_file_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                      data_source_detail_dict:
                        upload_file:
                          id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                          name: guide.txt
                          size: 2048
                          extension: txt
                          mime_type: text/plain
                          created_by: ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4
                          created_at: 1741267200
                      dataset_process_rule_id: e1f2a3b4-c5d6-7890-ef12-345678901234
                      name: guide.txt
                      created_from: api
                      created_by: ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4
                      created_at: 1741267200
                      tokens: 512
                      indexing_status: completed
                      error: null
                      enabled: true
                      disabled_at: null
                      disabled_by: null
                      archived: false
                      display_status: available
                      word_count: 350
                      hit_count: 0
                      doc_form: text_model
                      doc_metadata: []
                      summary_index_status: null
                      need_summary: false
                    batch: '20250306150245647595'
        '400':
          description: >-
            - `too_many_files` : Only one file is allowed.

            - `filename_not_exists_error` : The specified filename does not
            exist.

            - `provider_not_initialize` : No valid model provider credentials
            found. Please go to Settings -> Model Provider to complete your
            provider credentials.

            - `invalid_param` : The document is not available for update (only
            available documents can be updated).
          content:
            application/json:
              examples:
                too_many_files:
                  summary: too_many_files
                  value:
                    status: 400
                    code: too_many_files
                    message: Only one file is allowed.
                filename_not_exists_error:
                  summary: filename_not_exists_error
                  value:
                    status: 400
                    code: filename_not_exists_error
                    message: The specified filename does not exist.
                provider_not_initialize:
                  summary: provider_not_initialize
                  value:
                    status: 400
                    code: provider_not_initialize
                    message: >-
                      No valid model provider credentials found. Please go to
                      Settings -> Model Provider to complete your provider
                      credentials.
                invalid_param_not_available:
                  summary: invalid_param (not available)
                  value:
                    status: 400
                    code: invalid_param
                    message: Document is not available
        '403':
          description: >-
            - `forbidden` : Dataset api access is not enabled.

            - `forbidden` : The capacity of the vector space has reached the
            limit of your subscription.

            - `forbidden` : Sorry, you have reached the knowledge base request
            rate limit of your subscription.
          content:
            application/json:
              examples:
                forbidden_1:
                  summary: forbidden (api access)
                  value:
                    status: 403
                    code: forbidden
                    message: Dataset api access is not enabled.
                forbidden_2:
                  summary: forbidden (vector space)
                  value:
                    status: 403
                    code: forbidden
                    message: >-
                      The capacity of the vector space has reached the limit of
                      your subscription.
                forbidden_3:
                  summary: forbidden (rate limit)
                  value:
                    status: 403
                    code: forbidden
                    message: >-
                      Sorry, you have reached the knowledge base request rate
                      limit of your subscription.
        '404':
          description: |-
            - `not_found` : Dataset not found.
            - `not_found` : Document not found.
          content:
            application/json:
              examples:
                not_found_1:
                  summary: not_found
                  value:
                    status: 404
                    code: not_found
                    message: Dataset not found.
                not_found_2:
                  summary: not_found
                  value:
                    status: 404
                    code: not_found
                    message: Document not found.
        '413':
          description: '`file_too_large` : File size exceeded.'
          content:
            application/json:
              examples:
                file_too_large:
                  summary: file_too_large
                  value:
                    status: 413
                    code: file_too_large
                    message: File size exceeded.
        '415':
          description: '`unsupported_file_type` : File type not allowed.'
          content:
            application/json:
              examples:
                unsupported_file_type:
                  summary: unsupported_file_type
                  value:
                    status: 415
                    code: unsupported_file_type
                    message: File type not allowed.
      deprecated: true
components:
  schemas:
    Document:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier of the document.
        position:
          type: integer
          description: Display position of the document in the list.
        data_source_type:
          type: string
          description: >-
            How the document was created. `upload_file` for file uploads,
            `notion_import` for Notion imports.
        data_source_info:
          type: object
          description: Raw data source information, varies by `data_source_type`.
        data_source_detail_dict:
          type: object
          description: Detailed data source information including file details.
        dataset_process_rule_id:
          type: string
          description: ID of the processing rule applied to this document.
        name:
          type: string
          description: Document name.
        created_from:
          type: string
          description: >-
            Origin of the document. `api` for API creation, `web` for UI
            creation.
        created_by:
          type: string
          description: ID of the user who created the document.
        created_at:
          type: number
          description: Creation timestamp (Unix epoch in seconds).
        tokens:
          type: integer
          description: Total number of tokens in the document.
        indexing_status:
          type: string
          description: >-
            Current indexing status. `waiting` for queued, `parsing` while
            extracting content, `cleaning` while removing noise, `splitting`
            while chunking, `indexing` while building vectors, `completed` when
            ready, `error` if failed, `paused` if manually paused.
        error:
          type: string
          nullable: true
          description: Error message if indexing failed. `null` when no error.
        enabled:
          type: boolean
          description: Whether the document is enabled for retrieval.
        disabled_at:
          type: number
          nullable: true
          description: Timestamp when the document was disabled. `null` if enabled.
        disabled_by:
          type: string
          nullable: true
          description: ID of the user who disabled the document. `null` if enabled.
        archived:
          type: boolean
          description: Whether the document is archived.
        display_status:
          type: string
          description: >-
            User-facing display status derived from `indexing_status` and
            `enabled` state.
        word_count:
          type: integer
          description: Total word count of the document.
        hit_count:
          type: integer
          description: Number of times the document has been matched in retrieval queries.
        doc_form:
          type: string
          description: >-
            Document chunking mode. `text_model` for standard text chunking,
            `hierarchical_model` for parent-child structure, `qa_model` for QA
            pair extraction.
        doc_metadata:
          type: array
          description: Metadata values assigned to this document.
          items:
            type: object
            properties:
              id:
                type: string
                description: Metadata field identifier.
              name:
                type: string
                description: Metadata field name.
              type:
                type: string
                description: Metadata field value type.
              value:
                type: string
                description: Metadata value for this document.
        summary_index_status:
          type: string
          nullable: true
          description: >-
            Status of the summary index for this document. `null` if summary
            indexing is not configured.
        need_summary:
          type: boolean
          description: Whether a summary needs to be generated for this document.
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key authentication. For all API requests, include your API Key in
        the `Authorization` HTTP Header, prefixed with `Bearer `. Example:
        `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API
        Key on the server-side, not shared or stored on the client-side, to
        avoid possible API-Key leakage that can lead to serious consequences.**
        Requests with a missing or invalid API key fail with HTTP `401` and
        error code `unauthorized`.

````