Skip to main content

List Documents

List the documents in a Knowledge Base with pagination support.

Prerequisites

Configure the endpoint and authentication first. See API overview and Authentication.

Endpoint

GET /api/v1/indices/rag/index/files List the documents in a specified knowledge base with pagination support.

Query parameters

FieldRequiredTypeDescription
index_idYesstringKnowledge base ID, corresponding to the pipelineId returned when the knowledge base is created.
page_numberNointegerPage number, starting from 1. Default: 1.
page_sizeNointegerNumber of documents returned per page. Default: 10. Maximum: 100.

Request example

curl -G "$BASE_URL/api/v1/indices/rag/index/files" \
  -H "Authorization: Bearer $BAILIAN_API_KEY" \
  -d "index_id=your_index_id" \
  -d "page_number=1" \
  -d "page_size=20"
BASE_URL is https://{workspace_id}.cn-beijing.maas.aliyuncs.com ({workspace_id} is the workspace ID), and BAILIAN_API_KEY is your Alibaba Cloud Model Studio API key.

Response example

Returns 200 on success.
{
  "code": "Success",
  "status_code": 200,
  "data": {
    "page_number": 1,
    "total_count": 1,
    "rows": [
      {
        "code": "FINISH",
        "connectorId": "conn_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxx",
        "dataSync": false,
        "doc_type": "md",
        "gmt_modified": 1782184640000,
        "message": "索引构建成功",
        "doc_id": "file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxx",
        "categoryName": "默认类目",
        "tags": [],
        "ingestion_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "size": 21,
        "doc_name": "a",
        "canDelete": true,
        "source_id": "cate_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxx",
        "meta_extract_info": [],
        "categoryId": "cate_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_xxxxxx",
        "status": "FINISH"
      }
    ],
    "page_size": 1
  },
  "success": true,
  "message": "success",
  "request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "status": "SUCCESS"
}

Response fields

FieldTypeDescription
codestringResponse code. Success on success.
status_codeintegerHTTP status code.
request_idstringUnique request identifier. Provide this ID when troubleshooting.
dataobjectBusiness data. Sub-fields: page_number (integer, current page number), total_count (integer, total number of documents), rows (array<object>, document list. Element fields: doc_id (string, unique document identifier), doc_name (string, document name), doc_type (string, document type, such as pdf, docx, or txt), code (string, fine-grained processing status code, such as FINISH, PARSE_FAILED, or PIPELINE_JOB_RETRY_IMPORT_ERROR), status (string, coarse-grained processing status, such as FINISH, PARSE_FAILED, or INSERT_ERROR; usually consistent with code, while code provides finer error classification), message (string, processing status description; the error reason on failure), size (integer, file size in bytes), gmt_modified (integer, last modified time as a millisecond Unix timestamp), dataSync (boolean, whether the document is incremental sync data), categoryId (string, ID of the category), categoryName (string, name of the category), connectorId (string, ID of the connector), source_id (string, data source ID), ingestion_id (string, import task ID), tags (array<string>, document tag list), meta_extract_info (array, metadata extraction information), canDelete (boolean, whether the document can be deleted)).
successbooleanWhether the request succeeded.
messagestringMessage. success on success.
statusstringRequest status: SUCCESS or FAILED.

Error codes

HTTP status codeError codeMessageDescription
400Index.InvalidParameterRequired parameter missing or invalid.Invalid request parameters.
401InvalidApiKeyInvalid API-key provided.Authentication failed. The API key is invalid or missing.
Managed Agent API
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration