Update Knowledge Base
Updates a knowledge base. Only the fields included in the request body are changed.
curl --request PATCH \
--url https://{api_base_url}/datasets/{dataset_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "<string>",
"embedding_model": "<string>",
"embedding_model_provider": "<string>",
"external_knowledge_api_id": "<string>",
"external_knowledge_id": "<string>",
"external_retrieval_model": {
"score_threshold": 123,
"score_threshold_enabled": true,
"top_k": 123
},
"name": "<string>",
"partial_member_list": [
{
"user_id": "<string>"
}
]
}
'import requests
url = "https://{api_base_url}/datasets/{dataset_id}"
payload = {
"description": "<string>",
"embedding_model": "<string>",
"embedding_model_provider": "<string>",
"external_knowledge_api_id": "<string>",
"external_knowledge_id": "<string>",
"external_retrieval_model": {
"score_threshold": 123,
"score_threshold_enabled": True,
"top_k": 123
},
"name": "<string>",
"partial_member_list": [{ "user_id": "<string>" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
description: '<string>',
embedding_model: '<string>',
embedding_model_provider: '<string>',
external_knowledge_api_id: '<string>',
external_knowledge_id: '<string>',
external_retrieval_model: {score_threshold: 123, score_threshold_enabled: true, top_k: 123},
name: '<string>',
partial_member_list: [{user_id: '<string>'}]
})
};
fetch('https://{api_base_url}/datasets/{dataset_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/datasets/{dataset_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'description' => '<string>',
'embedding_model' => '<string>',
'embedding_model_provider' => '<string>',
'external_knowledge_api_id' => '<string>',
'external_knowledge_id' => '<string>',
'external_retrieval_model' => [
'score_threshold' => 123,
'score_threshold_enabled' => true,
'top_k' => 123
],
'name' => '<string>',
'partial_member_list' => [
[
'user_id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/datasets/{dataset_id}"
payload := strings.NewReader("{\n \"description\": \"<string>\",\n \"embedding_model\": \"<string>\",\n \"embedding_model_provider\": \"<string>\",\n \"external_knowledge_api_id\": \"<string>\",\n \"external_knowledge_id\": \"<string>\",\n \"external_retrieval_model\": {\n \"score_threshold\": 123,\n \"score_threshold_enabled\": true,\n \"top_k\": 123\n },\n \"name\": \"<string>\",\n \"partial_member_list\": [\n {\n \"user_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://{api_base_url}/datasets/{dataset_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"<string>\",\n \"embedding_model\": \"<string>\",\n \"embedding_model_provider\": \"<string>\",\n \"external_knowledge_api_id\": \"<string>\",\n \"external_knowledge_id\": \"<string>\",\n \"external_retrieval_model\": {\n \"score_threshold\": 123,\n \"score_threshold_enabled\": true,\n \"top_k\": 123\n },\n \"name\": \"<string>\",\n \"partial_member_list\": [\n {\n \"user_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/datasets/{dataset_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"<string>\",\n \"embedding_model\": \"<string>\",\n \"embedding_model_provider\": \"<string>\",\n \"external_knowledge_api_id\": \"<string>\",\n \"external_knowledge_id\": \"<string>\",\n \"external_retrieval_model\": {\n \"score_threshold\": 123,\n \"score_threshold_enabled\": true,\n \"top_k\": 123\n },\n \"name\": \"<string>\",\n \"partial_member_list\": [\n {\n \"user_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"app_count": 0,
"author_name": "admin",
"built_in_field_enabled": true,
"chunk_structure": null,
"created_at": 1741267200,
"created_by": "ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4",
"data_source_type": null,
"description": "Technical documentation for the product API",
"doc_form": "text_model",
"doc_metadata": [],
"document_count": 0,
"embedding_available": true,
"embedding_model": "text-embedding-3-small",
"embedding_model_provider": "langgenius/openai/openai",
"enable_api": true,
"external_knowledge_info": null,
"external_retrieval_model": null,
"icon_info": null,
"id": "c42e2a6e-40b3-4330-96f8-f1e4d768e8c9",
"indexing_technique": "high_quality",
"is_multimodal": false,
"is_published": false,
"maintainer": "admin",
"name": "Product Documentation",
"partial_member_list": [],
"permission": "only_me",
"pipeline_id": null,
"provider": "vendor",
"retrieval_model_dict": {
"reranking_enable": false,
"reranking_mode": null,
"reranking_model": {
"reranking_model_name": "",
"reranking_provider_name": ""
},
"score_threshold": null,
"score_threshold_enabled": false,
"search_method": "semantic_search",
"top_k": 3,
"weights": null
},
"runtime_mode": null,
"summary_index_setting": null,
"tags": [],
"total_available_documents": 0,
"total_documents": 0,
"updated_at": 1741267200,
"updated_by": "ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4",
"word_count": 0
}Authorizations
Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).
Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).
Path Parameters
Knowledge base ID, from List Knowledge Bases. For a scoped key, copy the ID from the Dify URL.
Body
Description of the knowledge base.
400Embedding model name. Use the model field from Get Available Models with model_type=text-embedding.
Embedding model provider identifier, formatted as organization/plugin_name/provider_name (e.g. langgenius/openai/openai). A bare name like openai expands to langgenius/<name>/<name> and works only for langgenius-published plugins.
Get valid values from the provider field of Get Available Models with model_type=text-embedding.
ID of the external knowledge API connection.
ID of the external knowledge base.
Retrieval settings for external knowledge bases.
Show child attributes
Show child attributes
high_quality uses embedding models for precise search; economy uses keyword-based indexing.
high_quality, economy Name of the knowledge base.
1 - 40List of team members with access when permission is partial_members.
Show child attributes
Show child attributes
Controls who can access this knowledge base. only_me restricts to the creator, all_team_members grants access to the entire workspace, partial_members grants access to specified members.
only_me, all_team_members, partial_members Retrieval model configuration. Controls how chunks are searched and ranked when querying this knowledge base.
Show child attributes
Show child attributes
Response
Knowledge base updated successfully.
Number of applications currently using this knowledge base.
Display name of the creator.
Whether built-in metadata fields (e.g., document_name, uploader) are enabled.
Chunk structure configuration.
Creation timestamp (Unix epoch in seconds).
ID of the user who created the knowledge base.
Data source type of the documents, null if not yet configured.
Optional text describing the purpose or contents of the knowledge base.
Document chunking mode. text_model for standard text chunking, hierarchical_model for parent-child structure, qa_model for QA pair extraction.
Metadata field definitions for the knowledge base.
Show child attributes
Show child attributes
Total number of documents in the knowledge base.
Whether the configured embedding model is currently available.
Name of the embedding model used for indexing.
Embedding model provider identifier, formatted as organization/plugin_name/provider_name (e.g. langgenius/openai/openai). Legacy knowledge bases may return the bare short form (e.g. openai).
Whether API access is enabled for this knowledge base.
Connection details for external knowledge bases. Present when provider is external.
Show child attributes
Show child attributes
Retrieval settings for external knowledge bases. null for internal knowledge bases.
Show child attributes
Show child attributes
Icon display configuration for the knowledge base.
Show child attributes
Show child attributes
Unique identifier of the knowledge base.
high_quality uses embedding models for precise search; economy uses keyword-based indexing.
Whether multimodal content processing is enabled.
Whether the knowledge base is published.
Display name of the knowledge base maintainer. null if not set.
Display name of the knowledge base. Unique within the workspace.
Account IDs of members granted access when permission is partial_members. Always present on the update response; on the detail response, present only when permission is partial_members.
Controls who can access this knowledge base. Possible values: only_me, all_team_members, partial_members.
Pipeline ID, if a custom processing pipeline is configured.
Provider type. vendor for internally managed, external for external knowledge base connections.
Retrieval configuration for the knowledge base.
Show child attributes
Show child attributes
Runtime processing mode.
Summary index configuration.
Show child attributes
Show child attributes
Tags associated with this knowledge base.
Show child attributes
Show child attributes
Number of documents that are enabled and available.
Total number of documents.
Last update timestamp (Unix epoch in seconds).
ID of the user who last updated the knowledge base.
Total word count across all documents.
Was this page helpful?
curl --request PATCH \
--url https://{api_base_url}/datasets/{dataset_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "<string>",
"embedding_model": "<string>",
"embedding_model_provider": "<string>",
"external_knowledge_api_id": "<string>",
"external_knowledge_id": "<string>",
"external_retrieval_model": {
"score_threshold": 123,
"score_threshold_enabled": true,
"top_k": 123
},
"name": "<string>",
"partial_member_list": [
{
"user_id": "<string>"
}
]
}
'import requests
url = "https://{api_base_url}/datasets/{dataset_id}"
payload = {
"description": "<string>",
"embedding_model": "<string>",
"embedding_model_provider": "<string>",
"external_knowledge_api_id": "<string>",
"external_knowledge_id": "<string>",
"external_retrieval_model": {
"score_threshold": 123,
"score_threshold_enabled": True,
"top_k": 123
},
"name": "<string>",
"partial_member_list": [{ "user_id": "<string>" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
description: '<string>',
embedding_model: '<string>',
embedding_model_provider: '<string>',
external_knowledge_api_id: '<string>',
external_knowledge_id: '<string>',
external_retrieval_model: {score_threshold: 123, score_threshold_enabled: true, top_k: 123},
name: '<string>',
partial_member_list: [{user_id: '<string>'}]
})
};
fetch('https://{api_base_url}/datasets/{dataset_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/datasets/{dataset_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'description' => '<string>',
'embedding_model' => '<string>',
'embedding_model_provider' => '<string>',
'external_knowledge_api_id' => '<string>',
'external_knowledge_id' => '<string>',
'external_retrieval_model' => [
'score_threshold' => 123,
'score_threshold_enabled' => true,
'top_k' => 123
],
'name' => '<string>',
'partial_member_list' => [
[
'user_id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/datasets/{dataset_id}"
payload := strings.NewReader("{\n \"description\": \"<string>\",\n \"embedding_model\": \"<string>\",\n \"embedding_model_provider\": \"<string>\",\n \"external_knowledge_api_id\": \"<string>\",\n \"external_knowledge_id\": \"<string>\",\n \"external_retrieval_model\": {\n \"score_threshold\": 123,\n \"score_threshold_enabled\": true,\n \"top_k\": 123\n },\n \"name\": \"<string>\",\n \"partial_member_list\": [\n {\n \"user_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://{api_base_url}/datasets/{dataset_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"<string>\",\n \"embedding_model\": \"<string>\",\n \"embedding_model_provider\": \"<string>\",\n \"external_knowledge_api_id\": \"<string>\",\n \"external_knowledge_id\": \"<string>\",\n \"external_retrieval_model\": {\n \"score_threshold\": 123,\n \"score_threshold_enabled\": true,\n \"top_k\": 123\n },\n \"name\": \"<string>\",\n \"partial_member_list\": [\n {\n \"user_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/datasets/{dataset_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"<string>\",\n \"embedding_model\": \"<string>\",\n \"embedding_model_provider\": \"<string>\",\n \"external_knowledge_api_id\": \"<string>\",\n \"external_knowledge_id\": \"<string>\",\n \"external_retrieval_model\": {\n \"score_threshold\": 123,\n \"score_threshold_enabled\": true,\n \"top_k\": 123\n },\n \"name\": \"<string>\",\n \"partial_member_list\": [\n {\n \"user_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"app_count": 0,
"author_name": "admin",
"built_in_field_enabled": true,
"chunk_structure": null,
"created_at": 1741267200,
"created_by": "ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4",
"data_source_type": null,
"description": "Technical documentation for the product API",
"doc_form": "text_model",
"doc_metadata": [],
"document_count": 0,
"embedding_available": true,
"embedding_model": "text-embedding-3-small",
"embedding_model_provider": "langgenius/openai/openai",
"enable_api": true,
"external_knowledge_info": null,
"external_retrieval_model": null,
"icon_info": null,
"id": "c42e2a6e-40b3-4330-96f8-f1e4d768e8c9",
"indexing_technique": "high_quality",
"is_multimodal": false,
"is_published": false,
"maintainer": "admin",
"name": "Product Documentation",
"partial_member_list": [],
"permission": "only_me",
"pipeline_id": null,
"provider": "vendor",
"retrieval_model_dict": {
"reranking_enable": false,
"reranking_mode": null,
"reranking_model": {
"reranking_model_name": "",
"reranking_provider_name": ""
},
"score_threshold": null,
"score_threshold_enabled": false,
"search_method": "semantic_search",
"top_k": 3,
"weights": null
},
"runtime_mode": null,
"summary_index_setting": null,
"tags": [],
"total_available_documents": 0,
"total_documents": 0,
"updated_at": 1741267200,
"updated_by": "ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4",
"word_count": 0
}