Customers and resellers
Billing integration (WHMCS, HostBill, provisioning API)
Connect WHMCS or HostBill so orders create, suspend, upgrade and terminate subscriptions automatically, or drive the same /api/v1/provisioning/ API from your own billing system.
When customers order hosting in a billing system, the billing system should create the account, suspend it when an invoice is overdue and remove it when the contract ends. Berth has a provisioning API for exactly that, and ready-made modules for WHMCS and HostBill that use it. One service in the billing system is one subscription in Berth, identified by the service's domain.
How it works
- The billing system authenticates with an API token that has the provisioning scope. That token can only reach
/api/v1/provisioning/and nothing else in the API, so a leaked billing token cannot touch DNS, backups or settings. - Every call is identified by the domain of the service. Creating is idempotent on that domain, so a retry after a timeout does not create a second account.
- The package of a product in the billing system is the name of a package in Berth. The modules load the list of package names from the panel.
- Every provisioning action is recorded in the audit trail like any other change.
Creating the provisioning token
Only an administrator can create a provisioning token. In the panel: Account → AI connection (the page AI connection and API keys) → Create key and choose the rights Billing. On the server:
berth token create --login admin --name whmcs --scope provisioning > whmcs-token.txtThe secret is shown once. Store it in the billing system and nowhere else; revoke it with berth token revoke or on the same page if it leaks. See REST API for tokens in general.
WHMCS
The WHMCS server module supports:
| WHMCS function | What happens in Berth |
|---|---|
| Create | Creates the customer if needed, the subscription on the chosen package, and the domain. |
| Suspend / Unsuspend | Suspends only that subscription: sites show the suspension page; SSH/SFTP, cron, FTP and mailboxes are closed. The customer's other services keep working. |
| Terminate | Removes the subscription's databases, domains (with mail and files) and the subscription; a customer left without subscriptions is removed too. |
| Change package | Moves the subscription to another package. |
| Change password | Sets the password of the customer login. |
| Test connection | Checks the token and shows the panel version and packages. |
| Single sign-on | The client area button logs the customer in to the panel without a password. |
| Package list | The Module Settings dropdown is filled with the panel's package names. |
| Usage update | Disk and traffic of every service on the server, for WHMCS usage display and billing. |
| Client area | A small client area template for the service. |
The customer in Berth gets the login whmcs-<client id>, so the same WHMCS client with several services ends up as one customer with several subscriptions.
Setting up WHMCS
- Copy the Berth server module (the folder
berth) intomodules/servers/of your WHMCS installation. - Create the provisioning token as above.
- In WHMCS: System Settings → Servers → Add New Server. Choose module Berth, set the hostname to the panel's hostname, paste the token into Access Hash, and tick Secure.
- For each product: Module Settings → module Berth, then pick the Berth package from the list.
- Use Test Connection on the server to check the token.
All module calls are idempotent, so retrying a failed action from WHMCS is safe.
HostBill
The HostBill hosting module uses the same provisioning API and supports create, suspend, unsuspend, terminate, change package and change password, plus:
- Status sync: the regular HostBill synchronisation picks up whether the account is suspended, and its usage.
- Usage: disk and traffic of one account, or of all accounts in one call, in whole MB, for usage billing. Traffic is web traffic in and out for the current calendar month, the same figures the panel shows.
- Single sign-on: a one-time login link for the customer, requested at the moment they click.
The customer in Berth gets the login hostbill-<client id>.
Setting up HostBill
- Copy the Berth module (the folder
berth) intoincludes/modules/Hosting/and activate it under Settings → Modules → Hosting Modules. - Create a provisioning token in Berth.
- In HostBill: Settings → Apps → Add new App, module Berth, Hostname = the panel, Password = the token, SSL on. Fill in Port only if the panel is not on 443.
- For each product: Connect with App → Berth, and choose the package.
Berth requires customer passwords of at least 12 characters. When HostBill generates a shorter one at creation, the module generates a longer password and stores it on the account.
The provisioning API
Your own billing or CRM system can use the same endpoints. All requests use Authorization: Bearer <token> with a provisioning token, and request bodies must be sent as Content-Type: application/json.
| Method and path | What it does |
|---|---|
GET /api/v1/provisioning/test | Test the connection: panel version and package names. |
POST /api/v1/provisioning/accounts | Create a service: customer if needed, subscription and domain. Idempotent on the domain. |
GET /api/v1/provisioning/accounts | All services with their usage. |
GET /api/v1/provisioning/accounts/{domain} | One service with its usage. |
POST /api/v1/provisioning/accounts/{domain}/suspend | Suspend this subscription only, with an optional reason. |
POST /api/v1/provisioning/accounts/{domain}/unsuspend | Lift the suspension. |
PUT /api/v1/provisioning/accounts/{domain}/plan | Move to another package. |
POST /api/v1/provisioning/accounts/{domain}/password | Set the password of the customer login. |
POST /api/v1/provisioning/accounts/{domain}/sso | A one-time login link for the customer. |
DELETE /api/v1/provisioning/accounts/{domain} | Terminate: databases, domains and subscription, and the customer when nothing is left, unless ?keep_customer=true. |
Examples
Create a service:
curl -s https://panel.example.nl/api/v1/provisioning/accounts \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"domain":"acme.nl","plan":"basis",
"customer":{"login":"acme","name":"Acme","email":"info@acme.nl","password":"…"}}'The customer object also accepts reseller, to create the customer under a reseller. The answer (201) describes the service, with the same fields that GET …/accounts/{domain} returns:
| Field | Meaning |
|---|---|
created | true when this call created it, false when it already existed |
domain, domains | The service's domain and all domains of the subscription |
customer, sysuser, plan | Customer login, system user of the subscription, package name |
suspended, suspend_reason, customer_suspended | Suspension state of the subscription and of the customer |
disk_mb, disk_limit_mb, traffic_mb, traffic_limit_mb | Usage and limits in MB; a limit of 0 is unlimited |
panel_url, sftp_host | Where the customer logs in and connects with SFTP, for the welcome mail |
created_at | When the subscription was created |
Suspend with a reason, and change the package:
curl -s -X POST https://panel.example.nl/api/v1/provisioning/accounts/acme.nl/suspend \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"reason":"Invoice 2026-1042 overdue"}'
curl -s -X PUT https://panel.example.nl/api/v1/provisioning/accounts/acme.nl/plan \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"plan":"webshop"}'Errors come back as a 4xx or 5xx status with a JSON body containing error (a message in Dutch) and request_id, which identifies the request when you report a problem.
The single sign-on link
POST …/accounts/{domain}/sso returns a URL of the form https://<panel>/sso/<token>. The link is valid for one minute and works once, and the customer arrives logged in on their dashboard. Request it when the customer clicks log in to the panel, redirect them straight away, and never store or e-mail it. Only a provisioning token, or an administrator with their own panel session, can create such a link; no other API key can, including those of extensions. Each request is logged as provisioning.sso and each use as login.sso.
Related
- Resellers and white label: customers created through billing can belong to a reseller and see their brand.
- Webhooks and extensions: push panel events back to your billing or CRM system.
- REST API: the full API for everything beyond provisioning.