列出上传目录
接口说明
读取一个上传目录下的直属子目录。
接口信息
| 字段 | 值 |
|---|---|
| 方法 | GET |
| 路径 | /openapi/v2/knowledge-bases/{knowledgeBaseId}/source-directories |
| Operation ID | listSourceDirectories |
| 鉴权 | Bearer OpenAPI key |
入参
| 名称 | 位置 | 必填 | 类型 | 示例 | 说明 |
|---|---|---|---|---|---|
knowledgeBaseId | path | 是 | string | knowledge-base-11111111-1111-4111-8111-111111111111 | 知识库 API 返回的知识库标识。 |
parentDirectoryId | query | 否 | string | directory-handbook | 上传目录的上级目录标识。列出顶层目录时可以省略或使用 root。 |
limit | query | 否 | integer | 50 | 最多返回的记录数量。部署环境可能采用更低的上限。 |
cursor | query | 否 | string | cursor_123 | 当前接口返回的下一页分页标记。 |
请求体
这个接口没有请求体。
请求示例
bash
curl -X GET "https://openapi.example.com/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-directories?parentDirectoryId=directory-handbook&limit=50" \
-H "Authorization: Bearer <openapi-key>"成功响应
200
返回上传目录中的直属子目录分页。
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
items | 是 | array<SourceDirectory> | 当前分页中的记录。 |
nextCursor | 是 | string | null | 当前接口返回的分页标记。只能在接口和筛选条件不变时继续使用;被拒绝时请移除 cursor 并从第一页重新读取。 |
成功响应示例
json
{
"items": [
{
"directoryId": "directory-11111111-1111-4111-8111-111111111111",
"knowledgeBaseId": "knowledge-base-11111111-1111-4111-8111-111111111111",
"parentDirectoryId": "directory-handbook",
"name": "onboarding",
"relativePath": "handbook/onboarding",
"generatedPath": "pages/handbook/onboarding",
"depth": 2,
"resourceRevision": 1,
"directFileCount": 1,
"descendantFileCount": 1,
"mutable": true,
"deletable": true,
"deleting": false,
"actions": {
"self": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-directories/directory-11111111-1111-4111-8111-111111111111",
"children": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-directories?parentDirectoryId=directory-11111111-1111-4111-8111-111111111111",
"sourceFiles": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/source-files?directoryId=directory-11111111-1111-4111-8111-111111111111",
"generatedTree": "/openapi/v2/knowledge-bases/knowledge-base-11111111-1111-4111-8111-111111111111/tree?parentPath=pages%2Fhandbook%2Fonboarding"
},
"createdAt": "2026-06-17T00:00:00.000Z",
"updatedAt": "2026-06-17T00:00:00.000Z"
}
],
"nextCursor": null
}错误码
下表列出这个接口已声明的全部错误响应。
| HTTP 状态 | 错误码 | 说明 |
|---|---|---|
| 401 | UNAUTHORIZED | Bearer API key 缺失、格式错误、未知、已撤销或已删除。 |
| 404 | NOT_FOUND | 请求的资源不存在。 |
| 422 | VALIDATION_ERROR | 请求未通过校验。 |
| 429 | RATE_LIMITED | 请求超过当前配置的速率限制。 |
| 500 | INTERNAL_ERROR | API 遇到内部错误。 |
| 503 | DATABASE_REPOSITORY_UNAVAILABLE | 当前接口所需的数据暂时不可用。 |