License Server API

RESTful API Documentation v1.0

Authentication

All API requests should include an API key in the header (optional but recommended):

Authorization: Bearer YOUR_API_KEY

Or use the custom header:

X-API-Key: YOUR_API_KEY

POST /api/v1/activate.php

Activate a license key on a device.

Request Parameters

license_key required
The license key to activate (format: XXXX-XXXX-XXXX-XXXX-XXXX)
hardware_id required
Unique hardware identifier for the device

Request Example

{
  "license_key": "ABCD-1234-EFGH-5678-IJKL",
  "hardware_id": "a1b2c3d4e5f6g7h8"
}

Success Response

{
  "success": true,
  "activation_token": "abc123def456...",
  "license_info": {
    "product_name": "My Software",
    "license_type": "subscription",
    "expiry_date": "2025-12-31 23:59:59"
  }
}

Error Response

{
  "success": false,
  "error": "Maximum activations reached"
}

POST /api/v1/validate.php

Validate an active license.

Request Parameters

license_key required
The license key to validate
hardware_id optional
Hardware identifier (required for activated licenses)
activation_token optional
Activation token from activate response

Request Example

{
  "license_key": "ABCD-1234-EFGH-5678-IJKL",
  "hardware_id": "a1b2c3d4e5f6g7h8",
  "activation_token": "abc123def456..."
}

Success Response

{
  "valid": true,
  "license": {
    "license_key": "ABCD-1234-EFGH-5678-IJKL",
    "product_name": "My Software",
    "license_type": "subscription",
    "status": "active",
    "expiry_date": "2025-12-31 23:59:59",
    "remaining_days": 365,
    "max_activations": 3,
    "current_activations": 1
  }
}

POST /api/v1/deactivate.php

Deactivate a license on a device.

Request Parameters

license_key required
The license key to deactivate
hardware_id required
Hardware identifier
activation_token required
Activation token from activate response

Request Example

{
  "license_key": "ABCD-1234-EFGH-5678-IJKL",
  "hardware_id": "a1b2c3d4e5f6g7h8",
  "activation_token": "abc123def456..."
}

Success Response

{
  "success": true,
  "message": "License deactivated successfully"
}

GET /api/v1/info.php?license_key=XXXX

Get information about a license.

Request Parameters

license_key required
The license key to query

Success Response

{
  "success": true,
  "license": {
    "license_key": "ABCD-1234-EFGH-5678-IJKL",
    "product_name": "My Software",
    "license_type": "subscription",
    "status": "active",
    "issued_date": "2025-01-01 00:00:00",
    "expiry_date": "2025-12-31 23:59:59",
    "max_activations": 3,
    "current_activations": 1
  }
}

HTTP Status Codes

Code Description
200 Success - Request completed successfully
400 Bad Request - Invalid parameters or missing required fields
401 Unauthorized - Invalid or missing API key
404 Not Found - License key not found
405 Method Not Allowed - Wrong HTTP method used
429 Too Many Requests - Rate limit exceeded
500 Server Error - Internal server error

Integration Examples

PHP Example

$ch = curl_init('https://yourdomain.com/api/v1/activate.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'license_key' => 'ABCD-1234-EFGH-5678-IJKL',
    'hardware_id' => 'unique-hardware-id'
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
$result = json_decode($response, true);

if ($result['success']) {
    echo "License activated!";
} else {
    echo "Error: " . $result['error'];
}

JavaScript Example

fetch('https://yourdomain.com/api/v1/activate.php', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        license_key: 'ABCD-1234-EFGH-5678-IJKL',
        hardware_id: 'unique-hardware-id'
    })
})
.then(response => response.json())
.then(data => {
    if (data.success) {
        console.log('License activated!');
    } else {
        console.error('Error:', data.error);
    }
});