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

# ドキュメントを更新

> 新しいファイルをアップロードしてドキュメントを更新し、再インデックスします。これはファイルベースのドキュメント更新の正規エンドポイントです。返された `batch` ID を使って [ドキュメント埋め込みステータス（進捗）を取得](/ja/api-reference/documents/get-document-indexing-status) で進捗を追跡します。



## OpenAPI

````yaml /ja/api-reference/openapi_service.json patch /datasets/{dataset_id}/documents/{document_id}
openapi: 3.0.1
info:
  description: >-
    Dify アプリケーションとナレッジベースのための REST API です。アプリケーション系エンドポイントはアプリの API
    キーで、ナレッジ系エンドポイントはナレッジベースの API キーで認証します。
  title: Dify サービス API
  version: 1.0.0
servers:
  - description: Dify サービス API のベース URL です。セルフホスト環境では、独自の API ベース URL に置き換えてください。
    url: https://{api_base_url}
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: API ベース URL のホストとパス（`https://` を除く）。
security:
  - ApiKeyAuth: []
tags:
  - description: チャットメッセージとインタラクションに関連する操作です。
    name: チャットメッセージ
  - description: ファイルのアップロードとプレビューの操作です。
    name: ファイル操作
  - description: エンドユーザー情報に関連する操作です。
    name: エンドユーザー
  - description: ユーザーフィードバックの操作です。
    name: メッセージフィードバック
  - description: 会話管理に関連する操作です。
    name: 会話管理
  - description: テキスト読み上げと音声認識の操作です。
    name: 音声・テキスト変換
  - description: アプリケーション設定と情報を取得する操作です。
    name: アプリケーション設定
  - description: ダイレクト返信用のアノテーション管理に関連する操作です。
    name: アノテーション管理
  - description: 人間の入力を要する一時停止中のワークフローの再開操作です。
    name: 人間の入力
  - description: ワークフローの実行と管理のための操作です。
    name: ワークフロー実行
  - description: テキスト生成に関連する操作です。
    name: 完了メッセージ
  - description: ナレッジベースの作成、設定、取得を含むナレッジベース管理の操作です。
    name: ナレッジベース
  - description: ナレッジベース内のドキュメントの作成、更新、管理のための操作です。
    name: ドキュメント
  - description: ドキュメントチャンクと子チャンクの管理のための操作です。
    name: チャンク
  - description: ナレッジベースのメタデータフィールドとドキュメントメタデータ値の管理のための操作です。
    name: メタデータ
  - description: ナレッジベースタグとタグバインディングの管理のための操作です。
    name: タグ管理
  - description: 利用可能なモデルを取得するための操作です。
    name: モデル
  - description: データソースプラグインとパイプライン実行を含むナレッジパイプラインの管理と実行のための操作です。
    name: ナレッジパイプライン
paths:
  /datasets/{dataset_id}/documents/{document_id}:
    patch:
      tags:
        - ドキュメント
      summary: ドキュメントを更新
      description: >-
        新しいファイルをアップロードしてドキュメントを更新し、再インデックスします。これはファイルベースのドキュメント更新の正規エンドポイントです。返された
        `batch` ID を使って
        [ドキュメント埋め込みステータス（進捗）を取得](/ja/api-reference/documents/get-document-indexing-status)
        で進捗を追跡します。
      operationId: updateDocument
      parameters:
        - description: >-
            ナレッジベース ID
            です。[ナレッジベースリストを取得](/ja/api-reference/knowledge-bases/list-knowledge-bases)
            から取得します。
          in: path
          name: dataset_id
          required: true
          schema:
            format: uuid
            type: string
        - description: >-
            ドキュメント ID
            です。[ナレッジベースのドキュメントリストを取得](/ja/api-reference/documents/list-documents)
            から取得します。
          in: path
          name: document_id
          required: true
          schema:
            format: uuid
            type: string
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                data:
                  description: >-
                    設定情報を含む JSON
                    文字列です。[テキストからドキュメントを作成](/ja/api-reference/documents/create-document-by-text)
                    と同じフィールド（`doc_form`、`doc_language`、`process_rule`、`retrieval_model`、`embedding_model`、`embedding_model_provider`）を受け付けますが、`name`
                    と `text` は除きます。
                  example: >-
                    {"doc_form":"text_model","doc_language":"English","process_rule":{"mode":"automatic"}}
                  type: string
                file:
                  description: >-
                    アップロードするファイルです。デフォルトの上限は 15 MB です。


                    セルフホスト環境では `UPLOAD_FILE_SIZE_LIMIT`
                    [環境変数](/ja/self-host/deploy/configuration/environments)
                    で調整できます。Dify Cloud の Professional と Team プランでは上限が 50 MB
                    になります。
                  format: binary
                  type: string
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              examples:
                success:
                  summary: レスポンス例
                  value:
                    batch: '20250306150245647595'
                    document:
                      archived: false
                      created_at: 1741267200
                      created_by: ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4
                      created_from: api
                      data_source_detail_dict:
                        upload_file:
                          created_at: 1741267200
                          created_by: ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4
                          extension: txt
                          id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                          mime_type: text/plain
                          name: guide.txt
                          size: 2048
                      data_source_info:
                        upload_file_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                      data_source_type: upload_file
                      dataset_process_rule_id: e1f2a3b4-c5d6-7890-ef12-345678901234
                      disabled_at: null
                      disabled_by: null
                      display_status: available
                      doc_form: text_model
                      doc_metadata: []
                      enabled: true
                      error: null
                      hit_count: 0
                      id: a8e0e5b5-78c6-4130-a5ce-25feb0e0b4ac
                      indexing_status: completed
                      name: guide.txt
                      need_summary: false
                      position: 1
                      summary_index_status: null
                      tokens: 512
                      word_count: 350
              schema:
                properties:
                  batch:
                    description: インデックス進捗を追跡するためのバッチ ID です。
                    type: string
                  document:
                    $ref: '#/components/schemas/Document'
                type: object
          description: ドキュメントが正常に更新されました。
        '400':
          content:
            application/json:
              examples:
                filename_not_exists_error:
                  summary: filename_not_exists_error
                  value:
                    code: filename_not_exists_error
                    message: The specified filename does not exist.
                    status: 400
                invalid_param_not_available:
                  summary: invalid_param (not available)
                  value:
                    code: invalid_param
                    message: Document is not available
                    status: 400
                provider_not_initialize:
                  summary: provider_not_initialize
                  value:
                    code: provider_not_initialize
                    message: >-
                      No valid model provider credentials found. Please go to
                      Settings -> Model Provider to complete your provider
                      credentials.
                    status: 400
                too_many_files:
                  summary: too_many_files
                  value:
                    code: too_many_files
                    message: Only one file is allowed.
                    status: 400
          description: |-
            - `too_many_files` : 1 回のリクエストにつき 1 ファイルのみ許可されています。
            - `filename_not_exists_error` : アップロードされたファイルにファイル名がありません。
            - `provider_not_initialize` : ワークスペースにモデルプロバイダーの認証情報が設定されていません。
            - `invalid_param` : ドキュメントが更新できる状態ではありません（利用可能なドキュメントのみ更新できます）。
        '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 (vector space)
                  value:
                    code: forbidden
                    message: >-
                      The capacity of the vector space has reached the limit of
                      your subscription.
                    status: 403
                forbidden_3:
                  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` : このナレッジベースでは API アクセスが有効になっていません。
            - `forbidden` : ベクトル空間の容量がサブスクリプションの上限に達しました。
            - `forbidden` : サブスクリプションのナレッジベースリクエストのレート制限に達しました。
        '404':
          content:
            application/json:
              examples:
                not_found_1:
                  summary: not_found
                  value:
                    code: not_found
                    message: Dataset not found.
                    status: 404
                not_found_2:
                  summary: not_found
                  value:
                    code: not_found
                    message: Document not found.
                    status: 404
          description: |-
            - `not_found` : ナレッジベースが見つかりません。
            - `not_found` : ドキュメントが見つかりません。
        '413':
          content:
            application/json:
              examples:
                file_too_large:
                  summary: file_too_large
                  value:
                    code: file_too_large
                    message: File size exceeded.
                    status: 413
          description: '`file_too_large` : ファイルサイズが上限を超えています。'
        '415':
          content:
            application/json:
              examples:
                unsupported_file_type:
                  summary: unsupported_file_type
                  value:
                    code: unsupported_file_type
                    message: File type not allowed.
                    status: 415
          description: '`unsupported_file_type` : 許可されていないファイルタイプです。'
        '503':
          content:
            application/json:
              examples:
                service_unavailable:
                  summary: service_unavailable
                  value:
                    code: service_unavailable
                    message: >-
                      Unable to verify vector space usage right now. Please try
                      again later.
                    status: 503
          description: >-
            `service_unavailable` : ベクトル空間の使用量を現在確認できません。しばらくしてから再試行してください。Dify
            Cloud の Sandbox プランでのみ発生します。
components:
  schemas:
    Document:
      properties:
        archived:
          description: ドキュメントがアーカイブ済みかどうかです。
          type: boolean
        created_at:
          description: 作成タイムスタンプ（Unix エポック、秒単位）です。
          type: number
        created_by:
          description: ドキュメントを作成したユーザーの ID です。
          type: string
        created_from:
          description: ドキュメントの作成元です。API で作成した場合は `api`、UI で作成した場合は `web` です。
          type: string
        data_source_detail_dict:
          description: ファイル詳細を含む詳細なデータソース情報です。
          type: object
        data_source_info:
          description: 生のデータソース情報です。`data_source_type` によって異なります。
          type: object
        data_source_type:
          description: >-
            ドキュメントの作成方法です。ファイルアップロードの場合は `upload_file`、Notion インポートの場合は
            `notion_import` です。
          type: string
        dataset_process_rule_id:
          description: このドキュメントに適用された処理ルールの ID です。
          type: string
        disabled_at:
          description: ドキュメントが無効化されたタイムスタンプです。有効な場合は `null` です。
          nullable: true
          type: number
        disabled_by:
          description: ドキュメントを無効化したユーザーの ID です。有効な場合は `null` です。
          nullable: true
          type: string
        display_status:
          description: '`indexing_status` と `enabled` 状態から導出されたユーザー向け表示ステータスです。'
          type: string
        doc_form:
          description: >-
            ドキュメントのチャンキングモードです。`text_model` は標準テキストチャンキング、`hierarchical_model`
            は親子構造、`qa_model` は QA ペア抽出を示します。
          type: string
        doc_metadata:
          description: このドキュメントに割り当てられたメタデータ値です。
          items:
            properties:
              id:
                description: メタデータフィールドの識別子です。
                type: string
              name:
                description: メタデータフィールド名です。
                type: string
              type:
                description: メタデータフィールドの値の種類です。
                type: string
              value:
                description: このドキュメントのメタデータ値。
                type: string
            type: object
          type: array
        enabled:
          description: このドキュメントが検索に対して有効かどうかです。
          type: boolean
        error:
          description: インデックス作成が失敗した場合のエラーメッセージです。エラーなしの場合は `null` です。
          nullable: true
          type: string
        hit_count:
          description: ドキュメントが検索クエリでマッチした回数です。
          type: integer
        id:
          description: ドキュメントの一意識別子です。
          type: string
        indexing_status:
          description: >-
            現在のインデックスステータスです。`waiting` はキュー待ち、`parsing` はコンテンツ抽出中、`cleaning`
            はノイズ除去中、`splitting` はチャンキング中、`indexing` はベクトル構築中、`completed`
            は準備完了、`error` は失敗、`paused` は手動一時停止を示します。
          type: string
        name:
          description: ドキュメント名です。
          type: string
        need_summary:
          description: このドキュメントに要約を生成する必要があるかどうかです。
          type: boolean
        position:
          description: リスト内のドキュメントの表示位置です。
          type: integer
        summary_index_status:
          description: このドキュメントの要約インデックスのステータスです。要約インデックスが設定されていない場合は `null` です。
          nullable: true
          type: string
        tokens:
          description: ドキュメント内の合計トークン数です。
          type: integer
        word_count:
          description: ドキュメントの合計単語数です。
          type: integer
      type: object
  securitySchemes:
    ApiKeyAuth:
      bearerFormat: API_KEY
      description: >-
        すべてのリクエストは API キーで認証します：`Authorization: Bearer
        {API_KEY}`。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API
        キーを使用します（[Dify API クイックスタート](/ja/api-reference/guides/get-started)）。


        キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP
        `401`（`unauthorized`）で失敗します。
      scheme: bearer
      type: http

````