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

# ソースを作成

> [ソースの接続一覧を取得](/ja/api-reference/sources/list-source-connections) で見つけた既存の接続を通じて読み取るソースを追加します。クロールやインポートは行われません。

成功した作成リクエストを繰り返すと、別のソースが作成されます。一意の `metadata.client_request_id` を付け、ソース ID を受け取るまで保持してください。

`web` ソースにデータを取り込むには、[ウェブサイトのクロールをプレビュー](/ja/api-reference/source-syncs-and-imports/preview-website-crawl) または [ウェブサイトのページをインポート](/ja/api-reference/source-syncs-and-imports/import-website-pages) を呼び出してください。`connector` ソースでは [ソースのアイテムをインポート](/ja/api-reference/source-syncs-and-imports/import-source-items) を呼び出します。手順については、[ソースの追加](/ja/api-reference/guides/knowledge-base#add-a-source) を参照してください。



## OpenAPI

````yaml /ja/api-reference/openapi_service.json post /knowledge-fs/spaces/{knowledge_base_id}/sources
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}/sources:
    post:
      tags:
        - Sources
      summary: ソースを作成
      description: >-
        [ソースの接続一覧を取得](/ja/api-reference/sources/list-source-connections)
        で見つけた既存の接続を通じて読み取るソースを追加します。クロールやインポートは行われません。


        成功した作成リクエストを繰り返すと、別のソースが作成されます。一意の `metadata.client_request_id` を付け、ソース
        ID を受け取るまで保持してください。


        `web`
        ソースにデータを取り込むには、[ウェブサイトのクロールをプレビュー](/ja/api-reference/source-syncs-and-imports/preview-website-crawl)
        または
        [ウェブサイトのページをインポート](/ja/api-reference/source-syncs-and-imports/import-website-pages)
        を呼び出してください。`connector` ソースでは
        [ソースのアイテムをインポート](/ja/api-reference/source-syncs-and-imports/import-source-items)
        を呼び出します。手順については、[ソースの追加](/ja/api-reference/guides/knowledge-base#add-a-source)
        を参照してください。
      operationId: createSource
      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
      requestBody:
        content:
          application/json:
            examples:
              website:
                summary: リクエスト例
                value:
                  connectionId: c3d4e5f6-7a8b-4c9d-8e0f-1a2b3c4d5e6f
                  metadata:
                    client_request_id: source-20260907-0001
                    providerKind: website
                  name: Docs site
                  permissionScope: []
                  status: disabled
                  type: web
                  uri: https://docs.example.com
            schema:
              additionalProperties: false
              properties:
                connectionId:
                  description: >-
                    ソースが読み取りに使う認証情報を提供する接続です。このナレッジベースに属し、`active`
                    である必要があります。[ソースの接続一覧を取得](/ja/api-reference/sources/list-source-connections)
                    の `id` から取得します。
                  format: uuid
                  nullable: true
                  type: string
                metadata:
                  description: >-
                    プロバイダーの設定と、機密でない独自のメタデータです。作成時のレスポンスが失われた場合にこのソースを識別できるよう、一意の
                    `client_request_id` を付けてください。この値はソースとともに返されますが、API
                    は一意性を強制せず、重複したリクエストも排除しません。


                    `providerKind` には接続の `configuration.providerKind`
                    を設定し、それに合ったソースの `type`
                    を選んでください。接続から取得される設定は、ソースのレスポンスに含まれない場合があります。


                    既存のソースのレスポンスをもとに `metadata` を組み立てる場合は、`__knowledgeFs`
                    で始まるフィールド、`credentials`、`parameters`
                    オブジェクトを除いてください。`credentialId` がある場合は、Dify が保持する認証情報を指します。
                  type: object
                name:
                  description: 表示名です。
                  maxLength: 200
                  minLength: 1
                  type: string
                permissionScope:
                  description: 空にするか省略してください。空のリストのみ受け付けます。
                  items:
                    type: string
                  maxItems: 0
                  type: array
                status:
                  default: active
                  description: '`disabled` にすると、スケジュール同期が一時停止します。'
                  enum:
                    - active
                    - disabled
                    - null
                  nullable: true
                  type: string
                type:
                  description: >-
                    ウェブサイトのクロールには `web` を、オンラインドキュメントまたはオンラインドライブのプロバイダーには
                    `connector` を指定します（`metadata.providerKind` も設定します）。`upload`
                    と `object-storage` は、Dify がデータを取り込むソース用の値です。
                  enum:
                    - connector
                    - object-storage
                    - upload
                    - web
                  type: string
                uri:
                  description: >-
                    `web` ではクロールのルート URL を指定します。`connector` では、Dify が書き込む値に合わせて
                    `connector://<connectionId>` を指定します。
                  maxLength: 4096
                  minLength: 1
                  type: string
              required:
                - name
                - type
                - uri
              type: object
        description: >-
          nullable と記されたオプションフィールドでは、`null` は省略と同じ扱いになります。


          正規化後のリクエストは、UTF-8 で 262,144
          バイト以内に収める必要があります。[リクエストサイズの制限](/ja/api-reference/guides/knowledge-base#request-size-limits)
          を参照してください。
        required: true
      responses:
        '201':
          content:
            application/json:
              examples:
                success:
                  summary: レスポンス例
                  value:
                    connection_id: c3d4e5f6-7a8b-4c9d-8e0f-1a2b3c4d5e6f
                    created_at: '2026-09-06T01:30:00Z'
                    credential_configured: null
                    id: 6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90
                    knowledge_space_id: 0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d
                    last_synced_at: null
                    metadata:
                      client_request_id: source-20260907-0001
                      providerKind: website
                      tenantId: 2f1e0d9c-8b7a-4695-8473-2a1b0c9d8e7f
                    name: Docs site
                    permission_scope: []
                    status: disabled
                    sync_policy: null
                    sync_workflow: null
                    type: web
                    updated_at: '2026-09-06T01:30:00Z'
                    uri: https://docs.example.com
                    version: 1
              schema:
                $ref: '#/components/schemas/KnowledgeBaseSource'
          description: 作成されたソースです。
        '400':
          content:
            application/json:
              examples:
                knowledge_fs_invalid_request:
                  summary: knowledge_fs_invalid_request (validation)
                  value:
                    code: knowledge_fs_invalid_request
                    message: Agent Knowledge Base request is invalid.
                    status: 400
                    violations:
                      - field:
                          - name
                        type: missing
                knowledge_fs_invalid_request_credentials:
                  summary: knowledge_fs_invalid_request (credentials in metadata)
                  value:
                    code: knowledge_fs_invalid_request
                    failure:
                      category: validation
                      code: KNOWLEDGE_FS_INVALID_REQUEST
                      message: The Agent Knowledge Base request is invalid.
                      retryPolicy: never
                    message: The Agent Knowledge Base request is invalid.
                    status: 400
          description: >-
            - `knowledge_fs_invalid_request`：`name`、`type`、`uri`
            のいずれかがないか制限の範囲外である、`type`
            が記載されている値のいずれでもない、またはボディに不明なキーが含まれています。`violations`
            には、問題のあるフィールドがそれぞれ示されます。

            - `knowledge_fs_invalid_request`：ボディにトップレベルの `credentials`
            キーが含まれている、`metadata` に `syncPolicy` が含まれている、または `permissionScope`
            が空ではありません。これらのレスポンスボディには、`failure` ではなく `violations` が含まれます。

            - `knowledge_fs_invalid_request`：`connectionId` が UUID
            ではありません。レスポンスボディの `failure` と `violations` にエラー詳細が含まれます。

            - `knowledge_fs_invalid_request`：`metadata` に `credentials`
            キーが含まれています。認証情報は Dify が管理するため、代わりに接続を紐付けてください。
        '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_upstream:
                  summary: knowledge_fs_access_denied
                  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
                    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`：キーには、このナレッジベースのコンテンツへのアクセス権がありません。

            - `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
                    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 が認識されません。

            - `knowledge_fs_resource_not_found`：`connectionId`
            がこのナレッジベースの接続を指していません。

            - `not_found`：このデプロイ環境では Agent ナレッジベース機能が無効になっています。
        '409':
          content:
            application/json:
              examples:
                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
                    message: >-
                      The Agent Knowledge Base operation conflicts with the
                      current resource state.
                    status: 409
          description: >-
            - `knowledge_fs_conflict`：接続が `active`
            ではありません（プロビジョニング中、期限切れ、取り消し済み、またはエラー）。Dify で接続を更新してください。
        '413':
          content:
            application/json:
              examples:
                knowledge_fs_request_too_large:
                  summary: knowledge_fs_request_too_large (request budget)
                  value:
                    code: knowledge_fs_request_too_large
                    message: Agent Knowledge Base request is too large.
                    status: 413
          description: >-
            - `knowledge_fs_request_too_large`：Dify がデフォルト値を追加した後のリクエストが、UTF-8 で
            262,144
            バイトを超えています。[リクエストサイズの制限](/ja/api-reference/guides/knowledge-base#request-size-limits)
            を参照してください。
        '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`：時間内に応答が返らなかったか、応答を読み取れませんでした。


            ソースはすでに作成されている可能性があります。同じ API キーで
            [ソース一覧を取得](/ja/api-reference/sources/list-sources) を呼び出し、送信した
            `metadata.client_request_id` を持つソースを探してください。`next_cursor`
            はすべてたどってください。一致するソースが見つかったら、そのソース ID を保持してください。


            一致するソースが見つからない場合は、リクエストの処理がまだ完了していないか、ソースが表示されなくなっている可能性があります。
        '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:
    KnowledgeBaseSource:
      properties:
        connection_id:
          description: >-
            ソースが認証情報の取得に使用する接続です。別のソースを同じ接続に紐付ける場合は、`connectionId`
            として渡します。紐付けられていない場合は `null` です。
          nullable: true
          type: string
        created_at:
          description: 作成日時（ISO 8601）です。
          type: string
        credential_configured:
          description: >-
            ソースが独自の認証情報の参照を保持している場合は `true` です。接続に紐付けられたソースのように参照を保持していない場合は
            `null` です。
          nullable: true
          type: boolean
        id:
          description: ソース ID です。
          type: string
        knowledge_space_id:
          description: ナレッジベースの内部 ID です。パスのナレッジベース ID とは異なります。
          type: string
        last_synced_at:
          description: >-
            直近に完了した同期（`completed` または
            `zero_results`）またはインポートの完了日時です。[ソース一覧を取得](/ja/api-reference/sources/list-sources)
            でのみ設定されます。それ以外の操作、およびソースが一度も同期されていない場合は `null` です。
          nullable: true
          type: string
        metadata:
          description: >-
            プロバイダーの設定と、サーバーが管理する同期データまたはページ選択データです。プロバイダーの識別子や `parameters`
            が含まれる場合があります。接続側で管理される設定は、ここに含まれるとは限りません。認証情報に類するキーは除去されます。別のソースを作成する際に、このオブジェクト全体をコピーしないでください。
          type: object
        name:
          description: 表示名です。
          type: string
        permission_scope:
          description: >-
            このソースを読み取るために必要なコンテンツのアクセス範囲です。空のリストの場合、ナレッジベース内でのコンテンツの制限は追加されません。ナレッジベースの認可は引き続き適用されます。
          items:
            type: string
          type: array
        status:
          description: >-
            `active`、`syncing`、`error`、`disabled`
            のいずれかです。ほとんどの操作は保存されている値を返します。[ソース一覧を取得](/ja/api-reference/sources/list-sources)
            は、直近の同期の実行から値を導き出します：


            - `failed` または `canceled` の実行：`error`

            - `completed` または `zero_results` の実行：`active`

            - 進行中の実行：`syncing`


            `disabled` が上書きされることはありません。
          type: string
        sync_policy:
          allOf:
            - $ref: '#/components/schemas/KnowledgeBaseSyncPolicy'
          description: >-
            ソースの同期スケジュールです。[ソース一覧を取得](/ja/api-reference/sources/list-sources)
            でのみ設定されます。それ以外の操作、およびスケジュールがない場合は `null` です。単独で取得するには
            [同期ポリシーを取得](/ja/api-reference/sources/get-sync-policy)、変更するには
            [同期ポリシーを更新](/ja/api-reference/sources/update-sync-policy) を使用します。
          nullable: true
        sync_workflow:
          allOf:
            - $ref: '#/components/schemas/KnowledgeBaseSourceRun'
          description: >-
            ソースで進行中の同期またはインポートの実行（`crawl-import`、`online-document-import`、`online-drive-import`）です。進行中の実行がない場合は、直近の同期の実行です。[ソース一覧を取得](/ja/api-reference/sources/list-sources)
            は、実行が進行中か、ソースより新しい場合に設定します。[ソースを更新](/ja/api-reference/sources/update-source)
            は、その呼び出しで同期が開始された場合に設定します。それ以外の場合は `null`
            です。クロールプレビューと、そこからのインポートはここに表示されません。


            個々の実行を追跡するには、その `id` を指定して
            [ソースの実行を取得](/ja/api-reference/source-syncs-and-imports/get-source-run)
            を呼び出します。
          nullable: true
        type:
          description: >-
            `web`（ウェブサイトのクロール）、`connector`（オンラインドキュメントまたはオンラインドライブ）、`upload`、`object-storage`
            のいずれかです。


            `connector` ソースでは、`metadata.providerKind` は `online-document` または
            `online-drive` です。`web` ソースでは `website` です。


            `upload` と `object-storage` のソースには、Dify が内容を追加します。
          type: string
        updated_at:
          description: 最終更新日時（ISO 8601）です。
          type: string
        uri:
          description: >-
            `web` ソースでは、クロールのルート URL です。Dify で作成されたコネクタソースでは
            `connector://<connection_id>` です。
          type: string
        version:
          description: >-
            ソースのバージョンで、書き込みのたびに増加します。[ソースを更新](/ja/api-reference/sources/update-source)
            では
            `expectedVersion`、[ソースを削除](/ja/api-reference/sources/delete-source)
            では
            `expectedRevision`、[同期ポリシーを更新](/ja/api-reference/sources/update-sync-policy)
            では `expectedSourceVersion` として送信します。
          type: integer
      type: object
    KnowledgeBaseSyncPolicy:
      properties:
        created_at:
          description: 作成日時（ISO 8601）です。
          type: string
        custom_interval_seconds:
          description: '`mode: custom` の場合の間隔（秒）です。ほかのモードでは `null` です。'
          nullable: true
          type: integer
        enabled:
          description: 'スケジュール同期を実行するかどうかです。`mode: manual` では常に `false` です。'
          type: boolean
        expected_source_version:
          description: スケジュールが紐付いているソースの `version` です。
          type: integer
        id:
          description: 同期ポリシー ID です。更新しても変わりません。
          type: string
        knowledge_space_id:
          description: ナレッジベースの内部 ID です。パスのナレッジベース ID とは異なります。
          type: string
        mode:
          description: >-
            `manual`（スケジュールなし）、`interval`（24
            時間ごと）、`custom`（`custom_interval_seconds` ごと）のいずれかです。
          type: string
        next_run_at:
          description: 次回のスケジュール同期の予定日時（ISO 8601）です。予定がない場合は `null` です。
          nullable: true
          type: string
        revision:
          description: >-
            スケジュールのリビジョンです。[同期ポリシーを更新](/ja/api-reference/sources/update-sync-policy)
            で `expectedRevision` として送信します。更新のたび、およびスケジュール同期が開始されるたびに増加します。
          type: integer
        source_id:
          description: スケジュールが属するソースです。
          type: string
        updated_at:
          description: 最終更新日時（ISO 8601）です。スケジュール同期が開始されたときにも更新されます。
          type: string
      type: object
    KnowledgeBaseSourceRun:
      properties:
        canceled_at:
          description: 実行がキャンセルされた日時です。`state` が `canceled` でない場合は `null` です。
          nullable: true
          type: string
        checkpoint:
          description: >-
            実行が到達した最後のステップで、`queued`、`provider-read`、`preview-staged`、`selection-frozen`、`materialized`、`cleanup-staging`、`source-committed`
            のいずれかです。[ソースの実行を再試行](/ja/api-reference/source-syncs-and-imports/retry-source-run)
            は、チェックポイントにかかわらず実行を最初からやり直します。
          type: string
        completed_at:
          description: >-
            実行が `completed`、`zero_results`、`failed`、`canceled` のいずれかで終了した日時（ISO
            8601）です。実行中は `null` です。
          nullable: true
          type: string
        created_at:
          description: 作成日時（ISO 8601）です。
          type: string
        cursor:
          description: 実行の再開位置となるプロバイダーのカーソルです。実行がページ送りをしていない場合は `null` です。
          nullable: true
          type: string
        execution_attempts:
          description: >-
            ワーカーが実行を取得した回数です。[ソースの実行を再試行](/ja/api-reference/source-syncs-and-imports/retry-source-run)
            の後の取得も含み、再試行してもリセットされません。
          type: integer
        failure:
          allOf:
            - $ref: '#/components/schemas/KnowledgeBaseErrorDetails'
          description: >-
            `state` が `failed` の場合のエラー詳細です。`stage` は失敗時点の実行の
            `checkpoint`、`traceId` は実行 ID です。それ以外の場合は `null` です。
          nullable: true
        id:
          description: >-
            実行 ID
            です。[ソースの実行を取得](/ja/api-reference/source-syncs-and-imports/get-source-run)、[ソースの実行をキャンセル](/ja/api-reference/source-syncs-and-imports/cancel-source-run)、[ソースの実行を再試行](/ja/api-reference/source-syncs-and-imports/retry-source-run)
            に渡します。
          type: string
        kind:
          description: >-
            実行の処理内容です：


            -
            `sync`：[ソースを同期](/ja/api-reference/source-syncs-and-imports/sync-source)、[ソースを更新](/ja/api-reference/sources/update-source)、スケジュール、または
            Dify によって開始されます。

            -
            `crawl-preview`：[ウェブサイトのクロールをプレビュー](/ja/api-reference/source-syncs-and-imports/preview-website-crawl)
            によって開始されます。[選択したページをインポート](/ja/api-reference/source-syncs-and-imports/import-selected-pages)
            がこの実行からインポートしている間も、種類は変わりません。

            -
            `crawl-import`：[ウェブサイトのページをインポート](/ja/api-reference/source-syncs-and-imports/import-website-pages)
            によって開始されます。

            -
            `online-document-import`、`online-drive-import`：[ソースのアイテムをインポート](/ja/api-reference/source-syncs-and-imports/import-source-items)
            によって開始されます。


            Dify でソースを追加または編集した場合も、Dify がプレビューとインポートを開始します。
          type: string
        knowledge_space_id:
          description: ナレッジベースの内部 ID です。パスのナレッジベース ID とは異なります。
          type: string
        last_error_code:
          description: '`state` が `failed` の場合は `failure.code` の値です。それ以外の場合は `null` です。'
          nullable: true
          type: string
        max_execution_attempts:
          description: >-
            `execution_attempts`
            の上限です。上限に達すると、[ソースの実行を再試行](/ja/api-reference/source-syncs-and-imports/retry-source-run)
            は `409` を返します。
          type: integer
        progress_completed:
          description: 完了したアイテム数です。同期で確認された未変更のアイテムも含みます。
          type: integer
        progress_failed:
          description: ソースの実行では常に `0` です。1 つのアイテムが失敗すると、実行全体が失敗するためです。
          type: integer
        progress_skipped:
          description: ソースの実行では常に `0` です。
          type: integer
        progress_total:
          description: >-
            実行が処理する予定のアイテム数です。インポートではリクエストされたページまたはアイテム、クロールプレビューではこれまでに一時保存されたページ、同期では一覧の取得後のソースのアイテムを数えます。判明するまでは
            `null` です。


            [ウェブサイトのページをインポート](/ja/api-reference/source-syncs-and-imports/import-website-pages)
            の実行が URL をクロールしている間は、`progress_completed` と `progress_total`
            のどちらも、それまでにクロールしたページ数を数えます。すべての URL のクロールが終わると、URL の数を総数として `0`
            から数え直します。
          nullable: true
          type: integer
        source_id:
          description: 実行が属するソースです。
          nullable: true
          type: string
        state:
          description: >-
            実行の進行状況です。


            進行中の状態：


            - `queued`：ワーカー待ち

            - `crawling`：クロールプレビューによるページの取得中

            - `preview_ready`：クロールプレビューが
            [選択したページをインポート](/ja/api-reference/source-syncs-and-imports/import-selected-pages)
            または
            [ソースの実行をキャンセル](/ja/api-reference/source-syncs-and-imports/cancel-source-run)
            を待機中

            - `importing`：アイテムのインポートとインデックス処理中

            - `syncing`：ソースのドキュメントを更新中


            最終状態：


            - `completed`：すべてのアイテムのインポートまたは更新、インデックス処理、アクティブ化が完了

            - `zero_results`：クロールプレビューで見つかったページが 0 件

            - `failed`：`failure` を参照

            - `canceled`


            `failed` または `canceled`
            の後は、[ソースの実行を再試行](/ja/api-reference/source-syncs-and-imports/retry-source-run)
            で再実行でき、[ソースを同期](/ja/api-reference/source-syncs-and-imports/sync-source)
            で新しい同期を開始できます。
          type: string
        updated_at:
          description: 最終更新日時（ISO 8601）です。
          type: string
      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.