更新成员 API Key
/enterprise/v1/sub-accounts/{subAccountId}/api-keys/{hash}即使只改预算也必须传 status:ACTIVE 或 DISABLED。name 可选。allowedIps 省略/null 保持原值,[] 清除限制。spendLimitPresent=true 才应用 spendLimit,含 null(清除限额);limitResetPresent=true 才应用 limitReset,含 null(累计)。不传标志不会更新预算字段。限额单位美元,不会增加账户资金。
身份验证
MANAGEMENT / PROVISIONING Key;tenant:keys:write
Authorization: Bearer <CONTROL_KEY>
路径中的 subAccountId 必须属于当前企业;hash 是 Key 元数据标识,不能传明文密钥。
审批与重试
启用审批的企业需传 Idempotency-Key,可能返回 HTTP 409 / APPROVAL_REQUIRED,data.operation.executed=false;此时尚未执行,不应当作成功。未启用审批时直接执行;不要假设任意 POST 都支持幂等重试。
路径参数
subAccountIdstringrequired10-digit public member ID / 10 位成员编号
hashstringrequiredPublic key hash / 公开 Key hash
请求体
statusstringrequiredACTIVE | DISABLED
namestringKey name / Key 名称
allowedIpsstring[] | nullnull keeps current; [] clears / null 保持;[] 清空
spendLimitnumber | nullUSD > 0; null clears with presence flag / 美元正数,配合标志可传 null 清除
spendLimitPresentbooleantrue applies spendLimit / true 才应用 spendLimit
limitResetstring | nulldaily | weekly | monthly | null
limitResetPresentbooleantrue applies limitReset / true 才应用 limitReset
字段使用 camelCase。必填项及可选字段见上文。
1{
2 "status": "ACTIVE",
3 "spendLimit": 100,
4 "spendLimitPresent": true,
5 "limitReset": "monthly",
6 "limitResetPresent": true
7}响应
HTTP 200; code: 200. 以下为示例值,字段使用 camelCase。
codeinteger200
dataobject | nulldata.hashstringdata.namestringdata.keyDisplaystringdata.workspaceCodestringdata.statusstringdata.allowedIpsarraydata.spendLimitnumberdata.limitResetstringdata.expiresAtstring | nulldata.createdAtstring错误处理
检查 HTTP 状态和 code,失败时读取 serviceCode、msg、traceId。无效凭证无法读取数据;缺少 scope 返回 API_KEY_SCOPE_DENIED。跨企业资源不可访问。不要把 202 接受或审批待处理当作业务完成。