cURL
Create a Knowledge Base and import files in a single call; you can also enable Wiki at creation time.
Example request body for image Q&A:
This endpoint may return the following error codes; for detailed triggers and
Wiki currently supports only auto-update mode: when enabling Wiki,
wikiAutoUpdate must be true. Wiki requires a Flagship knowledge base (pipelineCommercialType=enterprise, with pipelineCommercialCu) and knowledgeScene=basic_document_qa. wikiConfig.extraction.synthesisModelId and extractionGranularity are required; granularity is one of focused / standard / exhaustive.If Wiki configuration validation fails, the Knowledge Base is not created. Otherwise, it is created first and Wiki is enabled asynchronously. Success only means the enable request was accepted. Enabling and generation have no status-query endpoint; confirm the search_type=wiki service is published via List Agents before a trial retrieval.Import parameters and synchronization boundaries
description is optional, allows 0-500 characters, and defaults to an empty string. The top-level sourceType is required and determines which import parameters are validated:
| sourceType | Required import parameters |
|---|---|
DATA_CENTER_FILE | docIds; categoryIds cannot replace it |
DATA_CENTER_CATEGORY | categoryIds; docIds cannot replace it |
DATA_CENTER_STRUCTURED_TABLE | tableIds and columns |
dataSources is optional, and its sourceType cannot replace the top-level field. Importing an existing data-center table does not require connectId, datasourceCode, database, or table. These fields are for custom database sources only; connectId + table cannot replace tableIds.
createIndexTypeandchannelTypeare not available. Do not pass them. Console network requests use an internal gateway and console-specific parameters; do not copy them to call the public API. In console payloads,dataTypemaps tostructureType, andcornerstoneParamis internal, not a public parameter.- Passing
dataSync:truedoes not enable the console's automatic knowledge-index synchronization. After adding files to a category, submit an import job to append the category again. - Category imports do not remove Knowledge Base documents deleted from the dataset. Re-uploading the same file name may produce a new file ID, not replace the old document. Delete both the dataset file and the Knowledge Base document; if the dataset file remains, the next category import will import it again.
metaExtractColumnssupports up to five fields, only at creation; it cannot be added later through the update API.enableSearchandenableLlmdiffer frommetadata_filterat query time.
Knowledge Base type and usage scenario
knowledgeType and knowledgeScene correspond to Knowledge Base Type and Usage Scenario in step 1 of the console creation wizard. They must be supplied together or omitted together — sending only one returns knowledgeType and knowledgeScene cannot be empty. When both are omitted, the system applies defaults based on structureType.
The console only offers a Usage Scenario choice for Document Search. The other types have a fixed scenario filled in automatically. The API allows both fields to be omitted and applies defaults based on structureType. Supply the pair only when a non-default type or scenario is needed.
| knowledgeType | Console label | structureType | Available knowledgeScene |
|---|---|---|---|
document | Document Search | unstructured | basic_document_qa (basic document Q&A)visual_perception_qa (visual understanding, rich text documents)lite_document_qa (express Q&A) |
table | Data Query | structured | basic_table_qa (fixed) |
image | Image Q&A | unstructured | image_qa (fixed) |
multimedia | Audio and Video Search | unstructured | basic_multimedia_qa (fixed) |
- An incompatible
knowledgeTypeandstructureTypepair returnsknowledgeType and structureType do not match. AknowledgeScenethat does not belong to the selected type returnsknowledgeType and knowledgeScene do not match. lite_document_qa(express Q&A) requiressinkTypeto beBUILT_IN. Using the defaultDEFAULTreturnsLite Rag only supports BUILT_IN sink type.visual_perception_qaandimage_qamust specify a multimodal embedding model throughmultimodalEmbeddingModelName(for exampleqwen3-vl-embedding), otherwise the request returnsinvalid multi embedding model.- The
documenttype also has avisual_document_qa(rich media answers) scenario. The API still accepts this value, but the console no longer exposes it, so avoid it for new Knowledge Bases.
Error codes
This endpoint may return the following error codes; for detailed triggers and message, see the error reference.
| code | status_code | Trigger |
|---|---|---|
InvalidParameter | 400 | Type and scene not supplied together or mismatched; ultra-fast Q&A / multimodal parameter constraints not met; wikiAutoUpdate missing or not true when enabling Wiki |
Index.InvalidParameter | 400 | description exceeds 500 characters: Required parameter(description length range[1-500]) missing or invalid, please check the request parameters. Omitted or empty strings are valid |
Index.InvalidParameter | 400 | Missing or empty docIds when sourceType=DATA_CENTER_FILE; the message names file_ids. categoryIds alone is not a substitute |
Index.InvalidParameter | 400 | Missing categoryIds when sourceType=DATA_CENTER_CATEGORY; the message names source_ids. Providing only docIds or using the parameter name source_ids also fails |
Index.InvalidParameter | 400 | Missing top-level sourceType; the message names data_sources. Providing dataSources does not prevent this error |
Index.FileEmptyError | 400 | A file ID in docIds does not exist: fetch empty file list from data center. |
WikiEditionNotSupported | 400 | The knowledge base is not enterprise when enabling Wiki (unspecified specification is treated as Standard) |
WikiSceneNotSupported | 400 | knowledgeScene is not basic_document_qa when enabling Wiki |
WikiConfigInvalid | 400 | An invalid Wiki configuration key was provided; locate it by the field name in message |
Authorizations
string
header
required
DashScope API Key, obtained from the API Key page in the console.
Body
application/jsonobject
Response
200-application/json