License Key Validation with Creem

The validation endpoint allows you to verify if a license key is still valid and active. This documentation will guide you through implementing license validation in your application.

Overview

License validation is a crucial part of maintaining software security and ensuring proper usage of your product.

  1. Key Validation Features
    • Real-time Status: Get immediate feedback on license validity
    • Feature Access: Check which features are enabled for the license
    • Quota Management: Track remaining usage quotas
    • Expiration Checking: Verify if the license is still within its valid period

Validation Flow Example

Here’s how the validation process typically works:

  1. Application starts up or performs periodic check
  2. Retrieves stored license key and instance ID
  3. Sends validation request to Creem API
  4. Processes response and updates application state
  5. Handles any validation errors or expired licenses

Endpoint Details

  • URL: https://test-api.creem.io/v1/licenses/validate
  • Method: POST
  • Authentication: Requires API key in headers

Request Parameters

The request body should include:

  • key (required): The license key to validate
  • instance_id (required): The instance ID received during activation

Response Format

{
  "id": "<string>",
  "mode": "test",
  "object": "<string>",
  "status": "active",
  "key": "ABC123-XYZ456-XYZ456-XYZ456",
  "activation": 5,
  "activation_limit": 1,
  "expires_at": "2023-09-13T00:00:00Z",
  "created_at": "2023-09-13T00:00:00Z",
  "instance": [
    {
      "id": "<string>",
      "mode": "test",
      "object": "license-instance",
      "name": "My Customer License Instance",
      "status": "active",
      "created_at": "2023-09-13T00:00:00Z"
    }
  ]
}

Implementation Examples

  • JavaScript Example:

    const validateLicense = async (licenseKey, instanceId) => {
      const response = await fetch('https://test-api.creem.io/v1/licenses/validate', {
        method: 'POST',
        headers: {
          'accept': 'application/json',
          'x-api-key': 'YOUR_API_KEY',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          key: licenseKey,
          instance_id: instanceId
        })
      });
      return await response.json();
    }
    
  • cURL Example:

    curl -X POST https://test-api.creem.io/v1/licenses/validate \
      -H "accept: application/json" \
      -H "x-api-key: YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "key": "MYAPP_12345",
        "instance_id": "inst_xyz123"
      }'
    
  • Python Example:

    import requests
    
    def validate_license(license_key, instance_id):
        url = "https://test-api.creem.io/v1/licenses/validate"
        headers = {
            "accept": "application/json",
            "x-api-key": "YOUR_API_KEY",
            "Content-Type": "application/json"
        }
        data = {
            "key": license_key,
            "instance_id": instance_id
        }
        
        response = requests.post(url, json=data, headers=headers)
        return response.json()
    

Error Handling

Common error responses include:

  • 400 Bad Request: Invalid or missing parameters
  • 401 Unauthorized: Invalid API key
  • 404 Not Found: Invalid license key or instance ID
  • 410 Gone: License has been revoked or expired