Bill licences per unit
A licence can be billed by what its software counts, for example the websites on a server: each usage report sets the order price to the count times the unit price a month, at least the minimum.
Set up the product
Section titled “Set up the product”- Open the licence product’s Configuration tab, section Price per Unit.
- Set Unit name (for example
website), Price per unit a month and Minimum a month, in the default currency. An empty unit price turns per-unit billing off for the product. - Optional protections, each with its own switch:
- Hold big drops: a report that lowers the count by more than the percent waits for staff approval. Rises apply at once.
- Warn when reports stop: after the days set, the client gets an email and staff a notice, once per gap.
- Suspend when reports stop: after the days set, the order is suspended. A report does not lift the suspension: staff unsuspend it, and the days start again then. Reports sent while it is suspended still count, so the next renewal follows the real usage.
- Select Update.
- In System Settings > Licences, set the Usage report secret your software sends with its reports.
Turn it on for a licence
Section titled “Turn it on for a licence”On the order’s Service Management tab, set Per-unit billing to On and select Save. The next report sets the price. For software that cannot report, enter the Count yourself: that licence gets no warning or suspension until it reports. A held drop shows there with Approve and Refuse.
The new price is used by the next renewal invoice; an invoice already issued keeps its amount. The client’s licence page shows the count, when it was reported and the next renewal price.
The usage report
Section titled “The usage report”The software posts to /licence/report, as JSON or a form:
| Field | Value |
|---|---|
secret |
The usage report secret. |
service_id, product_id |
The serviceid and productid of the licence’s WHMCS-style answer. |
units |
The count, a whole number from 0 to 1,000,000. |
ips |
The servers, as a comma list of IP addresses. |
The report must come from an IP address already on the licence. With per-unit billing on, the licence’s IP
addresses become the reported servers, unless the product has a server limit. The answer is success, or the
reason with an HTTP error status.
curl --request POST 'https://billing.example.com/licence/report' \ --header 'Content-Type: application/json' \ --data '{"secret":"YOUR-SECRET","service_id":"1226","product_id":"90","units":"509","ips":"203.0.113.5,203.0.113.6"}'Software that reads custom fields
Section titled “Software that reads custom fields”Software built for the WHMCS Licensing Addon may read the switch and the count from the check answer’s
customfields. Name them in Answer field for the per-unit switch and Answer field for the count on the
product: the answer then sends name=on while per-unit billing is on, and name=count.
After a WHMCS import
Section titled “After a WHMCS import”When the switch and the count were custom fields of the WHMCS services, set the two answer field names to those field names, then select Take from imported answers on the product’s Configuration tab. Licences whose switch is already set are left alone, and prices stay as imported.

