Use the GetDocument operation to query the detailed information of a specified document. The data field in the response is an array of document records, and the response field table describes a single record in the array. When you query by ossKey, deleting and recreating the same file may return multiple results that include historical records. To query the status of the current import, use the docId returned by AddDocuments to locate the record.
Prerequisites
-
An AgentStorage instance is created and its status is
normal, and the endpoint and instance name are obtained. -
An API Key is created.
-
The knowledge base and document to query already exist.
Request parameters
|
Parameter |
Type |
Description |
|
|
string |
The name of the knowledge base. Required. |
|
|
string |
The subspace name. Required when subspace is enabled. |
|
|
string |
The document ID. Either this or ossKey. |
|
|
string |
The OSS file path. Either this or docId. |
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>/GetDocument \
-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",
"ossKey": "oss://example-bucket/docs/manual.pdf"
}'
Response
|
Field |
Type |
Description |
|
|
string |
The document ID. |
|
|
string |
The OSS path. |
|
|
string |
The subspace. |
|
|
int |
The number of chunks. |
|
|
string |
The document status: pending/indexing/completed/failed/deleting |
|
|
int |
The creation timestamp. |
|
|
int |
The update timestamp. |
|
|
string |
The document eTag. |
|
|
string |
The failure reason (only when the status is failed). |
|
|
object |
The document metadata. |
{
"code": "SUCCESS",
"data": [
{
"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}
}
],
"message": "succeed"
}