Skip to main content

Submit Import Job

Append documents to an existing Knowledge Base. Returns the import job ID (ingestionId), which you can track through the Get Job Status endpoint.

Prerequisites

Get an API key and a workspace ID, and configure authentication first. See API overview and Authentication.

Endpoint

POST /api/v1/indices/rag/index/job/create Append documents to an existing Knowledge Base.

Request body

FieldRequiredTypeDescription
indexIdYesstringKnowledge Base ID.
sourceTypeNostringData source type. DATA_CENTER_CATEGORY imports by category (requires categoryIds); DATA_CENTER_FILE imports by file (requires docIds). When this parameter is omitted, all files in the entire data center are imported by default — use with caution.
categoryIdsNoarray<string>Category ID list. Required when sourceType is DATA_CENTER_CATEGORY.
docIdsNoarray<string>File ID list. Required when sourceType is DATA_CENTER_FILE. The parameter name is docIds — not documentIds or fileIds. With a wrong name, the server ignores the parameter and returns Index.InvalidParameter (Required parameter(dataSource.fileIds) missing).
chunkModeNostringChunk mode, which sets a segmentation strategy only for the files in this import (independent of the global configuration made when the Knowledge Base was created). h1 to h5 split by the corresponding heading level (h1 is the level-1 heading, and so on, down to h5); length splits by fixed length; page splits by page; regex splits by a custom regular expression.
chunkSizeNointegerChunk size in characters. Valid range: 1-6000. Required when chunkMode is length. When chunkMode is h1 to h5, a specified value is also taken into account (default 500 when not passed).
overlapSizeNointegerChunk overlap size in characters. Valid range: 0-1024. Only takes effect when chunkMode is length; has no effect when splitting by headings (h1 to h5).
separatorNostringChunk separator, which only takes effect when chunkMode is regex. Required when chunkMode is regex, otherwise the request returns Index.InvalidParameter (Separator can't be null).
enableHeadersNobooleanWhether to enable heading extraction. Default: false.

Request example

curl -X POST "$BASE_URL/api/v1/indices/rag/index/job/create" \
  -H "Authorization: Bearer $BAILIAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "indexId": "your-kb-id",
    "categoryIds": ["your-category-id"]
  }'
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": {
    "updated_at": 1782191904527,
    "created_at": 1782191904527,
    "ingestionId": "your-ingestion-id",
    "pipelineId": "your-kb-id",
    "status": "PENDING"
  },
  "success": true,
  "message": "success",
  "request_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "status": "SUCCESS"
}

Response fields

FieldTypeDescription
codestringResponse code. Success when successful.
status_codeintegerHTTP status code.
request_idstringUnique request identifier. Provide this ID when troubleshooting.
successbooleanWhether the request succeeded.
messagestringResponse message. success when successful.
statusstringRequest status: SUCCESS or FAILED.
dataobjectResponse data. Sub-fields: pipelineId (string, Knowledge Base ID), ingestionId (string, import job ID), status (string, job status; PENDING after submission).

Error codes

HTTP status codeError code (code)Description
400Index.InvalidParameterInvalid request parameters: Required parameter missing or invalid.
401InvalidApiKeyInvalid or missing API key: Invalid API-key provided.
Managed Agent API
Flow Agent API
Sandbox API
RAG API
Long-term Memory
ParseX API
Security API
Framework Integration