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

# インデックスタスクを再試行

> `run_state` が `failed` または `canceled` のインデックスタスクを、同じタスク ID のまま再開し、更新後のタスクを返します。その後は、同じ ID で [インデックスタスクを取得](/ja/api-reference/indexing-tasks/get-indexing-task) をポーリングしてください。

タスクが `published` になった後でドキュメントをもう一度インデックスするには、[ドキュメントを再インデックス](/ja/api-reference/documents-and-chunks/re-index-documents) を使用します。再インデックスの流れについては、[再インデックスとインデックス処理の追跡](/ja/api-reference/guides/knowledge-base#track-indexing) を参照してください。

`run_state: superseded` の試行は、`stage` が `canceled` であっても再試行できません。再インデックスのレスポンスから新しいタスク ID を保存している場合は、そのタスクをポーリングしてください。



## OpenAPI

````yaml /ja/api-reference/openapi_service.json post /knowledge-fs/spaces/{knowledge_base_id}/jobs/{task_id}/retry
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: ナレッジパイプライン
  - description: ナレッジベースに質問し、回答をストリーミングで受け取ります。
    name: クエリ
  - description: クエリが何を検索したか、またその理由を確認します。
    name: クエリ記録
  - description: リサーチの質問をバックグラウンドで実行し、その結果を取得します。
    name: リサーチタスク
  - description: ナレッジベースのドキュメントと、そのファイル、リビジョン、チャンクを読み取り、ドキュメントにメタデータのラベルを付けます。
    name: ドキュメントとチャンク
  - description: インデックス処理の追跡、キャンセル、再試行と、ナレッジベースのバックグラウンドタスクの一覧表示を行います。
    name: インデックスタスク
  - description: ドキュメントファイル、ファイルのバッチ、またはソースの削除を、完了するまで追跡します。
    name: 削除ジョブ
  - description: ナレッジベースにデータを供給するソース、その同期スケジュール、接続を管理します。
    name: ソース
  - description: ソースの即時同期、ウェブサイトのページまたはプロバイダーのアイテムのインポート、実行の追跡、キャンセル、再試行を行います。
    name: ソースの同期とインポート
  - description: ナレッジベースのモデルと検索設定の読み取りと変更、および変更によって始まる移行の追跡を行います。
    name: 設定
paths:
  /knowledge-fs/spaces/{knowledge_base_id}/jobs/{task_id}/retry:
    post:
      tags:
        - Indexing Tasks
      summary: インデックスタスクを再試行
      description: >-
        `run_state` が `failed` または `canceled` のインデックスタスクを、同じタスク ID
        のまま再開し、更新後のタスクを返します。その後は、同じ ID で
        [インデックスタスクを取得](/ja/api-reference/indexing-tasks/get-indexing-task)
        をポーリングしてください。


        タスクが `published`
        になった後でドキュメントをもう一度インデックスするには、[ドキュメントを再インデックス](/ja/api-reference/documents-and-chunks/re-index-documents)
        を使用します。再インデックスの流れについては、[再インデックスとインデックス処理の追跡](/ja/api-reference/guides/knowledge-base#track-indexing)
        を参照してください。


        `run_state: superseded` の試行は、`stage` が `canceled`
        であっても再試行できません。再インデックスのレスポンスから新しいタスク ID を保存している場合は、そのタスクをポーリングしてください。
      operationId: retryIndexingTask
      parameters:
        - description: >-
            ナレッジベース ID です。ナレッジベースの **API アクセス** ダイアログに表示されるサービス API
            エンドポイントの最後のセグメント（`…/knowledge-fs/spaces/<knowledge base
            ID>`）です。アドレスバーでは `/datasets/new/` の後のセグメントです。
          in: path
          name: knowledge_base_id
          required: true
          schema:
            format: uuid
            type: string
        - description: >-
            インデックスタスク ID
            です。どこで得た値も同じです。[ドキュメントを再インデックス](/ja/api-reference/documents-and-chunks/re-index-documents)
            のレスポンスでは `queued` 項目の
            `compilation_job.id`、[ドキュメントを取得](/ja/api-reference/documents-and-chunks/get-document)
            では `latest_task.id`
            です。[ドキュメントのインデックスタスク一覧を取得](/ja/api-reference/indexing-tasks/list-document-indexing-tasks)
            では
            `id`、[バックグラウンドタスク一覧を取得](/ja/api-reference/indexing-tasks/list-background-tasks)
            では `document` タスクの `id` です。
          in: path
          name: task_id
          required: true
          schema:
            format: uuid
            type: string
      responses:
        '200':
          content:
            application/json:
              examples:
                success:
                  summary: レスポンス例
                  value:
                    base_head_revision: 1
                    candidate_fingerprint: null
                    candidate_publication_id: null
                    completed_at: null
                    created_at: 1788681600000
                    document_asset_id: 6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b
                    error: null
                    execution_attempts: 0
                    failure: null
                    id: e4a1f0b2-7c3d-4e5f-9a1b-2c3d4e5f6a7b
                    knowledge_space_id: 9b2e5b7a-3c1d-4e2f-8a9b-1c2d3e4f5a6b
                    max_execution_attempts: 3
                    run_state: dispatch_pending
                    stage: outline_built
                    updated_at: 1788681800000
                    version: 1
              schema:
                $ref: '#/components/schemas/KnowledgeBaseIndexingTask'
          description: >-
            再開されたタスクです。`run_state` は `dispatch_pending` で、`error` と
            `completed_at` は `null` です。
        '400':
          content:
            application/json:
              examples:
                knowledge_fs_invalid_request_path:
                  summary: knowledge_fs_invalid_request (path ID)
                  value:
                    code: knowledge_fs_invalid_request
                    message: Agent Knowledge Base request is invalid.
                    status: 400
          description: '- `knowledge_fs_invalid_request`：`task_id` の形式が正しくありません。'
        '401':
          content:
            application/json:
              examples:
                knowledge_fs_invalid_credential:
                  summary: knowledge_fs_invalid_credential
                  value:
                    code: knowledge_fs_invalid_credential
                    message: Invalid Agent Knowledge Base service credential.
                    status: 401
                unauthorized:
                  summary: unauthorized
                  value:
                    code: unauthorized
                    message: Access token is invalid
                    status: 401
          description: >-
            - `unauthorized`：`Authorization` ヘッダーがないか、キーが不明であるか、ナレッジベースの API
            キーではありません。

            - `knowledge_fs_invalid_credential`：キーは有効ですが、キーのワークスペースにこの ID
            のナレッジベースが存在しないか、キーがワークスペースに紐付いていません。
        '403':
          content:
            application/json:
              examples:
                forbidden:
                  summary: forbidden (rate limit)
                  value:
                    code: forbidden
                    message: >-
                      Sorry, you have reached the knowledge base request rate
                      limit of your subscription.
                    status: 403
                knowledge_fs_access_denied:
                  summary: knowledge_fs_access_denied (key scope)
                  value:
                    code: knowledge_fs_access_denied
                    message: Agent Knowledge Base operation is not allowed.
                    status: 403
                knowledge_fs_access_denied_2:
                  summary: knowledge_fs_access_denied (upstream)
                  value:
                    code: knowledge_fs_access_denied
                    failure:
                      action: contact_admin
                      category: authorization
                      code: KNOWLEDGE_FS_ACCESS_DENIED
                      message: >-
                        You do not have permission to perform this Agent
                        Knowledge Base operation.
                      retryPolicy: never
                      traceId: 8f3a2c14-9d6b-4c07-b5a1-2e7d0c93f5b2
                    message: >-
                      You do not have permission to perform this Agent Knowledge
                      Base operation.
                    status: 403
          description: >-
            -
            `knowledge_fs_access_denied`：キーのアクセス範囲がほかのナレッジベースに限定されているか、このナレッジベースで
            **API アクセス** がオフになっています。または、ナレッジベースがアクティブではありません。

            - `knowledge_fs_access_denied`：API
            キーがこのナレッジベースのコンテンツにアクセスできないか、このナレッジベースへの書き込み権限を失いました。

            - `forbidden`：Dify Cloud
            で、ワークスペースがサブスクリプションで定められたナレッジベースのリクエストレート制限に達しました。読み取りを含め、すべての呼び出しがカウントされます。
        '404':
          content:
            application/json:
              examples:
                knowledge_fs_resource_not_found:
                  summary: knowledge_fs_resource_not_found
                  value:
                    code: knowledge_fs_resource_not_found
                    failure:
                      category: not_found
                      code: KNOWLEDGE_FS_NOT_FOUND
                      message: >-
                        The requested Agent Knowledge Base resource was not
                        found.
                      retryPolicy: never
                      traceId: 8f3a2c14-9d6b-4c07-b5a1-2e7d0c93f5b2
                    message: The requested Agent Knowledge Base resource was not found.
                    status: 404
                not_found:
                  summary: not_found (feature off)
                  value:
                    code: not_found
                    message: >-
                      The requested URL was not found on the server. If you
                      entered the URL manually please check your spelling and
                      try again.
                    status: 404
          description: >-
            - `knowledge_fs_resource_not_found`：この ID
            のインデックスタスクが存在しないか、タスクがインデックス対象とするドキュメントファイルを、この API キーで読み取れなくなりました。

            - `not_found`：このデプロイ環境では Agent ナレッジベース機能が無効になっています。
        '409':
          content:
            application/json:
              examples:
                document_compilation_profile_changed:
                  summary: knowledge_fs_conflict (model configuration changed)
                  value:
                    code: knowledge_fs_conflict
                    failure:
                      action: configure_model
                      category: configuration
                      code: DOCUMENT_COMPILATION_PROFILE_CHANGED
                      message: >-
                        The model configuration changed or is unavailable. Check
                        the knowledge space models before retrying document
                        processing.
                      retryPolicy: after_configuration
                      traceId: 5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b
                    message: >-
                      The model configuration changed or is unavailable. Check
                      the knowledge space models before retrying document
                      processing.
                    status: 409
                knowledge_fs_conflict:
                  summary: knowledge_fs_conflict
                  value:
                    code: knowledge_fs_conflict
                    failure:
                      action: retry
                      category: conflict
                      code: KNOWLEDGE_FS_CONFLICT
                      message: >-
                        The Agent Knowledge Base operation conflicts with the
                        current resource state.
                      retryPolicy: manual
                      traceId: 8f3a2c14-9d6b-4c07-b5a1-2e7d0c93f5b2
                    message: >-
                      The Agent Knowledge Base operation conflicts with the
                      current resource state.
                    status: 409
          description: >-
            - `knowledge_fs_conflict`：タスクが `failed` または `canceled`
            の状態ではないか、同じファイルに対する別の試行がすでに実行中です。

            -
            `knowledge_fs_conflict`：ナレッジベースのモデル設定が変更されたか、利用できません。`failure.code`
            は `DOCUMENT_COMPILATION_PROFILE_CHANGED`、`action` は
            `configure_model`
            です。再試行する前に、[ナレッジベース設定を取得](/ja/api-reference/settings/get-knowledge-base-settings)
            でモデルを確認してください。
        '413':
          content:
            application/json:
              examples:
                knowledge_fs_request_too_large:
                  summary: knowledge_fs_request_too_large (vector storage limit)
                  value:
                    code: knowledge_fs_request_too_large
                    failure:
                      action: retry
                      category: configuration
                      code: VECTOR_SPACE_QUOTA_EXCEEDED
                      message: >-
                        The workspace vector storage limit has been reached.
                        Delete documents or upgrade the plan before indexing
                        more.
                      retryPolicy: manual
                      traceId: 5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b
                    message: >-
                      The workspace vector storage limit has been reached.
                      Delete documents or upgrade the plan before indexing more.
                    status: 413
          description: >-
            -
            `knowledge_fs_request_too_large`：ワークスペースのベクトルストレージの上限に達しました。`failure.code`
            は `VECTOR_SPACE_QUOTA_EXCEEDED`
            です。再試行する前に、ドキュメントを削除するか、プランをアップグレードしてください。
        '502':
          content:
            application/json:
              examples:
                knowledge_fs_upstream_unavailable:
                  summary: knowledge_fs_upstream_unavailable
                  value:
                    code: knowledge_fs_upstream_unavailable
                    message: Agent Knowledge Base is unavailable.
                    status: 502
          description: >-
            - `knowledge_fs_upstream_unavailable`：時間内に応答が返らなかったか、応答を読み取れませんでした。


            再試行が反映されている可能性があります。再試行を繰り返すかどうかを判断する前に、同じタスク ID で
            [インデックスタスクを取得](/ja/api-reference/indexing-tasks/get-indexing-task)
            を呼び出して確認してください。`stage` と `run_state`
            がこの操作の要件を満たしているかを確かめます。タスクの状態が変わった後は、同じ操作を繰り返しても拒否される場合があります。
        '503':
          content:
            application/json:
              examples:
                knowledge_fs_operation_unavailable:
                  summary: knowledge_fs_operation_unavailable
                  value:
                    code: knowledge_fs_operation_unavailable
                    message: Agent Knowledge Base operation is not available.
                    status: 503
                knowledge_fs_operation_unavailable_upstream:
                  summary: knowledge_fs_operation_unavailable (temporary)
                  value:
                    code: knowledge_fs_operation_unavailable
                    failure:
                      action: retry
                      category: dependency
                      code: KNOWLEDGE_FS_UNAVAILABLE
                      message: >-
                        A service required by Agent Knowledge Base is
                        temporarily unavailable.
                      retryPolicy: manual
                      traceId: 5e2a9c17-3b4d-4f60-8a1b-2c3d4e5f6a7b
                    message: >-
                      A service required by Agent Knowledge Base is temporarily
                      unavailable.
                    status: 503
          description: >-
            - `knowledge_fs_operation_unavailable`：このワークスペースで Agent
            ナレッジベース機能が設定されていないか、このデプロイ環境ではこの操作を利用できません。または、リクエストの認可中に、このナレッジベースに対するキーのアクセス権が変更されました。

            -
            `knowledge_fs_operation_unavailable`：現在このリクエストを処理できません。`failure.retryPolicy`
            に従ってください。
components:
  schemas:
    KnowledgeBaseIndexingTask:
      properties:
        base_head_revision:
          description: 内部用です。タスクの追跡には不要です。
          nullable: true
          type: integer
        candidate_fingerprint:
          description: 内部用です。タスクの追跡には不要です。
          nullable: true
          type: string
        candidate_publication_id:
          description: 内部用です。タスクの追跡には不要です。
          nullable: true
          type: string
        completed_at:
          description: タスクが最終状態に達した日時（エポックミリ秒）です。実行中と再試行後は `null` です。
          nullable: true
          type: number
        created_at:
          description: タスクの作成日時（エポックミリ秒）です。
          type: number
        document_asset_id:
          description: >-
            インデックス処理中のドキュメントファイルの ID
            です。[ドキュメントファイルを取得](/ja/api-reference/documents-and-chunks/get-document-file)
            で使用できます。ドキュメント ID を送信した場合でも、タスクを開始した
            [ドキュメントを再インデックス](/ja/api-reference/documents-and-chunks/re-index-documents)
            の項目の `asset.id` になります。
          type: string
        error:
          description: >-
            短い失敗メッセージです。`failure.message` と異なる場合があります。`stage` または `run_state` が
            `failed` の場合にのみ設定されます。それ以外の場合は、キャンセルされたタスクも含めて `null` です。
          nullable: true
          type: string
        execution_attempts:
          description: >-
            これまでの試行回数です。[インデックスタスクを再試行](/ja/api-reference/indexing-tasks/retry-indexing-task)
            で `0` にリセットされるため、再試行を繰り返しても、それだけで試行回数の上限に達することはありません。
          nullable: true
          type: integer
        failure:
          allOf:
            - $ref: '#/components/schemas/KnowledgeBaseErrorDetails'
          description: タスクが失敗した場合のエラー詳細です。それ以外の場合は `null` です。
          nullable: true
        id:
          description: インデックスタスク ID です。
          type: string
        knowledge_space_id:
          description: ナレッジベースの内部 ID です。パスのナレッジベース ID とは異なります。
          type: string
        max_execution_attempts:
          description: タスクが失敗となるまでに許可される試行回数です。
          nullable: true
          type: integer
        run_state:
          description: >-
            現在の試行のスケジューラ上の状態です：


            - `dispatch_pending`：受け付け済みで、ワーカーへの割り当てを待っています。

            - `queued`：割り当て済みで、ワーカーを待っています。

            - `running`：ワーカーがタスクを実行しています。

            - `retry_wait`：自動再試行が予定されています。`stage` は変わりません。

            - `succeeded`：`stage: published` とともに返されます。

            - `failed`、`canceled`：最終状態です。

            - `superseded`：新しい試行に置き換えられました。最終状態で、`stage: canceled`
            とともに返されます。キャンセルも再試行も受け付けません。


            未設定の場合は `null`
            です。[インデックスタスクを再試行](/ja/api-reference/indexing-tasks/retry-indexing-task)
            で `dispatch_pending` に設定されます。
          nullable: true
          type: string
        stage:
          description: >-
            インデックス処理の段階です。次の順に進みます：


            - `queued`

            - `parsed`

            - `outline_built`

            - `nodes_generated`

            - `projection_built`

            - `smoke_eval_passed`

            - `published`


            `published` は、新しいリビジョンがアクティブになったことを示します。最終状態を表すほかの値は `failed` と
            `canceled`
            です。[インデックスタスクを再試行](/ja/api-reference/indexing-tasks/retry-indexing-task)
            では試行が到達したチェックポイントが維持されるため、再試行後にこの値が `queued` になることはほとんどありません。
          type: string
        updated_at:
          description: タスクが最後に変更された日時（エポックミリ秒）です。
          type: number
        version:
          description: インデックス処理中のドキュメントファイルのバージョンです。
          type: integer
      type: object
    KnowledgeBaseErrorDetails:
      properties:
        action:
          description: >-
            推奨される次の対応です。ある場合は
            `configure_model`、`configure_parser`、`configure_source`、`contact_admin`、`reupload`、`retry`
            のいずれかです。該当しない場合は `null` で、HTTP エラーのボディでは省略されます。
          nullable: true
          type: string
        category:
          description: >-
            失敗の種類で、`authorization`、`canceled`、`configuration`、`conflict`、`dependency`、`internal`、`not_found`、`rate_limit`、`timeout`、`validation`
            のいずれかです。
          type: string
        code:
          description: >-
            大文字のスネークケースで表される固定のエラーコードです（例：`KNOWLEDGE_FS_CONFLICT`、`SOURCE_CREDENTIAL_TEST_FAILED`）。
          type: string
        message:
          description: エラーコードまたは失敗の種類に対応する公開用メッセージです。プロバイダーのエラー詳細は公開されません。
          type: string
        parameters:
          additionalProperties: true
          description: >-
            失敗の内容を補足する最大 8 個の値です。キーは
            `attempt`、`currentRowVersion`、`documentCount`、`expectedRowVersion`、`fileSizeBytes`、`limit`、`maxFileSizeBytes`、`maxItems`、`modelType`、`providerKind`、`retryAfterSeconds`、`status`
            のいずれかです。値がない場合は `null` で、HTTP エラーのボディでは省略されます。
          nullable: true
          type: object
        retryPolicy:
          description: >-
            再試行で解決できるかどうかです。`automatic`（サービスが自動で再試行）、`manual`（呼び出し側で再試行）、`after_configuration`（先に
            Dify でナレッジベースの設定を修正）、`never`（リクエストを変更）のいずれかです。
          type: string
        stage:
          description: >-
            失敗が発生した段階です（例：`query_generation`、`credential-test`）。該当しない場合は `null`
            で、HTTP エラーのボディでは省略されます。
          nullable: true
          type: string
        traceId:
          description: >-
            管理者に問い合わせる際に伝える参照情報です。失敗の詳細を含む成功レスポンスでは `null` になることがあり、HTTP
            エラーのボディでは省略されることがあります。
          nullable: true
          type: string
      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

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.