POST/v1/validate-key

Check if an API key is valid and get its associated plan details.

Request

txt
POST /v1/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. This allows you to validate keys without knowing which header format they use.

Response

Valid Key (200)

txt
{
  "valid": true,
  "plan": "pro",
  "credits_total": 1000,
  "credits_used": 342,
  "credits_remaining": 658,
  "created_at": "2026-01-15T10:30:00Z"
}

Invalid Key (401)

txt
{
  "error": {
    "code": "unauthorized",
    "message": "Invalid API key"
  }
}

Usage

Use this endpoint to:

  • Validate keys during plugin setup
  • Display plan information in admin dashboards
  • Check if a key is still active before making generation requests
txt
const response = await fetch("https://api.altextapi.com/v1/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.");
}