Delete Knowledge Tag
Permanently delete a knowledge base tag. Does not delete the knowledge bases that were tagged.
1 min read
delete/datasets/tags
Request example
curl --request DELETE \
--url https://api.dify.ai/v1/datasets/tags \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"tag_id": "<string>"
}'import requests
url = "https://api.dify.ai/v1/datasets/tags"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
}
payload = {
"tag_id": "<string>"
}
response = requests.request("DELETE", url, headers=headers, json=payload)
print(response.text)const response = await fetch('https://api.dify.ai/v1/datasets/tags', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"tag_id": "<string>"
})
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.dify.ai/v1/datasets/tags',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_POSTFIELDS => '{
"tag_id": "<string>"
}',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
url := "https://api.dify.ai/v1/datasets/tags"
payload := strings.NewReader("{\n \"tag_id\": \"<string>\"\n}")
req, _ := http.NewRequest("DELETE", 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))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dify.ai/v1/datasets/tags"))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.method("DELETE", HttpRequest.BodyPublishers.ofString("{\n \"tag_id\": \"<string>\"\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://api.dify.ai/v1/datasets/tags')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Delete.new(url)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = '{
"tag_id": "<string>"
}'
response = http.request(request)
puts response.read_bodyResponse
{
"code": "forbidden",
"message": "The API key is not authorized to access this knowledge base.",
"status": 403
}{
"code": "not_found",
"message": "Tag not found",
"status": 404
}delete/datasets/tags
Authorization
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).
Body
application/jsonID of the tag to delete. See List Knowledge Type Tags.
Responses
Success.