Get API key
Read metadata for one of your ordinary model keys
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.
See Access for authentication, pagination, and errors.
Behavior
Returns the metadata of a given key, useful for inspecting its name, status, credits, expiry, and model restrictions. Soft-deleted keys can still be read, with status=deleted. The full secret is only returned by create and rotate responses. This endpoint does not return key.
Keys belonging to others or that do not exist return 404.
Authentication
AuthorizationstringheaderrequiredUse Bearer YOUR_SYSTEM_ACCESS_TOKEN. Model API keys are not accepted. X-User-Id is not required.
Request parameters
api_key_idstringpathrequiredDecimal string ID of your model API key. A key owned by someone else returns 404. Deleted keys can still filter your historical usage.
Constraints: pattern=^[1-9][0-9]*$.
Request examples
requestExample
curl --request GET \
--url 'https://api.toapis.com/api/v1/api-keys/42' \
--header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'import requests
response = requests.get(
"https://api.toapis.com/api/v1/api-keys/42",
headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
timeout=30,
)
response.raise_for_status()
print(response.json())const url = new URL("https://api.toapis.com/api/v1/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());Response fields
Examples use fictional data and assume credits_per_usd="100". Use the conversion rate returned by the API.
codeintegerNumeric result code; 0 means success.
messagestringResponse message; empty on success. Error messages are localized.
dataobjectResult object for this query.
data.idstringModel API key ID, not the secret key. Returned as a decimal ID string.
data.namestringAPI key name.
data.key_hintstring | nullFixed mask and last four key characters; never the full secret. Short keys return null.
data.statusstringCurrent API key status. Details can include your soft-deleted keys. Values: enabled, disabled, expired, exhausted, deleted, unknown.
data.created_atstring | nullCreation time. RFC 3339 timestamp with a timezone. null when unknown or inapplicable.
data.expires_atstring | nullKey expiration time; null if no expiration is set. RFC 3339 timestamp with a timezone.
data.unlimitedbooleanWhether the key has unlimited quota. If true, remaining_credits=null.
data.remaining_creditsstring | nullRemaining credits. An unlimited API key returns null. Returned as a decimal string to preserve precision.
data.daily_limit_creditsstring | nullDaily quota limit in credits; null when unrestricted. Returned as a decimal string to preserve precision.
data.monthly_limit_creditsstring | nullMonthly quota limit in credits; null when unrestricted. Returned as a decimal string to preserve precision.
data.model_limitsstring[]Model allowlist as a string array; [] means unrestricted and null is never returned.
data.allow_ipsstring[]Effective IP allowlist for this key as a lexicographically sorted string array; [] means unrestricted. Other keys in the account and system access tokens are unaffected. A nonmatching source IP returns 403 for model calls. Changes retain existing cache and in-flight request behavior.
Response examples
responseExample
{
"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,
"model_limits": [],
"allow_ips": []
}
}