取得 API Key 詳情
使用系統存取權杖讀取目前帳戶的資料
中國大陸用戶請注意: 中國大陸用戶請使用 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 均回傳 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.namestringAPI Key 的名稱.
data.key_hintstring | null固定遮罩及 Key 末 4 位, 不回傳完整密鑰. 過短時為 null.
data.statusstringAPI Key 目前狀態. 詳情可包含自有軟刪除 Key. 可選值: enabled, disabled, expired, exhausted, deleted, unknown.
data.created_atstring | null建立時間. 時間格式為含時區的 RFC 3339. 無法確認或不適用時為 null.
data.expires_atstring | nullKey 到期時間, 未設定時為 null. 時間格式為含時區的 RFC 3339.
data.unlimitedbooleanKey 是否無限額度. 為 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
}
}