AddDocuments

Updated at:
Copy as MD

Registers files that have been uploaded to the knowledge base storage as knowledge base documents and **automatically triggers parsing** (chunking and embedding). Supports two types of import: - `LOCAL_UPLOAD`: Used with the `GetKnowledgeBasePreSignedUrl` direct upload process. This operation only registers the files and does not verify whether the files have been actually uploaded. Therefore, you must complete the PUT upload first. - `OSS_IMPORT`: Imports files from an external OSS bucket. This operation creates an asynchronous import task and returns the `knowledge_import_task_id`. The system downloads and registers the files in the background. A maximum of 100 files can be processed at a time.

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

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /api/v1/datasets/{datasetId}/documents/addDocuments HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

datasetId

string

No

The ID of the knowledge base.

kd-03ec1e2385fcf

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body.

KnowledgeBaseId

string

No

The ID of the knowledge base.

kb-3bd02617e9be335f

ImportType

string

No

The import type.

LOCAL_UPLOAD

StrategyId

string

No

The ID of the processing strategy.

kb-strategy-7043984ca395eabd

Documents

array<object>

No

The list of documents.

object

No

The imported document.

Path

string

No

The document path, which is the file name or relative path used during upload. It must be consistent with the pre-signed request.

2026_06_23_17_49_52WwGSUezpG2u2iHWxyYGzkf9KtormhkxN/CHANGELOG.md

Name

string

No

The name of the document.

CHANGELOG.md

Size

integer

No

The size of the file.

1024

StrategyId

string

No

The ID of the processing strategy.

kb-strategy-7043984ca395eabd

Dedup

object

No

The deduplication configuration.

ContentDedup

boolean

No

Specifies whether to enable content deduplication.

true

DocNameDedup

boolean

No

Specifies whether to enable document name deduplication.

true

MetaFields

any

No

The batch tag configuration. The key must be a tag field defined in the knowledge base. The value supports the string, int64, float32, bool, and list data types.

{"department":"legal","topics":["policy","contract"],"reviewed":true}

dingTalkConfiguration

object

No

This parameter is not supported and is ignored.

userId

string

No

This parameter is not supported and is ignored.

ignore

appId

string

No

This parameter is not supported and is ignored.

ignore

appPassword

string

No

This parameter is not supported and is ignored.

ignore

knowledgeType

string

No

This parameter is not supported and is ignored.

ignore

knowledgeId

string

No

This parameter is not supported and is ignored.

ignore

parentId

string

No

Defaults to root when omitted.

root

Response elements

Element

Type

Description

Example

object

Schema of Response

requestId

string

The request ID.

DDDBE0E5-4314-156F-B7F1-C4BCFD25A509

data

object

The response data.

errors

array

The list of errors.

string

The error message.

Failed to add the document

documents

array<object>

The list of documents.

object

The document.

id

string

The document ID.

doc-123

name

string

The name of the document.

example.pdf

datasetId

string

The ID of the knowledge base.

kb-123

chunkMethod

string

The chunking method.

naive

run

string

The processing status.

RUNNING

progress

number

The processing progress.

0

size

integer

The size of the file.

1024

location

string

The object path.

uploaded/doc-id/example.pdf

suffix

string

The file extension.

pdf

thumbnail

string

The thumbnail.

""

tokenCount

integer

The number of tokens.

0

chunkCount

integer

The number of chunks.

0

code

integer

The response status code.

0

message

string

The response message.

success

accessDeniedDetail

string

The access denial details.

{"PolicyType":"AccountLevelIdentityBasedPolicy","AuthPrincipalOwnerId":"1234567890123456","AuthPrincipalType":"SubUser","AuthPrincipalDisplayName":"1234567890123456","NoPermissionType":"ImplicitDeny","AuthAction":"milvusknowledgebase:ListDatasets"}

success

boolean

Indicates whether the request is successful.

true

httpStatusCode

integer

The HTTP status code.

403

{
  "code": 0,
  "message": "success",
  "requestId": "DDDBE0E5-4314-156F-B7F1-C4BCFD25A509",
  "success": true,
  "data": {
    "errors": [],
    "documents": [
      {
        "id": "a38f814a914f11f19f10b19d12783d11",
        "name": "contract-2026.md",
        "datasetId": "kd-8b682030a90e5",
        "chunkMethod": "naive",
        "run": "RUNNING",
        "progress": 0,
        "size": 189385,
        "location": "uploaded/a38f814a914f11f19f10b19d12783d11/contract-2026.md",
        "suffix": "md",
        "thumbnail": "",
        "tokenCount": 0,
        "chunkCount": 0
      }
    ]
  }
}

Examples

Success response

JSON format

{
  "requestId": "DDDBE0E5-4314-156F-B7F1-C4BCFD25A509",
  "data": {
    "errors": [
      "Failed to add the document"
    ],
    "documents": [
      {
        "id": "doc-123",
        "name": "example.pdf",
        "datasetId": "kb-123",
        "chunkMethod": "naive",
        "run": "RUNNING",
        "progress": 0,
        "size": 1024,
        "location": "uploaded/doc-id/example.pdf",
        "suffix": "pdf",
        "thumbnail": "\"\"",
        "tokenCount": 0,
        "chunkCount": 0
      }
    ]
  },
  "code": 0,
  "message": "success",
  "accessDeniedDetail": "{\"PolicyType\":\"AccountLevelIdentityBasedPolicy\",\"AuthPrincipalOwnerId\":\"1234567890123456\",\"AuthPrincipalType\":\"SubUser\",\"AuthPrincipalDisplayName\":\"1234567890123456\",\"NoPermissionType\":\"ImplicitDeny\",\"AuthAction\":\"milvusknowledgebase:ListDatasets\"}",
  "success": true,
  "httpStatusCode": 403
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.