Use the ListDocuments operation to query the list of documents under a knowledge base in a paginated manner.
Prerequisites
-
An AgentStorage instance has been created and its status is
normal, and the endpoint and instance name have been obtained. -
An API Key has been created.
-
The knowledge base to query already exists.
Request parameters
|
Parameter |
Type |
Description |
|
|
string |
The name of the knowledge base. Required. |
|
|
list<string> |
The list of subspaces, up to 10. Required when subspace is enabled. |
|
|
int |
The number of results to return. Default: 10. Maximum: 1000. |
|
|
string |
The pagination token. |
Request example
When you use API Key authentication, pass the instance name and API Key through the x-ots-instancename and x-ots-apikey request headers.
curl -X POST https://<endpoint>/ListDocuments \
-H "x-ots-instancename: <instance-name>" \
-H "x-ots-apikey: <your-api-key>" \
-H "Content-Type: application/json" \
-d '{
"knowledgeBaseName": "product_docs_kb",
"subspace": ["default"],
"maxResults": 10
}'
Response
{
"code": "SUCCESS",
"data": {
"documentDetails": [
{
"docId": "fc6ed97f-28ad-4dc0-9b73-bf4a7d67ab65",
"ossKey": "oss://example-bucket/docs/manual.pdf",
"subspace": "default",
"chunkNum": 1,
"status": "completed",
"createdAt": 1787636583092,
"eTag": "6227CEC56ABFAF47135E4C033FF24C98",
"updatedAt": 1787636583092, "metadata": {"author": "张三", "date": "2026-01-22 10:00:59", "score": 80}
}
],
"nextToken": ""
},
"message": "succeed"
}