请求头

请求头必填说明
AuthorizationBearer YOUR_ACCESS_TOKEN,账号访问令牌(控制台登录态,非 sk- API Key)
Content-Typeapplication/json

接口:PUT /api/token/ 更新已存在的 API Key。Token id 放在请求体(不在 URL)。

查询参数

查询参数必填类型说明
status_onlystring非空时仅更新 status 字段(启用 / 禁用),忽略其他字段

请求体

字段必填类型说明
idinteger要更新的 Token ID(放在 body 中)
namestringToken 名称
expired_timeinteger过期时间 Unix 秒;-1 永不过期
remain_quotainteger剩余额度(quota)
unlimited_quotaboolean是否不限额度
statusinteger状态:1 启用 / 2 禁用(配合 status_only 使用)
model_limits_enabledboolean是否启用模型白名单
model_limitsstring模型白名单
allow_ipsstringnull
groupstring分组,取自 GET /api/user/self/groups 的键
cross_group_retryboolean是否跨分组重试
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,只传 idstatus

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}'