> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 获取知识库列表

GET https://api.elevenlabs.io/v1/convai/knowledge-base

获取可用知识库文档列表

Reference: https://elevenlabs.io/docs/api-reference/knowledge-base/list

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Query parameters

- `page_size` (integer, optional, default: 30) — 最多返回的文档数量。不能超过 100，默认为 30。
- `search` (string, optional, nullable) — 指定后，此端点仅返回名称以此字符串开头的知识库文档。
- `show_only_owned_documents` (boolean, optional, default: false, deprecated) — 设为 true 时，此端点仅返回你拥有的文档（不包括他人分享的文档）。已弃用：请改用 created_by_user_id。
- `created_by_user_id` (string, optional, nullable) — 按创建者用户 ID 筛选文档。设置后，仅返回该用户创建的文档。此项优先于 show_only_owned_documents。使用 '@me' 表示已认证用户。
- `types` (list of enum, optional, nullable) — 提供后，端点仅返回指定类型的文档。
  - Allowed values: `file`, `url`, `text`, `folder`
- `parent_folder_id` (string, optional, nullable) — 设定后，此端点仅返回指定文件夹的直接子文档。
- `ancestor_folder_id` (string, optional, nullable) — 设定后，此端点仅返回指定文件夹的后代文档。
- `folders_first` (boolean, optional, default: false) — 是否在文档列表中优先返回文件夹。
- `sort_direction` (enum, optional) — 结果排序方向
  - Allowed values: `asc`, `desc`
- `sort_by` (enum, optional, nullable) — 用于排序结果的字段
  - Allowed values: `name`, `created_at`, `updated_at`, `size`
- `cursor` (string, optional, nullable) — 用于获取下一页。响应中会返回游标。

## Response

### 200

成功响应

- `documents` (list of GetKnowledgeBaseListResponseModelDocumentsItems, required)
- `has_more` (boolean, required)
- `next_cursor` (string, optional, nullable)

## Errors

### 422 Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### GetKnowledgeBaseListResponseModelDocumentsItems

- `type`: `file` (GetKnowledgeBaseSummaryFileResponseModel)
  - `access_info` (ResourceAccessInfo, required)
  - `id` (string, required)
  - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
  - `name` (string, required)
  - `supported_usages` (list of enum, required)
    - Allowed values: `prompt`, `auto`
  - `dependent_agents` (list of V1ConvaiKnowledgeBaseSummariesGetResponsesContentApplicationJsonSchemaDiscriminatorMappingSuccessDataDiscriminatorMappingFileDependentAgentsItems, required, deprecated) — 此字段已弃用，将在未来移除。请改用独立端点获取依赖的智能体。
  - `auto_sync_info` (AutoSyncInfo, optional, nullable)
  - `external_sync_info` (ExternalFileSyncInfo, optional, nullable) — 跟踪返回外部来源原始文件的链接。
  - `folder_parent_id` (string, optional, nullable) — 父文件夹的 ID；如果文档位于根目录，则为 null。
  - `folder_path` (list of KnowledgeBaseFolderPathSegmentSummaryResponseModel, optional) — 从根目录到父文件夹、通往此实体的文件夹路径段。
  - `is_frozen` (boolean, optional, default: false)
  - `refresh_status` (FileRefreshStatus, optional, nullable) — 外部同步知识库文件正在进行或最近一次刷新的状态。
- `type`: `folder` (GetKnowledgeBaseSummaryFolderResponseModel)
  - `access_info` (ResourceAccessInfo, required)
  - `children_count` (integer, required)
  - `document_count` (integer, required) — 此文件夹子树中任意位置的非文件夹文档数量（递归）。计数超过 1000 后停止；
  - `id` (string, required)
  - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
  - `name` (string, required)
  - `supported_usages` (list of enum, required)
    - Allowed values: `prompt`, `auto`
  - `dependent_agents` (list of V1ConvaiKnowledgeBaseSummariesGetResponsesContentApplicationJsonSchemaDiscriminatorMappingSuccessDataDiscriminatorMappingFolderDependentAgentsItems, required, deprecated) — 此字段已弃用，将在未来移除。请改用独立端点获取依赖的智能体。
  - `auto_sync_info` (AutoSyncInfo, optional, nullable)
  - `external_sync_info` (ExternalFolderSyncInfo, optional, nullable) — 镜像外部源文件夹的知识库文件夹元数据。
  - `folder_parent_id` (string, optional, nullable) — 父文件夹的 ID；如果文档位于根目录，则为 null。
  - `folder_path` (list of KnowledgeBaseFolderPathSegmentSummaryResponseModel, optional) — 从根目录到父文件夹、通往此实体的文件夹路径段。
  - `is_frozen` (boolean, optional, default: false)
- `type`: `text` (GetKnowledgeBaseSummaryTextResponseModel)
  - `access_info` (ResourceAccessInfo, required)
  - `id` (string, required)
  - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
  - `name` (string, required)
  - `supported_usages` (list of enum, required)
    - Allowed values: `prompt`, `auto`
  - `dependent_agents` (list of V1ConvaiKnowledgeBaseSummariesGetResponsesContentApplicationJsonSchemaDiscriminatorMappingSuccessDataDiscriminatorMappingTextDependentAgentsItems, required, deprecated) — 此字段已弃用，将在未来移除。请改用独立端点获取依赖的智能体。
  - `folder_parent_id` (string, optional, nullable) — 父文件夹的 ID；如果文档位于根目录，则为 null。
  - `folder_path` (list of KnowledgeBaseFolderPathSegmentSummaryResponseModel, optional) — 从根目录到父文件夹、通往此实体的文件夹路径段。
- `type`: `url` (GetKnowledgeBaseSummaryURLResponseModel)
  - `access_info` (ResourceAccessInfo, required)
  - `id` (string, required)
  - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
  - `name` (string, required)
  - `supported_usages` (list of enum, required)
    - Allowed values: `prompt`, `auto`
  - `url` (string, required)
  - `dependent_agents` (list of V1ConvaiKnowledgeBaseSummariesGetResponsesContentApplicationJsonSchemaDiscriminatorMappingSuccessDataDiscriminatorMappingUrlDependentAgentsItems, required, deprecated) — 此字段已弃用，将在未来移除。请改用独立端点获取依赖的智能体。
  - `auto_sync_info` (AutoSyncInfo, optional, nullable)
  - `folder_parent_id` (string, optional, nullable) — 父文件夹的 ID；如果文档位于根目录，则为 null。
  - `folder_path` (list of KnowledgeBaseFolderPathSegmentSummaryResponseModel, optional) — 从根目录到父文件夹、通往此实体的文件夹路径段。

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ResourceAccessInfo

- `is_creator` (boolean, required) — 发出请求的用户是否为该智能体的创建者
- `creator_name` (string, required) — 智能体创建者名称
- `creator_email` (string, required) — 智能体创建者的邮箱
- `role` (enum, required) — 发出请求的用户角色
  - Allowed values: `admin`, `editor`, `commenter`, `viewer`
- `anonymous_access_level_override` (enum, optional, nullable) — 匿名用户的访问级别。若为 None，该资源不会公开共享。
  - Allowed values: `admin`, `editor`, `commenter`, `viewer`
- `access_source` (enum, optional, nullable) — 请求用户拥有此资源访问权限的原因。'creator' = 调用者是所有者。'explicit' = 调用者（或其所属的某个工作区群组）列于 role_to_group_ids 中，且不包括工作区范围的所有人群组。'workspace_default' = 工作区范围的所有人群组列于 role_to_group_ids 中（所有非匿名工作区成员，包括管理员，均可查看此资源）。'workspace_admin' = 调用者是工作区管理员，且管理员席位是 *唯一* 的访问路径；此项仅用于其他人均无法查看的文档。这样 UI 可说明管理员绕过权限的查看者为何能看到未明确向其共享的文档。
  - Allowed values: `creator`, `explicit`, `workspace_admin`, `workspace_default`

### KnowledgeBaseDocumentMetadataResponseModel

- `created_at_unix_secs` (integer, required)
- `last_updated_at_unix_secs` (integer, required)
- `size_bytes` (integer, required)

### V1ConvaiKnowledgeBaseSummariesGetResponsesContentApplicationJsonSchemaDiscriminatorMappingSuccessDataDiscriminatorMappingFileDependentAgentsItems

- `type`: `available` (DependentAvailableAgentIdentifier)
  - `access_level` (enum, required)
    - Allowed values: `admin`, `editor`, `commenter`, `viewer`
  - `created_at_unix_secs` (integer, required)
  - `id` (string, required)
  - `name` (string, required)
  - `referenced_resource_ids` (list of string, optional) — 如果智能体是传递依赖项，则包含该智能体直接依赖资源的 ID。
- `type`: `unknown` (DependentUnknownAgentIdentifier)
  - `id` (string, required)
  - `referenced_resource_ids` (list of string, optional) — 如果智能体是传递依赖项，则包含该智能体直接依赖资源的 ID。

### AutoSyncInfo

- `minimum_frequency_days` (integer, optional, default: 7) — 刷新文档的最低频率（按天计）。实际间隔可能更短，但不会更长。
- `auto_remove` (boolean, optional, default: false) — 当 URL 不可用时是否删除文档
- `consec_failures` (integer, optional, default: 0) — 连续同步失败次数
- `next_refresh_by` (integer, optional, nullable) — 下次计划同步的 Unix 时间戳；文件夹时为 None。
- `auto_discover` (boolean, optional, default: false, deprecated) — 已弃用。此字段已不再生效，并将在未来版本中移除。

### ExternalFileSyncInfo

跟踪返回外部来源原始文件的链接。

- `type` (enum, required) — 提供商标识符
  - Allowed values: `google_drive`
- `source_entity_id` (string, required) — 外部系统中的实体 ID
- `integration_connection_id` (string, required) — 集成连接实例 ID
- `source_parent_entity_id` (string, required) — 此文件同步来源的外部系统文件夹 ID
- `source_mime_type` (string, required) — 外部系统中的原始 MIME 类型
- `source_modified_time` (string, required) — 外部系统中的最后修改时间
- `root_folder_id` (string, optional, nullable) — 同步根目录的知识库文件夹 ID，用于查询同步树下的所有实体

### KnowledgeBaseFolderPathSegmentSummaryResponseModel

- `id` (string, required)

### FileRefreshStatus

外部同步知识库文件正在进行或最近一次刷新的状态。

- `status` (enum, optional, default: queued)
  - Allowed values: `queued`, `processing`, `succeeded`, `failed`, `skipped`, `cancelled`
- `enqueued_at` (integer, optional, nullable)
- `started_at` (integer, optional, nullable)
- `completed_at` (integer, optional, nullable)
- `last_synced_at` (integer, optional, nullable)
- `error_message` (string, optional, nullable)

### V1ConvaiKnowledgeBaseSummariesGetResponsesContentApplicationJsonSchemaDiscriminatorMappingSuccessDataDiscriminatorMappingFolderDependentAgentsItems

- `type`: `available` (DependentAvailableAgentIdentifier)
  - `access_level` (enum, required)
    - Allowed values: `admin`, `editor`, `commenter`, `viewer`
  - `created_at_unix_secs` (integer, required)
  - `id` (string, required)
  - `name` (string, required)
  - `referenced_resource_ids` (list of string, optional) — 如果智能体是传递依赖项，则包含该智能体直接依赖资源的 ID。
- `type`: `unknown` (DependentUnknownAgentIdentifier)
  - `id` (string, required)
  - `referenced_resource_ids` (list of string, optional) — 如果智能体是传递依赖项，则包含该智能体直接依赖资源的 ID。

### ExternalFolderSyncInfo

镜像外部源文件夹的知识库文件夹元数据。

- `type` (enum, required) — 提供商标识符
  - Allowed values: `google_drive`
- `source_entity_id` (string, required) — 外部系统中的实体 ID
- `integration_connection_id` (string, required) — 集成连接实例 ID
- `root_folder_id` (string, optional, nullable) — 同步根目录的知识库文件夹 ID。None 表示此文件夹为根目录。
- `sync_cursor` (string, optional, nullable) — 用于增量同步的不透明游标，由提供商解析
- `last_sync_at` (integer, optional, nullable) — 上次完成同步的 Unix 时间戳。

### V1ConvaiKnowledgeBaseSummariesGetResponsesContentApplicationJsonSchemaDiscriminatorMappingSuccessDataDiscriminatorMappingTextDependentAgentsItems

- `type`: `available` (DependentAvailableAgentIdentifier)
  - `access_level` (enum, required)
    - Allowed values: `admin`, `editor`, `commenter`, `viewer`
  - `created_at_unix_secs` (integer, required)
  - `id` (string, required)
  - `name` (string, required)
  - `referenced_resource_ids` (list of string, optional) — 如果智能体是传递依赖项，则包含该智能体直接依赖资源的 ID。
- `type`: `unknown` (DependentUnknownAgentIdentifier)
  - `id` (string, required)
  - `referenced_resource_ids` (list of string, optional) — 如果智能体是传递依赖项，则包含该智能体直接依赖资源的 ID。

### V1ConvaiKnowledgeBaseSummariesGetResponsesContentApplicationJsonSchemaDiscriminatorMappingSuccessDataDiscriminatorMappingUrlDependentAgentsItems

- `type`: `available` (DependentAvailableAgentIdentifier)
  - `access_level` (enum, required)
    - Allowed values: `admin`, `editor`, `commenter`, `viewer`
  - `created_at_unix_secs` (integer, required)
  - `id` (string, required)
  - `name` (string, required)
  - `referenced_resource_ids` (list of string, optional) — 如果智能体是传递依赖项，则包含该智能体直接依赖资源的 ID。
- `type`: `unknown` (DependentUnknownAgentIdentifier)
  - `id` (string, required)
  - `referenced_resource_ids` (list of string, optional) — 如果智能体是传递依赖项，则包含该智能体直接依赖资源的 ID。

### ValidationErrorLocItems

- string
- integer

## Examples

**Response**

```json
{
  "documents": [
    {
      "access_info": {
        "access_source": "creator",
        "creator_email": "john.doe@example.com",
        "creator_name": "John Doe",
        "is_creator": true,
        "role": "admin"
      },
      "auto_sync_info": {
        "auto_discover": false,
        "auto_remove": false,
        "consec_failures": 0,
        "minimum_frequency_days": 7,
        "next_refresh_by": 1
      },
      "dependent_agents": [
        {
          "access_level": "admin",
          "created_at_unix_secs": 1,
          "id": "string",
          "name": "string",
          "referenced_resource_ids": [
            "string"
          ],
          "type": "available"
        }
      ],
      "folder_parent_id": "string",
      "folder_path": [
        {
          "id": "string"
        }
      ],
      "id": "string",
      "metadata": {
        "created_at_unix_secs": 1,
        "last_updated_at_unix_secs": 1,
        "size_bytes": 1
      },
      "name": "string",
      "supported_usages": [
        "auto"
      ],
      "type": "string",
      "url": "string"
    }
  ],
  "has_more": true,
  "next_cursor": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/knowledge-base"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/knowledge-base';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/convai/knowledge-base"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/convai/knowledge-base")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.elevenlabs.io/v1/convai/knowledge-base")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/knowledge-base');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/knowledge-base");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/convai/knowledge-base")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```