Skip to main content
Knowledge base

SubmitIndexAddDocumentsJob

Appends parsed files to a specified knowledge base.

Operation description

  • This operation does not support data query or image Q&A knowledge bases. For information about how to update data query or image Q&A knowledge bases, see the knowledge base update instructions in Knowledge base.
  • Resource Access Management (RAM) users must first obtain API permissions for Model Studio (requiring AliyunBailianDataFullAccess, which includes the sfm:SubmitIndexAddDocumentsJob permission), and join a workspace before invoking this operation. Alibaba Cloud accounts can invoke this operation directly without authorization. Use the latest Model Studio SDK to invoke this operation.
  • Before invoking this operation, make sure that your knowledge base has been created and has not been deleted (that is, the knowledge base ID IndexId is valid).
  • Before invoking this operation, invoke the AddFile operation to upload the files you want to append to Model Studio.
  • After invoking this operation, the node requires time to execute and may take several hours during peak periods. Do not submit duplicate requests before the node is complete. To query the node execution status, invoke the GetIndexJobStatus operation. The Documents file list returned by this operation contains all files in this append job (uniquely identified by the job_id you provide), and you can check whether each file was imported (parsed) successfully. Note that invoking GetIndexJobStatus too frequently will trigger rate limiting. Do not exceed a frequency of 20 times per minute.
  • After this operation is invoked successfully, it takes some time to execute. Do not submit duplicate requests before the response is returned. This operation does not have idempotence.
Rate limit: Frequent calls to this operation will be throttled. Do not exceed 10 calls per second. If throttled, retry later.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage. Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:
  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.
  • API: The API that you can call to perform the action.
  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.
  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.
    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.
    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.
  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.
  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

sfm:SubmitIndexAddDocumentsJob

create

*All Resource

*

NoneNone

Request syntax

POST /{WorkspaceId}/index/add_documents_to_index HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

WorkspaceId

string

Yes

The workspace ID to which the knowledge base belongs. For information about how to obtain the workspace ID, see How to use a workspace.

llm-3shx2gu255oqxxxx

Request parameters

Parameter

Type

Required

Description

Example

IndexId

string

Yes

The knowledge base ID, which is the Data.Id returned by the CreateIndex operation.

79c0alxxxx

SourceType

string

Yes

The data source type. Valid values:

  • DATA_CENTER_CATEGORY: category type. Imports all documents under specified categories in Application Data. Multiple categories are supported.

  • DATA_CENTER_FILE: document type. Imports specified files from Application Data. Multiple files are supported.

If this parameter is set to DATA_CENTER_CATEGORY, you must specify the CategoryIds parameter. If this parameter is set to DATA_CENTER_FILE, you must specify the DocumentIds parameter.

Valid values:

  • DATA_CENTER_CATEGORY :

    category type.

  • DATA_CENTER_FILE :

    document type.

DATA_CENTER_FILE

DocumentIds

array

No

The list of file IDs.

string

No

The file ID, which is the FileId returned by the AddFile operation. You can also obtain the file ID on the Application Data page by clicking the ID icon next to the file name.

doc_ea4a504d9ce545508d8aa6d90371bf54xxxxxxxx

CategoryIds

array

No

The list of category IDs.

string

No

The category ID, which is the CategoryId returned by the AddCategory operation. You can also obtain the category ID on the Application Data Files tab by clicking the ID icon next to the category.

cate_21a407a3372c4ba7aedc649709143f0cxxxxxxxx

ChunkMode

string

No

This parameter is not yet available. Do not specify this parameter.

length

Separator

string

No

This parameter is not yet available. Do not specify this parameter.

(?<=。)

ChunkSize

integer

No

This parameter is not yet available. Do not specify this parameter.

128

OverlapSize

integer

No

This parameter is not yet available. Do not specify this parameter.

16

EnableHeaders

boolean

No

Specifies whether to enable header assembly for Excel files. When enabled, the knowledge base treats the first row of all xlsx and xls files as headers and automatically appends them to each text chunk (data row), preventing the large language model from treating headers as regular data rows.

Enable this feature only when all imported files are in xlsx or xls format and contain headers. Otherwise, leave it disabled.

Valid values:

  • true: Enabled.

  • false: Disabled.

Default value: false.

Valid values:

  • true :

    Enabled.

  • false :

    Disabled.

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 data returned by the operation.

Id

string

The task ID, also known as JobId.

42687eb254a34802bed398357f5498ae

Status

string

The status code returned by the operation.

200

Success

boolean

Indicates whether the operation was successful. Valid values:

  • true: Successful.

  • false: Failed.

true

Message

string

The error message.

Required parameter(%s) missing or invalid, please check the request parameters.

Code

string

The error 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

400IdempotentParameterMismatchThe 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.
See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.
SubmitIndexAddDocumentsJob - Alibaba Cloud Model Studio