API 密钥
当前用户的 API 密钥。密钥明文只在创建时返回一次,可按领域限定授权范围。
api-keys用户账号鉴权: 用户4 个接口列出 API Key
GET
/api/v2/api-keys鉴权: 用户
查询参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | integer | — | 页码,从 1 开始。 |
| page_size | integer | — | 每页条数。 |
| sort | string | — | 排序字段,逗号分隔,前缀 `-` 表示降序,如 `-created_at,id`。 |
创建 API Key
POST
/api/v2/api-keys鉴权: 用户
请求体 application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| allow_ips | ApiKeyAllowIps | — | 调用 IP 白名单(只收单个 IP,最多 200 个);空 = 不限。不在名单里的调用按凭据无效回 401。 |
| expires_at | string | — | 过期时间 |
| name | string | 必填 | 名称 |
| scopes | string[] | 必填 | 授权范围,取值同创建时的 scopes。 |
修改 API Key 的 IP 白名单或重置
PUT
/api/v2/api-keys/{id}鉴权: 用户
请求体 application/json
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| allow_ips | ApiKeyAllowIps | — | 调用 IP 白名单(只收单个 IP,最多 200 个);空 = 不限。不在名单里的调用按凭据无效回 401。 |
| reset | boolean | — | 为 true 时换新 key,旧 key 立即失效。 |
删除 API Key
DELETE
/api/v2/api-keys/{id}鉴权: 用户
API 密钥对象
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| allow_ips | ApiKeyAllowIps | — | 调用 IP 白名单(只收单个 IP,最多 200 个);空 = 不限。不在名单里的调用按凭据无效回 401。 |
| created_at | string | — | 创建时间 |
| expires_at | string | — | 过期时间 |
| id | integer | — | 记录 ID |
| last_used_at | string | — | 最近一次使用时间;从未使用为空。 |
| name | string | — | 名称 |
| prefix | string | — | 明文的前几位,便于辨认。 |
| reset | boolean | — | 为 true 时换新 key,旧 key 立即失效。 |
| scopes | string[] | — | 授权范围,取值同创建时的 scopes。 |
| secret | string | — | 明文 key(X-API-Key 的值),只在创建时返回一次;库里只存哈希。 |
| updated_at | string | — | 更新时间 |