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.
Self-hosted deployments adjust the length limit with the DATASET_DESCRIPTION_MAX_LENGTH environment variable.
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.
Response
Knowledge base updated successfully.
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
}