請求頭
| 請求頭 | 必填 | 說明 |
|---|---|---|
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 | IP 白名單 | |
group | string | 分組,取自 GET /api/user/self/groups 的鍵 | |
cross_group_retry | boolean | 是否跨分組重試 |
curl -X PUT https://bearlab.ai/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://bearlab.ai/api/token/?status_only=1" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"id":10633,"status":2}'