ToAPIsToAPIs
API Keys

Revoke an API key

Revoke your ordinary model key by soft deletion

DELETE
/api/v1/api-keys/{api_key_id}

Note for users in mainland China: Please use https://api.toapis.cn as the API endpoint (Base URL). Replace https://api.toapis.com with https://api.toapis.cn in the examples in this document.

Behavior

Revokes a model key that is no longer used, disabling its secret immediately. Revocation is a soft delete and cannot be undone, but historical usage stays linked, the account balance is not cleared, and tasks already started by the key are not cancelled.

On success it returns HTTP 200 with data=null; revoking the same own key again also returns 200. Keys belonging to others or that do not exist return 404.

Authentication

Authorizationstringheaderrequired

Use Bearer YOUR_SYSTEM_ACCESS_TOKEN. Model keys are not accepted and X-User-Id is not required. See access rules.

Request parameters

api_key_idstringpathrequired

Decimal string ID of your ordinary model key, not the sk- secret.

No body or query parameters are accepted.

Request examples

requestExample

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());

Response fields

Examples use fictitious data. See Get API key for key metadata and Access for the shared response and error contract.

Response examples

responseExample

{
  "code": 0,
  "message": "",
  "data": null
}