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

# ソースのファイル一覧を取得

> オンラインドライブソースがプロバイダー側で参照できるバケットとファイルを一覧表示します。

ソースは、`metadata.providerKind` が `online-drive` の `connector` ソースである必要があります。

返されたフォルダーを開くには、その `id` を `prefix` として渡します。バケットの `is_truncated` が `true` の場合は、その `continuation_token` を `continuationToken` として渡すと、次のページを読み取れます。



## OpenAPI

````yaml /ja/api-reference/openapi_service.json get /knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/files
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/{source_id}/files:
    get:
      tags:
        - Sources
      summary: ソースのファイル一覧を取得
      description: >-
        オンラインドライブソースがプロバイダー側で参照できるバケットとファイルを一覧表示します。


        ソースは、`metadata.providerKind` が `online-drive` の `connector`
        ソースである必要があります。


        返されたフォルダーを開くには、その `id` を `prefix` として渡します。バケットの `is_truncated` が `true`
        の場合は、その `continuation_token` を `continuationToken` として渡すと、次のページを読み取れます。
      operationId: listSourceFiles
      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/sources/list-sources)
            から取得します。
          in: path
          name: source_id
          required: true
          schema:
            format: uuid
            type: string
        - description: 参照するバケットです。プロバイダーでの名前で指定します。省略すると、ソースに設定されたバケットが使われます。
          in: query
          name: bucket
          required: false
          schema:
            type: string
        - description: >-
            フォルダーを開くには、返されたフォルダーの `id` を `prefix`
            として送信します。表示名を送ったり、パスを組み立てたりしないでください。このパラメータを省略すると、ソースに設定された開始位置が使われます。
          in: query
          name: prefix
          required: false
          schema:
            type: string
        - description: >-
            前のレスポンスで返された、バケットの `continuation_token` です。`prefix`
            とバケットの指定は同じままにしてください。バケットを指定しておらず、レスポンスの `bucket` が `null`
            の場合は、`bucket` パラメータを省略します。
          in: query
          name: continuationToken
          required: false
          schema:
            maxLength: 4096
            minLength: 1
            type: string
        - description: 1 回のレスポンスで、バケットごとに返すファイル数です。省略すると、ソースに設定された値が適用されます。設定がない場合は 20 です。
          in: query
          name: maxKeys
          required: false
          schema:
            maximum: 1000
            minimum: 1
            type: integer
      responses:
        '200':
          content:
            application/json:
              examples:
                success:
                  summary: レスポンス例
                  value:
                    buckets:
                      - bucket: acme-shared
                        continuation_token: eyJwYWdlIjoyfQ
                        files:
                          - id: 1AbC9dEfGh2IjKl3MnOpQr
                            name: Q3-plan.pdf
                            size: 482113
                            type: file
                          - id: 2DeF8gHiJk3LmNo4PqRsTu
                            name: Policies
                            size: null
                            type: folder
                        is_truncated: true
              schema:
                properties:
                  buckets:
                    description: レスポンスに含まれるバケットです。
                    items:
                      properties:
                        bucket:
                          description: >-
                            バケット名です。プロバイダーにバケットの概念がない場合は `null`
                            です。別のページを取得するときは、リクエストのバケット指定を変えないでください。バケットを指定しておらず、この値が
                            `null` の場合は `bucket` を省略します。
                          nullable: true
                          type: string
                        continuation_token:
                          description: >-
                            このバケットの次のページを取得するには、この値を `continuationToken`
                            として渡します。最後のページでは `null` です。
                          nullable: true
                          type: string
                        files:
                          description: このページのファイルとフォルダーです。
                          items:
                            properties:
                              id:
                                description: プロバイダーでのファイル ID です。
                                type: string
                              name:
                                description: ファイル名またはフォルダー名です。
                                type: string
                              size:
                                description: >-
                                  サイズ（バイト）です。フォルダーの場合や、プロバイダーがサイズを報告しない場合は
                                  `null` です。
                                nullable: true
                                type: number
                              type:
                                description: プロバイダーが定義するエントリの種類です（例：`file`、`folder`）。
                                type: string
                            type: object
                          type: array
                        is_truncated:
                          description: >-
                            後続のファイルがある場合は `true` です。`continuation_token`
                            を使って次のページを取得します。
                          nullable: true
                          type: boolean
                      type: object
                    type: array
                type: object
          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:
                          - maxKeys
                        type: less_than_equal
                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
                knowledge_fs_invalid_request_type:
                  summary: knowledge_fs_invalid_request (source type)
                  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`：`maxKeys` が 1〜1,000
            の範囲外である、`continuationToken` が空か 4,096
            文字を超えている、またはクエリ文字列に不明なパラメータが含まれています。`violations`
            には、問題のあるフィールドがそれぞれ示されます。

            - `knowledge_fs_invalid_request`：ソースが `connector` ソースではありません。

            - `knowledge_fs_invalid_request`：`source_id` が UUID ではありません。

            - `knowledge_fs_invalid_request`：`source_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
          description: >-
            -
            `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
                    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 のソースがナレッジベースに存在しないか、その
            `permission_scope` がキーに付与された権限の範囲外です。

            - `not_found`：このデプロイ環境では Agent ナレッジベース機能が無効になっています。
        '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
                knowledge_fs_upstream_unavailable_provider:
                  summary: >-
                    knowledge_fs_upstream_unavailable
                    (SOURCE_ONLINE_DRIVE_REQUEST_FAILED)
                  value:
                    code: knowledge_fs_upstream_unavailable
                    failure:
                      action: retry
                      category: dependency
                      code: SOURCE_ONLINE_DRIVE_REQUEST_FAILED
                      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: 502
          description: >-
            -
            `knowledge_fs_upstream_unavailable`：時間内に応答が返らなかったか、応答を読み取れませんでした。しばらく待ってから再試行してください。

            -
            `knowledge_fs_upstream_unavailable`：プロバイダーまたは接続でエラーが発生しました。レスポンスボディには、`SOURCE_ONLINE_DRIVE_REQUEST_FAILED`
            などのコードを含む `failure` が返されます。

            -
            `knowledge_fs_upstream_unavailable`：デプロイ環境にオンラインドライブのコネクタが設定されていません。`failure.code`
            は `KNOWLEDGE_FS_INTERNAL_ERROR` です。
        '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:
  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.