批量删除令牌
curl --request POST \
--url 'https://api.example.com/{{llmApiOrigin}}/api/token/batch' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"ids": [
123
]
}
'import requests
url = "https://api.example.com/{{llmApiOrigin}}/api/token/batch"
payload = { "ids": [123] }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({ids: [123]})
};
fetch('https://api.example.com/{{llmApiOrigin}}/api/token/batch', 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.example.com/{{llmApiOrigin}}/api/token/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ids' => [
123
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.example.com/{{llmApiOrigin}}/api/token/batch"
payload := strings.NewReader("{\n \"ids\": [\n 123\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.post("https://api.example.com/{{llmApiOrigin}}/api/token/batch")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"ids\": [\n 123\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/api/token/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ids\": [\n 123\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": ""
}
令牌管理
批量删除令牌
POST
{llmApiOrigin}
/
api
/
token
/
batch
批量删除令牌
curl --request POST \
--url 'https://api.example.com/{{llmApiOrigin}}/api/token/batch' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"ids": [
123
]
}
'import requests
url = "https://api.example.com/{{llmApiOrigin}}/api/token/batch"
payload = { "ids": [123] }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({ids: [123]})
};
fetch('https://api.example.com/{{llmApiOrigin}}/api/token/batch', 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.example.com/{{llmApiOrigin}}/api/token/batch",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ids' => [
123
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.example.com/{{llmApiOrigin}}/api/token/batch"
payload := strings.NewReader("{\n \"ids\": [\n 123\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.post("https://api.example.com/{{llmApiOrigin}}/api/token/batch")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"ids\": [\n 123\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/api/token/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"ids\": [\n 123\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": ""
}
简介
批量删除多个令牌。此接口需要登录(User 权限)后调用。认证
string
必填
Bearer Token,如
Bearer sk-xxxxxxxxxx请求参数
array<integer>
必填
需要删除的令牌 ID 数组。
代码示例
- cURL
- Python
- Node.js
curl -X POST "https://api-test.shengmoai.com/api/token/batch" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"ids": [1, 2, 3]
}'
import requests
url = "https://api-test.shengmoai.com/api/token/batch"
headers = {
"Authorization": "Bearer sk-xxxxxxxxxx",
"Content-Type": "application/json"
}
data = {"ids": [1, 2, 3]}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const axios = require('axios');
const response = await axios.post(
'https://api-test.shengmoai.com/api/token/batch',
{ ids: [1, 2, 3] },
{
headers: {
'Authorization': 'Bearer sk-xxxxxxxxxx',
'Content-Type': 'application/json'
}
}
);
console.log(response.data);
响应示例
{
"success": true,
"message": ""
}
HTTP 状态码
| 状态码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 401 | 未登录或令牌无效 |
| 400 | 请求参数错误 |
注意事项
- 批量删除为不可逆操作,删除后这些令牌将立即失效
ids数组不能为空
