SubmitIndexAddDocumentsJob

Updated at:
Copy as MD

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 knowledge bases, see the knowledge base documentation.

  • A RAM user (sub-account) can call this API only after being granted the required api permission for Alibaba Cloud Model Studio (specifically, the AliyunBailianDataFullAccess policy, which includes the sfm:SubmitIndexAddDocumentsJob permission) and joining a workspace. An Alibaba Cloud account can call this API directly without authorization. We recommend using the latest version of the Alibaba Cloud Model Studio SDK to call this API.

  • 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 Documents file list returned by the GetIndexJobStatus API contains all files for the job, which is uniquely identified by the job_id you 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.

  • A successful API call indicates the job has been submitted for processing, which takes time. This API is not idempotent, so do not send duplicate requests; doing so will create multiple jobs.

Rate limiting: This API is limited to 10 calls per second. If you exceed this limit, wait before retrying.

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

*

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 that contains the knowledge base. To obtain the ID, see How to use workspaces.

llm-3shx2gu255oqxxxx

Request parameters

Parameter

Type

Required

Description

Example

IndexId

string

Yes

The knowledge base ID. This is the Data.Id returned by the CreateIndex API.

79c0alxxxx

SourceType

string

Yes

The type of the data source. Valid values:

  • DATA_CENTER_CATEGORY: Imports all documents from specified categories in application data. You can import documents from multiple categories.

  • DATA_CENTER_FILE: Imports specified files from application data. You can import multiple files.

Note

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

Valid values:

  • DATA_CENTER_CATEGORY :

    Imports documents by category.

  • DATA_CENTER_FILE :

    Imports documents by file.

DATA_CENTER_FILE

DocumentIds

array

No

A list of file IDs.

string

No

The file ID. This is the FileId returned by the AddFile API. You can also obtain the ID on the application data page by clicking the ID icon next to the file name.

doc_ea4a504d9ce545508d8aa6d90371bf54xxxxxxxx

CategoryIds

array

No

A list of category IDs.

string

No

The category ID. This is the CategoryId returned by the AddCategory API. You can also obtain the ID on the File tab of the application data page by clicking the ID icon next to the category name.

cate_21a407a3372c4ba7aedc649709143f0cxxxxxxxx

ChunkMode

string

No

Note

This parameter is not available. Do not specify it.

length

Separator

string

No

Note

This parameter is not available. Do not specify it.

(?<=。)

ChunkSize

integer

No

Note

This parameter is not available. Do not specify it.

128

OverlapSize

integer

No

Note

This parameter is not available. Do not specify it.

16

EnableHeaders

boolean

No

Specifies whether to include Excel file headers. If set to true, the knowledge base treats the first row of all .xlsx and .xls files as the header and automatically prepends it to each text chunk (data row). This prevents the large language model (LLM) from misinterpreting the header as a regular data row.

Note

Enable this parameter only if all imported documents are Excel files that contain a header.

Valid values:

  • true: Enabled.

  • false: Disabled.

Default value: false.

Valid values:

  • true :

    Enabled

  • false :

    Disabled

false

Response elements

Element

Type

Description

Example

object

The response object.

RequestId

string

The request ID.

778C0B3B-xxxx-5FC1-A947-36EDD13606AB

Data

object

The business data.

Id

string

The job ID, also known as JobId.

42687eb254a34802bed398357f5498ae

Status

string

The response status code.

200

Success

boolean

Indicates whether the request was successful. Valid values:

  • true: The request was successful.

  • false: The request failed.

true

Message

string

The error message returned on failure.

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

Code

string

The error code returned on failure.

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.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.