请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Authorization | ✓ | Bearer YOUR_ACCESS_TOKEN,账号访问令牌(控制台登录态,非 sk- API Key) |
Content-Type | ✓ | application/json |
接口:PUT /api/token/ 更新已存在的 API Key。Token id 放在请求体(不在 URL)。
查询参数
| 查询参数 | 必填 | 类型 | 说明 |
|---|---|---|---|
status_only | string | 非空时仅更新 status 字段(启用 / 禁用),忽略其他字段 |
请求体
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
id | ✓ | integer | 要更新的 Token ID(放在 body 中) |
name | ✓ | string | Token 名称 |
expired_time | ✓ | integer | 过期时间 Unix 秒;-1 永不过期 |
remain_quota | ✓ | integer | 剩余额度(quota) |
unlimited_quota | ✓ | boolean | 是否不限额度 |
status | integer | 状态:1 启用 / 2 禁用(配合 status_only 使用) | |
model_limits_enabled | boolean | 是否启用模型白名单 | |
model_limits | string | 模型白名单 | |
allow_ips | string | null | |
group | string | 分组,取自 GET /api/user/self/groups 的键 | |
cross_group_retry | boolean | 是否跨分组重试 |
curl -X PUT https://top.qingyuntop.ai/dashboard//api/token/ \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"id":10633,"name":"renamed","expired_time":-1,"remain_quota":-1,"unlimited_quota":true,"model_limits_enabled":false,"group":""}'Response
{
"success": true,
"message": "",
"data": {
"id": 10633,
"user_id": 42,
"key": "op0O**********nBYM",
"status": 1,
"name": "renamed",
"created_time": 1781995744,
"accessed_time": 1781995744,
"expired_time": -1,
"remain_quota": 0,
"unlimited_quota": true,
"used_quota": 0,
"model_limits_enabled": false,
"model_limits": "",
"allow_ips": "",
"group": "",
"cross_group_retry": false
}
}成功响应的 data 为更新后的脱敏 Token 对象(字段同 Token 列表,key 已脱敏)。 仅切换启用 / 禁用状态时,附加 ?status_only=1,只传 id 与 status:
curl -X PUT "https://top.qingyuntop.ai/dashboard//api/token/?status_only=1" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"id":10633,"status":2}'