> ## 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.

# ファイルでドキュメントを更新

> 新しいファイルをアップロードして既存のドキュメントを更新します。インデックスが再トリガーされます——返された `batch` ID を [ドキュメント埋め込みステータス（進捗）を取得](/api-reference/ドキュメント/ドキュメント埋め込みステータス（進捗）を取得) で使用して進捗を追跡します。



## OpenAPI

````yaml /ja/api-reference/openapi_knowledge.json post /datasets/{dataset_id}/documents/{document_id}/update-by-file
openapi: 3.0.1
info:
  title: ナレッジAPI
  description: >-
    ナレッジベース、ドキュメント、チャンク、メタデータ、タグの管理（作成、取得、設定を含む）のための API です。**注意：**単一のナレッジベース
    API キーは、同じアカウント配下のすべての可視ナレッジベースを操作する権限を持ちます。データセキュリティにご注意ください。
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: Knowledge API のベース URL です。セルフホスト環境では、独自の API ベース URL に置き換えてください。
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: API ベース URL のホストとパス（`https://` を除く）。
security:
  - ApiKeyAuth: []
tags:
  - name: データセット
    description: ナレッジベースの作成、設定、取得を含むナレッジベース管理の操作です。
  - name: ドキュメント
    description: ナレッジベース内のドキュメントの作成、更新、管理のための操作です。
  - name: チャンク
    description: ドキュメントチャンクと子チャンクの管理のための操作です。
  - name: メタデータ
    description: ナレッジベースのメタデータフィールドとドキュメントメタデータ値の管理のための操作です。
  - name: タグ管理
    description: ナレッジベースタグとタグバインディングの管理のための操作です。
  - name: モデル
    description: 利用可能なモデルを取得するための操作です。
  - name: ナレッジパイプライン
    description: データソースプラグインとパイプライン実行を含むナレッジパイプラインの管理と実行のための操作です。
paths:
  /datasets/{dataset_id}/documents/{document_id}/update-by-file:
    post:
      tags:
        - ドキュメント
      summary: ファイルでドキュメントを更新
      description: >-
        新しいファイルをアップロードして既存のドキュメントを更新します。インデックスが再トリガーされます——返された `batch` ID を
        [ドキュメント埋め込みステータス（進捗）を取得](/api-reference/ドキュメント/ドキュメント埋め込みステータス（進捗）を取得)
        で使用して進捗を追跡します。
      operationId: updateDocumentByFile
      parameters:
        - name: dataset_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: ナレッジベース 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: アップロードするファイルです。
                data:
                  type: string
                  description: >-
                    設定情報を含む JSON
                    文字列です。[テキストからドキュメントを作成](/api-reference/ドキュメント/テキストからドキュメントを作成)
                    と同じフィールド（`indexing_technique`、`doc_form`、`doc_language`、`process_rule`、`retrieval_model`、`embedding_model`、`embedding_model_provider`）を受け付けますが、`name`
                    と `text` は除きます。
                  example: >-
                    {"indexing_technique":"high_quality","doc_form":"text_model","doc_language":"English","process_rule":{"mode":"automatic"}}
      responses:
        '200':
          description: ドキュメントが正常に更新されました。
          content:
            application/json:
              schema:
                type: object
                properties:
                  document:
                    $ref: '#/components/schemas/Document'
                  batch:
                    type: string
                    description: インデックス進捗を追跡するためのバッチ ID です。
              examples:
                success:
                  summary: レスポンス例
                  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` : ファイルは 1 つのみ許可されています。

            - `filename_not_exists_error` : 指定されたファイル名が存在しません。

            - `provider_not_initialize` : 有効なモデルプロバイダーの認証情報が見つかりません。設定 →
            モデルプロバイダーで認証情報を完了してください。

            - `invalid_param` :
            ナレッジベースが存在しない、外部データセットは非対応、ファイルが大きすぎる、サポートされていないファイルタイプ、または doc_form
            が無効です（`text_model`、`hierarchical_model`、または `qa_model`
            のいずれかである必要があります）。
          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_dataset:
                  summary: invalid_param (dataset)
                  value:
                    status: 400
                    code: invalid_param
                    message: Dataset does not exist.
                invalid_param_external:
                  summary: invalid_param (external)
                  value:
                    status: 400
                    code: invalid_param
                    message: External datasets are not supported.
                invalid_param_file_too_large:
                  summary: invalid_param (file_too_large)
                  value:
                    status: 400
                    code: invalid_param
                    message: File size exceeded.
                invalid_param_unsupported_file_type:
                  summary: invalid_param (unsupported_file_type)
                  value:
                    status: 400
                    code: invalid_param
                    message: File type not allowed.
components:
  schemas:
    Document:
      type: object
      properties:
        id:
          type: string
          description: ドキュメントの一意識別子です。
        position:
          type: integer
          description: リスト内のドキュメントの表示位置です。
        data_source_type:
          type: string
          description: >-
            ドキュメントの作成方法です。ファイルアップロードの場合は `upload_file`、Notion インポートの場合は
            `notion_import` です。
        data_source_info:
          type: object
          description: 生のデータソース情報です。`data_source_type` によって異なります。
        data_source_detail_dict:
          type: object
          description: ファイル詳細を含む詳細なデータソース情報です。
        dataset_process_rule_id:
          type: string
          description: このドキュメントに適用された処理ルールの ID です。
        name:
          type: string
          description: ドキュメント名です。
        created_from:
          type: string
          description: ドキュメントの作成元です。API で作成した場合は `api`、UI で作成した場合は `web` です。
        created_by:
          type: string
          description: ドキュメントを作成したユーザーの ID です。
        created_at:
          type: number
          description: 作成タイムスタンプ（Unix エポック、秒単位）です。
        tokens:
          type: integer
          description: ドキュメント内の合計トークン数です。
        indexing_status:
          type: string
          description: >-
            現在のインデックスステータスです。`waiting` はキュー待ち、`parsing` はコンテンツ抽出中、`cleaning`
            はノイズ除去中、`splitting` はチャンキング中、`indexing` はベクトル構築中、`completed`
            は準備完了、`error` は失敗、`paused` は手動一時停止を示します。
        error:
          type: string
          nullable: true
          description: インデックス作成が失敗した場合のエラーメッセージです。エラーなしの場合は `null` です。
        enabled:
          type: boolean
          description: このドキュメントが検索に対して有効かどうかです。
        disabled_at:
          type: number
          nullable: true
          description: ドキュメントが無効化されたタイムスタンプです。有効な場合は `null` です。
        disabled_by:
          type: string
          nullable: true
          description: ドキュメントを無効化したユーザーの ID です。有効な場合は `null` です。
        archived:
          type: boolean
          description: ドキュメントがアーカイブ済みかどうかです。
        display_status:
          type: string
          description: '`indexing_status` と `enabled` 状態から導出されたユーザー向け表示ステータスです。'
        word_count:
          type: integer
          description: ドキュメントの合計単語数です。
        hit_count:
          type: integer
          description: ドキュメントが検索クエリでマッチした回数です。
        doc_form:
          type: string
          description: >-
            ドキュメントのチャンキングモードです。`text_model` は標準テキストチャンキング、`hierarchical_model`
            は親子構造、`qa_model` は QA ペア抽出を示します。
        doc_metadata:
          type: array
          description: このドキュメントに割り当てられたメタデータ値です。
          items:
            type: object
            properties:
              id:
                type: string
                description: メタデータフィールドの識別子です。
              name:
                type: string
                description: メタデータフィールド名です。
              type:
                type: string
                description: メタデータフィールドの値の種類です。
              value:
                type: string
                description: このドキュメントのメタデータ値。
        summary_index_status:
          type: string
          nullable: true
          description: このドキュメントの要約インデックスのステータスです。要約インデックスが設定されていない場合は `null` です。
        need_summary:
          type: boolean
          description: このドキュメントに要約を生成する必要があるかどうかです。
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key 認証です。すべての API リクエストにおいて、`Authorization` HTTP ヘッダーに `Bearer `
        プレフィックスを付けた API Key を含めてください。例：`Authorization: Bearer {API_KEY}`。**API
        Key はサーバーサイドに保存し、クライアントサイドで共有・保存しないことを強く推奨します。API Key
        の漏洩は深刻な結果につながる可能性があります。**

````