The license product type lets you create and manage software licenses that your application can validate against FOSSBilling over the API.
How It Works
Section titled “How It Works”- Customer purchases a license product
- FOSSBilling generates a unique license key
- Your application calls FOSSBilling's API to validate the license
- FOSSBilling checks the license against your rules (IP, hostname, path, version)
- Your application grants or denies access based on the response
Setting Up License Products
Section titled “Setting Up License Products”Enable the Extension
Go to Extensions and install "Service License".
Create a License Product
When creating the product, configure these options:
Option Description pluginWhich validation plugin to use (default: Simple)prefixOptional prefix for license keys (e.g., MYAPP-)lengthLength of the generated key (default: 25) validate_ipCheck the IP address validate_hostCheck the hostname validate_pathCheck the installation path validate_versionCheck the software version Distribute and Validate
Give customers their license key, then have your application validate it using the API.
API Endpoints
Section titled “API Endpoints”| Endpoint | Method | Access | Description |
|---|---|---|---|
/admin/servicelicense/plugin_get_pairs | GET/POST | Admin | List available license plugins |
/admin/servicelicense/update | POST | Admin | Update license validation rules |
/admin/servicelicense/reset | POST | Admin | Reset license to defaults |
/guest/servicelicense/check | POST | Guest | Validate a license |
Validating a License
Section titled “Validating a License”Use a POST request with a JSON body to /api/guest/servicelicense/check. The endpoint requires no authentication.
Parameters
Section titled “Parameters”| Parameter | Required | Type | Description |
|---|---|---|---|
license | Yes | string | The license key to validate |
host | Yes | string | Hostname of the installation (e.g., example.com) |
version | Yes | string | Software version (e.g., 1.0.0) |
path | Yes | string | Installation path (e.g., /var/www/app) |
The client's IP address is detected automatically from the request and does not need to be sent.
Examples
Section titled “Examples”curl -X POST "https://example.com/api/guest/servicelicense/check" \ -H "Content-Type: application/json" \ -d '{ "license": "MYAPP-ABCD1-EFGH2-IJKL3-MNOP4", "host": "customer-site.com", "version": "1.2.3", "path": "/var/www/myapp" }'import requests
url = "https://example.com/api/guest/servicelicense/check"payload = { "license": "MYAPP-ABCD1-EFGH2-IJKL3-MNOP4", "host": "customer-site.com", "version": "1.2.3", "path": "/var/www/myapp"}
response = requests.post(url, json=payload)print(response.json())Success Response
Section titled “Success Response”{ "result": { "licensed_to": "Client Name", "created_at": "2025-01-01T12:00:00Z", "expires_at": null, "valid": true }, "error": null}| Field | Type | Description |
|---|---|---|
licensed_to | string | Name of the license owner |
created_at | string | License creation date (ISO 8601) |
expires_at | string or null | Expiry date in ISO 8601, or null if no expiry |
valid | bool | Whether the license passed all validation checks |
Error Codes
Section titled “Error Codes”| Code | Message |
|---|---|
| 1000 | Invalid request. Parameters missing? |
| 1001 | License key is not present in call |
| 1002 | Host key is not present in call |
| 1003 | Version key is not present in call |
| 1004 | Path key is not present in call |
| 1005 | Your license key is invalid |
| 1006 | License is not active |
| 1007 | IP address is not allowed for this license |
| 1008 | Host is not allowed for this license |
| 1009 | Version is invalid for this license |
| 1010 | Software install path is invalid for this license |
| 1020 | Plugin-specific validation failure |
Custom License Plugins
Section titled “Custom License Plugins”You can create your own license generation and validation logic.
Creating a Plugin
Section titled “Creating a Plugin”Place your plugin in /modules/Servicelicense/Plugin/YourPlugin.php:
class License_YourPlugin{ public function generate(array $data): string { return 'YOUR-KEY-HERE'; }
public function validate(\Model_ServiceLicense $service, array $data): array { if (empty($data['host'])) { throw new \LogicException('Host is required', 1020); }
return ['host' => $data['host']]; }}Plugin Requirements
Section titled “Plugin Requirements”- Class name must be
License_PluginName - File must be
PluginName.phpin thePlugin/directory - Must implement a
generate()method - Optional: implement a
validate()method for custom rules
The Simple Plugin (Built-in)
Section titled “The Simple Plugin (Built-in)”The default Simple plugin generates keys like:
MYAPP-ABCD1-EFGH2-IJKL3-MNOP4- 25 characters by default
- Optional prefix
- Dashes every 5 characters
- Uppercase letters and digits 1–9
See src/modules/Servicelicense/Plugin/Simple.php for the implementation.