Updated on 2025-08-13 GMT+08:00

Uploading Files

Function

This API is used to upload a file to a knowledge base.

URI

POST /v1/koosearch/repos/{repo_id}/files

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

repo_id

Yes

String

Knowledge base ID. The value is a string of 1 to 64 characters and can contain only digits, letters, hyphens (-), and underscores (_).

How to obtain:

Log in to the KooSearch experience platform. In the navigation tree on the left, choose Knowledge Bases to view knowledge base IDs. Each knowledge base has a unique ID stored in the vector database.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Parameter description:

Token used for API authentication. For how to obtain the token, see section 3.2 "Authentication."

Constraints:

N/A.

Table 3 FormData parameters

Parameter

Mandatory

Type

Description

file

Yes

File

Files to be uploaded.

category

No

String

Document directory, which corresponds to the leaf nodes in the directory tree. This parameter has only one value.

The recommended format is "leaf node directory name (directory ID)", for example, patent (3166-1).

tags

No

Array of strings

Document tags. You can use tags to automatically group documents for filtering.

Precautions:
        1. You are advised to use case-insensitive tags. For example, `Approved` and `approved` are the same tag.
        2. A document can have one or more tags.
        Do not use reserved characters (```+ - = && || > <!). Otherwise, you will need to escape them in queries. ( ) { } [ ] ^ " ~ * ? : \ /```

file_extract_req

No

String

Document-level parsing parameter.

The following is an example:

{"mode":1,"language":"CHINESE","parse_conf":{"ocr_enabled":true,"image_enabled":true,"image_conf":"IMAGE","header_footer_enabled":false,"catalog_enabled":false},"split_conf":{"split_mode":"RULE","chunk_size":500,"separators":[". ",". ","! ","! ","? ","?"],"title_level":3,"combine_title":true,"merge_titles":true,"rule_regexs":["^Chapter ([1-9]{1,7})","^Section ([1-9]{1,7}),"^Clause([1-9]{1,7})"]}}

chat_id

No

String

chatId is used to upload the files of a chat

Response Parameters

Status code: 201

Table 4 Response body parameters

Parameter

Type

Description

file_id

String

File ID.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error Code

error_msg

String

Error description

Status code: 500

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error Code

error_msg

String

Error description

Example Requests

POST https://{endpoint}/v1/koosearch/repos/0ac621de-3624-454e-adcf-8c5b4cf7317c/files

Example Responses

Status code: 201

Response body of the API for uploading documents.

{
  "file_id" : "5c46f7e31c5c4587ac99ef0da0502470"
}

Status Codes

Status Code

Description

201

Response body of the API for uploading documents.

400

Incorrect request body parameter

500

Internal error

Error Codes

See Error Codes.