POST
/api/validate-keyCheck if an API key is valid and get its associated plan details.
Request
txt
POST /api/validate-key
Content-Type: application/json
{
"api_key": "alt_YOUR_API_KEY"
}
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| api_key | string | Yes | The API key to validate |
Note: This endpoint accepts the key in the request body, not in the
X-API-Key header.
Response
Valid Key (200)
txt
{
"valid": true,
"plan": "free",
"credits_total": 50,
"credits_used": 12,
"credits_remaining": 38
}
Invalid Key (401)
txt
{
"error": "Invalid API key"
}
Usage
txt
const response = await fetch("https://api.altextapi.com/api/validate-key", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ api_key: userProvidedKey }),
});
const data = await response.json();
if (data.valid) {
showDashboard(data);
} else {
showError("Invalid API key. Please check and try again.");
}