Skip to content

License

The license product type lets you create and manage software licenses that your application can validate against FOSSBilling over the API.

  1. Customer purchases a license product
  2. FOSSBilling generates a unique license key
  3. Your application calls FOSSBilling's API to validate the license
  4. FOSSBilling checks the license against your rules (IP, hostname, path, version)
  5. Your application grants or denies access based on the response

Go to Extensions and install "Service License".

When creating the product, configure these options:

OptionDescription
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

Give customers their license key, then have your application validate it using the API.

EndpointMethodAccessDescription
/admin/servicelicense/plugin_get_pairsGET/POSTAdminList available license plugins
/admin/servicelicense/updatePOSTAdminUpdate license validation rules
/admin/servicelicense/resetPOSTAdminReset license to defaults
/guest/servicelicense/checkPOSTGuestValidate a license

Use a POST request with a JSON body to /api/guest/servicelicense/check. The endpoint requires no authentication.

ParameterRequiredTypeDescription
licenseYesstringThe license key to validate
hostYesstringHostname of the installation (e.g., example.com)
versionYesstringSoftware version (e.g., 1.0.0)
pathYesstringInstallation path (e.g., /var/www/app)

The client's IP address is detected automatically from the request and does not need to be sent.

Terminal window
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"
}'
{
"result": {
"licensed_to": "Client Name",
"created_at": "2025-01-01 12:00:00",
"expires_at": null,
"valid": true
},
"error": null
}
FieldTypeDescription
licensed_tostringName of the license owner
created_atstringLicense creation date (ISO 8601)
expires_atstring or nullExpiry date in ISO 8601, or null if no expiry
validboolWhether the license passed all validation checks
CodeMessage
1000Invalid request. Parameters missing?
1001License key is not present in call
1002Host key is not present in call
1003Version key is not present in call
1004Path key is not present in call
1005Your license key is invalid
1006License is not active
1007IP address is not allowed for this license
1008Host is not allowed for this license
1009Version is invalid for this license
1010Software install path is invalid for this license
1020Plugin-specific validation failure

You can create your own license generation and validation logic.

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']];
}
}
  • Class name must be License_PluginName
  • File must be PluginName.php in the Plugin/ directory
  • Must implement a generate() method
  • Optional: implement a validate() method for custom rules

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.