更新 API Key

PATCH/v1/keys/{hash}

更新当前认证用户拥有的 API Key。

hash 来自 GET /v1/key、GET /v1/keys 或 POST /v1/keys。路径参数不接受原始 API Key 字符串。

身份验证

Authorization Bearer <USER_JWT>

必须使用已登录用户 JWT。普通推理 API Key、MANAGEMENT Key 和 PROVISIONING Key 均不支持此接口。企业机器自动化请使用 Enterprise 控制面接口。

企业 API 指南 · 查询企业余额

路径参数

hashstringrequired

API Key hash 标识。

请求体

namestring

新的 API Key 名称。空白字符串会被忽略。

disabledboolean

true 禁用 Key;false 仅在 Key 未过期时重新启用。

limitnumber | null

USD 花费上限。发送 null 可清除已有上限。

limit_resetstring | null

可选重置周期:daily / weekly / monthly,或 null 表示终身。UTC 零点重置;周为周一至周日。

响应

dataobject

更新后的 API Key 信息。

data.hashstring

管理接口使用的 hash 标识。

data.namestring

API Key 名称。

data.labelstring

展示标签,与 name 一致。

data.disabledboolean

当 Key 状态不是 ACTIVE 或 expires_at 已过期时为 true。

data.workspace_idstring

Key 所属 workspace code。

data.creator_user_idstring | null

所有者用户 ID。

data.created_atstring

创建时间,UTC ISO-8601 格式。

data.updated_atstring | null

最后更新时间。

data.expires_atstring | null

UTC 过期时间,或 null。

data.usagenumber

该 Key 累计消费金额(USD),不是赠送 Credit 余额。

data.usage_dailynumber

当前 UTC 日内该 Key 的消费金额(USD)。

data.usage_weeklynumber

当前 UTC 周内该 Key 的消费金额(USD),周一开始。

data.usage_monthlynumber

当前 UTC 自然月内该 Key 的消费金额(USD)。

data.limitnumber | null

配置的 Key 消费上限(USD);未设置时为 null。

data.limit_remainingnumber | null

适用限额周期内的剩余预算(USD);未设置上限时为 null。

data.limit_resetstring | null

daily | weekly | monthly | null(终身)。

data.is_free_tierboolean

当前为 false。

data.is_management_keyboolean

此响应描述推理 Key,该字段为 false。

data.is_provisioning_keyboolean

当前为 false。

data.rate_limitobject

每分钟请求限制信息。

请求

Shell
1curl -X PATCH https://api.token360.ai/v1/keys/f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943 \
2  -H "Authorization: Bearer $USER_JWT" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "name": "Updated API Key Name",
6    "disabled": false
7  }'

响应

JSON
1{
2  "data": {
3    "hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",
4    "name": "Updated API Key Name",
5    "label": "Updated API Key Name",
6    "disabled": false,
7    "workspace_id": "DEFAULT",
8    "creator_user_id": "00000000-0000-4000-8000-000000000001",
9    "created_at": "2026-06-04T00:00:00Z",
10    "updated_at": "2026-06-04T01:00:00Z",
11    "expires_at": null,
12    "usage": 12.34,
13    "usage_daily": 0,
14    "usage_weekly": 0,
15    "usage_monthly": 0,
16    "limit": null,
17    "limit_remaining": null,
18    "limit_reset": null,
19    "is_free_tier": false,
20    "is_management_key": false,
21    "is_provisioning_key": false,
22    "rate_limit": {
23      "interval": "minute",
24      "note": "Token-360 per-minute request limit",
25      "requests": 1000
26    }
27  }
28}
此页面对您有帮助吗?
更新 API Key · Token360