The kscli doc group — upload files, import from OSS, track parse status, and manage tags
Document management covers file upload, OSS import, parse status tracking, document deletion, and tag maintenance. Once imported into a Knowledge Base, documents are automatically parsed into chunks. This group has 6 commands.
Shared conventions for authentication, workspace ID, global flags, output formats, confirmation prompts, and dry-run mode are covered in the CLI overview. The examples below assume the workspace ID is already set in the config file.
List documents in a Knowledge Base along with their parse status.
Parameters
Output
Examples
Check the execution status of a Knowledge Base import job.
Parameters
Output
Upload local files or directories to the data center, optionally importing them into a Knowledge Base.
Parameters
Output
Delete documents and their chunks from a Knowledge Base.
Parameters
Output
Batch update tags on data center files.
Parameters
Constraints
Batch import files from an authorized OSS bucket into the data center.
Parameters
Output
kscli doc list
List documents in a Knowledge Base along with their parse status.
| Parameter | Type | Required | Description |
|---|---|---|---|
--index-id <id> | string | Yes | Knowledge Base ID |
--page-number <n> | number | No | Page number, default 1 |
--page-size <n> | number | No | Items per page, default 10, range 1–100 |
text mode prints one document per line, highlighting FAILED documents in red:
quiet mode prints one doc_id per line. json mode returns the full result.
A document's
doc_id inside a Knowledge Base is not necessarily the same as its data center file ID — it depends on the import path. For later operations on Knowledge Base documents (such as doc delete or chunk update), always use the doc_id from this command.kscli doc status
Check the execution status of a Knowledge Base import job.
| Parameter | Type | Required | Description |
|---|---|---|---|
--index-id <id> | string | Yes | Knowledge Base ID |
--job-id <id> | string | Yes | Import job ID, returned by kb create or doc upload |
--page-number <n> | number | No | Page number, default 1 |
--page-size <n> | number | No | Items per page |
--wait | switch | No | Poll until the job reaches a terminal state |
--poll-interval <seconds> | number | No | Polling interval in seconds, default 5 |
quiet mode prints the overall job status. json mode returns the full result including per-document status.
Notes
- The overall job status is
PENDING,RUNNING, orCOMPLETED. - An individual document may fail to parse (for example
PARSE_FAILED); the command then exits non-zero and shows the server error message. - A
SystemErrorfrom the server usually means the job ID does not exist — confirm it from the output ofdoc uploadorkb create.
kscli doc upload
Upload local files or directories to the data center, optionally importing them into a Knowledge Base.
| Parameter | Type | Required | Description |
|---|---|---|---|
--file <path> | array | Yes | Local file or directory path, repeatable. Directories are scanned recursively and unsupported formats are skipped |
--index-id <id> | string | No | Import into this Knowledge Base after upload; all files become one import job |
--category-id <id> | string | No | Target data center category, defaults to the workspace default category |
--tag <text> | array | No | File tag, repeatable, applied to every uploaded file |
--wait | switch | No | Poll the import job to a terminal state; requires --index-id |
--poll-interval <seconds> | number | No | Polling interval in seconds, default 5 |
quiet mode prints one file ID per line. json mode returns files (paths and file IDs), skipped, index_id, ingestion_id, and final_status.
Supported file formats
.pdf, .doc, .docx, .ppt, .pptx, .xls, .xlsx, .csv, .md, .txt, .html, .png, .jpg, .jpeg, .bmp, .gif
Notes
- When scanning directories recursively,
node_modules,.git, and similar directories are skipped automatically. - Multiple files are uploaded sequentially. If some fail, the file IDs already uploaded are listed in the error message so you can resume or clean up.
- Before uploading a large batch, run
--dry-run --verboseto review which files would be uploaded and skipped.
kscli doc delete
Delete documents and their chunks from a Knowledge Base.
| Parameter | Type | Required | Description |
|---|---|---|---|
--index-id <id> | string | Yes | Knowledge Base ID |
--doc-id <id> | array | Yes | Document ID, repeatable |
--yes | switch | No | Skip the confirmation prompt |
quiet mode prints one deleted doc_id per line. json mode returns the list of IDs actually deleted.
Notes
- This only removes documents from the Knowledge Base index; the data center source files remain. To delete source files, use
kscli file delete. - Take
doc_idfromkscli doc list --quiet, not from the file ID returned bydoc upload. - Deletion is asynchronous: the command returns success immediately, but
doc listmay still show the document briefly — it clears after roughly 30 seconds. - The output lists the IDs actually deleted, which may differ in count from the request; any difference is warned about on stderr.
kscli doc tag
Batch update tags on data center files.
| Parameter | Type | Required | Description |
|---|---|---|---|
--doc-id <id> | array | Yes | Data center file ID, repeatable, up to 20 per call |
--tag <text> | array | Yes | Tag, repeatable, applied to every --doc-id |
--mode <mode> | string | No | Update mode, append (default) or overwrite |
- Up to 20
--doc-idvalues per call - Up to 100 tags; each tag up to 32 chars; total tag length up to 700 chars
quiet mode prints nothing. json mode returns the full result.
The same tag set is applied to every --doc-id. To tag different files differently, run the command multiple times.
Examples
kscli doc import-oss
Batch import files from an authorized OSS bucket into the data center.
| Parameter | Type | Required | Description |
|---|---|---|---|
--bucket <name> | string | Yes | Authorized OSS bucket name |
--region <id> | string | Yes | OSS region ID, such as cn-beijing |
--oss-key <key> | array | Yes | OSS object key, repeatable, up to 10 per call |
--category-id <id> | string | No | Target data center category, defaults to the default category |
--tag <text> | array | No | File tag, repeatable, up to 10 |
--overwrite | switch | No | Overwrite files previously imported from the same OSS keys |
quiet mode prints one file ID per line. json mode returns each file's ID, status, and OSS key.
Notes
- The bucket must be authorized for the platform service beforehand. In the RAM console, confirm the
AliyunServiceRoleForBailianservice-linked role is correctly authorized for the bucket, otherwise the import returns a permission error. - The imported file name is taken from the last segment of the OSS key.
--overwritereplaces the previously imported file and produces a new file ID, invalidating the old one. If any Knowledge Base or script references the old ID, update it accordingly.