API Key
撤銷 API Key
透過軟刪除撤銷自有的一般模型 Key
中國大陸用戶請注意: 中國大陸用戶請使用 https://api.toapis.cn 作為接口地址 (Base URL). 文檔示例中的 https://api.toapis.com 請替換為 https://api.toapis.cn.
使用說明
吊銷一個不再使用的模型 Key, 使其密鑰立即失效. 吊銷是軟刪除且不可恢復, 但歷史用量關聯保留, 不會清零帳戶餘額, 也不會取消該 Key 已發起的任務.
成功回傳 HTTP 200 且 data=null; 重複吊銷同一個自有 Key 同樣回傳 200. 屬於他人或不存在的 Key 回傳 404.
驗證
Authorizationstring請求頭必填系統存取權杖, 格式為 Bearer YOUR_SYSTEM_ACCESS_TOKEN. 不接受模型 Key, 不需要 X-User-Id. 共用規則見接入方式.
請求參數
api_key_idstring路徑必填自有一般模型 Key 的十進位 ID 字串, 不是 sk- 密鑰.
不接受主體或查詢參數.
請求範例
請求示例
curl --request DELETE \
--url 'https://api.toapis.com/api/v1/api-keys/43' \
--header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'import requests
response = requests.delete(
"https://api.toapis.com/api/v1/api-keys/43",
headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
timeout=30,
)
response.raise_for_status()
print(response.json())const response = await fetch("https://api.toapis.com/api/v1/api-keys/43", {
method: "DELETE",
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());回應欄位
範例使用虛構資料. Key 中繼資料見取得 API Key 詳情, 共用回應與錯誤處理見接入方式.
回應範例
響應示例
{
"code": 0,
"message": "",
"data": null
}