ToAPIsToAPIs
账户查询API Key

获取 API Key 详情

使用系统访问令牌读取当前账户的数据

GET
/api/v1/account/api-keys/%7Bapi_key_id%7D

国内用户请注意: 中国大陆用户请使用 https://toapis.cn 作为接口地址 (Base URL). 文档示例中的 https://toapis.com 请替换为 https://toapis.cn.

鉴权, 分页与错误处理见接入说明.

使用说明

仅查询自有普通模型 Key 的元数据. 列表按数字 ID 倒序, 默认排除软删除和 stats:read 凭据; 详情可读取自有软删除 Key. key_hint 仅含固定遮罩和末 4 位, 过短时为 null. 无限额度用 unlimited=true, remaining_credits=null; 日/月无限制也用 null. 不返回 Key 原文或 Webhook 密钥, 他人 Key 与不存在的 Key 均返回 404.

鉴权

Authorizationstring请求头必填

使用系统访问令牌, 格式为 Bearer YOUR_SYSTEM_ACCESS_TOKEN. 模型 API Key 不能用于此接口, 无需 X-User-Id.

请求参数

api_key_idstring路径必填

自身模型 API Key 的十进制 ID 字符串. 不属于自己时返回 404, 已删除 Key 仍可用于查询自身历史用量.

约束: pattern=^[1-9][0-9]*$.

请求示例

curl --request GET \
  --url 'https://toapis.com/api/v1/account/api-keys/42' \
  --header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'
import requests

response = requests.get(
    "https://toapis.com/api/v1/account/api-keys/42",
    headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
const url = new URL("https://toapis.com/api/v1/account/api-keys/42");

const response = await fetch(url, {
  headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
  signal: AbortSignal.timeout(30_000),
});

if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());

响应字段

示例使用虚构数据. 金额样例假设 credits_per_usd="100", 实际换算以响应为准.

codeinteger

业务状态码, 成功时为 0.

messagestring

响应消息, 成功时为空字符串. 错误消息会按请求语言返回.

dataobject

本次查询的结果对象.

data.idstring

模型 API Key 的 ID, 不是 Key 原文. 以十进制 ID 字符串返回.

data.namestring

API Key 的名称.

data.key_hintstring | null

固定遮罩和 Key 末 4 位, 不返回完整密钥. Key 过短时为 null.

data.statusstring

API Key 当前状态. 详情可返回自身已软删除 Key 的元数据. 可选值: enabled, disabled, expired, exhausted, deleted, unknown.

data.created_atstring | null

创建时间. 时间格式为带时区的 RFC 3339. 无法确认或不适用时为 null.

data.expires_atstring | null

Key 过期时间, 未设置过期时间时为 null. 时间格式为带时区的 RFC 3339.

data.unlimitedboolean

Key 是否为无限额度. 为 true 时 remaining_credits=null.

data.remaining_creditsstring | null

剩余额度, 单位为 credits. API Key 无限额时为 null. 以十进制字符串返回以保持精度.

data.daily_limit_creditsstring | null

每日额度上限, 单位为 credits, 无限制时为 null. 以十进制字符串返回以保持精度.

data.monthly_limit_creditsstring | null

每月额度上限, 单位为 credits, 无限制时为 null. 以十进制字符串返回以保持精度.

响应示例

{
  "code": 0,
  "message": "",
  "data": {
    "id": "42",
    "name": "Example Key",
    "key_hint": "****abcd",
    "status": "enabled",
    "created_at": "2026-10-01T00:00:00Z",
    "expires_at": null,
    "unlimited": false,
    "remaining_credits": "500",
    "daily_limit_credits": "100",
    "monthly_limit_credits": null
  }
}