SubmitIndexAddDocumentsJob
Adds parsed files to the specified knowledge base.
Operation description
- This API does not support knowledge bases for data queries or image Q&A. To update these types of knowledge bases, see the instructions on updating knowledge bases in the knowledge base documentation.
- A RAM user (sub-account) must first obtain the API permission for Alibaba Cloud Model Studio (the
AliyunBailianDataFullAccesspolicy, which includes the sfm:SubmitIndexAddDocumentsJob permission point) and join a workspace before calling this API. An Alibaba Cloud account (primary account) can call this API directly without authorization. We recommend that you call this API using the latest version of the Alibaba Cloud Model Studio SDK. - Before calling this API, ensure your knowledge base exists and has a valid knowledge base ID (
IndexId). - Before calling this API, you must first upload files to Alibaba Cloud Model Studio using the AddFile API.
- After calling this API, the job runs in the background and may take several hours to complete, especially during peak times. Do not submit duplicate requests until the job is complete. To check the job status, call the GetIndexJobStatus API. The
Documentsfile list returned by the GetIndexJobStatus API contains all files for the job, which is uniquely identified by thejob_idyou provided. You can check this list to verify whether each file was imported (parsed) successfully. Note that frequent calls to the GetIndexJobStatus API are subject to rate limiting. Do not exceed 20 calls per minute. - After this API is called successfully, the job takes some time to run. Do not submit duplicate requests before the response is returned. This API is not idempotent.
Rate limiting: Frequent calls to this API are subject to rate limiting. Do not exceed 10 calls per second. If you are rate-limited, retry later.
Try it now
You can run this API directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After a successful run, OpenAPI Explorer can automatically generate SDK code examples.
RAM authorization
The following table describes the authorization information for this API. You can use the Action element in RAM permission policy statements to grant RAM users or RAM roles the permission to call this API. For more information:
-
Operation: the specific permission.
-
Access level: the access level of each operation. Valid values: Write, Read, or List.
-
Resource type: the resource types that support authorization for the operation. For more information:
- Required resource types are marked with a leading asterisk (*).
- For operations that do not support resource-level authorization,
All Resourcesis used.
-
Condition key: the condition keys defined by the cloud service itself.
-
Dependent action: other permissions required to successfully perform the operation. The caller must have the permissions of all dependent actions for the operation to succeed.
Operation | Access level | Resource type | Condition key | Dependent action |
|---|---|---|---|---|
sfm:SubmitIndexAddDocumentsJob | create | *All Resources
| None | None |
Request syntax
POST /{WorkspaceId}/index/add_documents_to_index HTTP/1.1
Path Parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| WorkspaceId | string | Yes | The ID of the workspace to which the knowledge base belongs. For information about how to obtain it, see How to use workspaces. | llm-3shx2gu255oqxxxx |
Request parameters
Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| IndexId | string | Yes | The knowledge base ID. This is the | 79c0alxxxx |
| SourceType | string | Yes | The type of the data source. Valid values:
If you set this parameter to Valid values:
| DATA_CENTER_FILE |
| DocumentIds | array | No | A list of file IDs. | |
string | No | The file ID. This is the | doc_ea4a504d9ce545508d8aa6d90371bf54xxxxxxxx | |
| CategoryIds | array | No | A list of category IDs. | |
string | No | The category ID. This is the | cate_21a407a3372c4ba7aedc649709143f0cxxxxxxxx | |
| ChunkMode | string | No | The custom chunking mode. This setting applies only to the documents added in the current job. For more information, see knowledge base. Valid values (you can specify only one value):
If this parameter is not set, intelligent chunking is used by default. | length |
| Separator | string | No | The sentence-split delimiter, which takes effect only when When you use intelligent chunking (when | (?<=。) |
| ChunkSize | integer | No | The chunk size. Specifies the maximum number of characters for each text chunk. This setting applies only to the documents added in the current job. If a text segment exceeds this size, the behavior depends on the chunking mode:
The value must be in the range of [1-6000]. If this parameter is not specified, the default value 500 is used. For more information, see knowledge base. If you specify a | 128 |
| OverlapSize | integer | No | The chunk overlap length (applies only to the files appended this time). It indicates the number of characters that overlap between the current text chunk and the previous text chunk. For more information, see knowledge base. The value must be in the range of [0-1024]. If this parameter is not specified, the default value 100 is used. The value of | 16 |
| EnableHeaders | boolean | No | Specifies whether the headers of Excel files support concatenation. If enabled, the knowledge base treats the first row of all xlsx and xls files as the header and automatically concatenates it into each text chunk (data row). This prevents the large language model (LLM) from misinterpreting the header as a regular data row. We recommend enabling this parameter only when all imported files are in xlsx or xls format and contain headers; otherwise, there is no need to enable it. Valid values:
Default value: false. Valid values:
| false |
| Extra | object | No | ||
| uniqueId | string | No |
Response elements
Element | Type | Description | Example |
|---|---|---|---|
object | Schema of Response | ||
| RequestId | string | The request ID. | 778C0B3B-xxxx-5FC1-A947-36EDD13606AB |
| Data | object | The business fields returned by the API. | |
| Id | string | The job ID, also known as | 42687eb254a34802bed398357f5498ae |
| Status | string | The status code returned by the API. | 200 |
| Success | boolean | Indicates whether the request was successful. Valid values:
| true |
| Message | string | The error message. | Required parameter(%s) missing or invalid, please check the request parameters. |
| Code | string | The error status code. | Index.InvalidParameter |
Examples
Success response
JSON format
{
"RequestId": "778C0B3B-xxxx-5FC1-A947-36EDD13606AB",
"Data": {
"Id": "42687eb254a34802bed398357f5498ae"
},
"Status": "200",
"Success": true,
"Message": "Required parameter(%s) missing or invalid, please check the request parameters.",
"Code": "Index.InvalidParameter"
}
Error codes
HTTP status code | Error code | Error message | Description |
|---|---|---|---|
| 400 | IdempotentParameterMismatch | The request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical. |
Visit the Error Center to view more error codes.
Release notes
For more information, see change details.