跳转到主要内容
PATCH
/
datasets
/
tags
修改知识库标签
curl --request PATCH \
  --url https://{api_base_url}/datasets/tags \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "tag_id": "<string>",
  "name": "<string>"
}
'
import requests

url = "https://{api_base_url}/datasets/tags"

payload = {
    "tag_id": "<string>",
    "name": "<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({tag_id: '<string>', name: '<string>'})
};

fetch('https://{api_base_url}/datasets/tags', 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/tags",
  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([
    'tag_id' => '<string>',
    'name' => '<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/tags"

	payload := strings.NewReader("{\n  \"tag_id\": \"<string>\",\n  \"name\": \"<string>\"\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/tags")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"tag_id\": \"<string>\",\n  \"name\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://{api_base_url}/datasets/tags")

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  \"tag_id\": \"<string>\",\n  \"name\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "f4b5c6d7-e8f9-0a1b-2c3d-4e5f6a7b8c9d",
  "name": "Product Docs",
  "type": "knowledge",
  "binding_count": "0"
}
{
  "status": 400,
  "code": "invalid_param",
  "message": "Tag name already exists"
}
{
  "status": 404,
  "code": "not_found",
  "message": "Tag not found"
}

授权

Authorization
string
header
必填

每个请求都通过 API Key 认证:Authorization: Bearer {API_KEY}。应用接口使用应用 API Key,知识库接口使用知识库 API Key(快速开始)。

API Key 应保存在服务端,切勿嵌入客户端代码。缺失或无效的 Key 会返回 HTTP 401unauthorized)。

请求体

application/json
tag_id
string
必填

要重命名的标签 ID。参见 获取知识库标签列表

name
string
必填

标签的新名称。在工作空间内必须唯一。

Required string length: 1 - 50

响应

标签更新成功。

id
string

标签标识符。

name
string

标签显示名称。

type
string

标签类型。知识库标签始终为 knowledge

binding_count
string | null

绑定到该标签的知识库数量。