Automation
Connect your provisioning and billing systems to HF Panel: licences from the partner API, hosting accounts with the WHMCS and Blesta modules and the token API.
A partner usually automates two different things, with two different keys:
| What | Where it runs | Key |
|---|---|---|
| Licences: one per server, issued when you create the server and removed when you delete it | against the licence server, api.hostfog.com |
your partner API key, hfp_… |
| Hosting accounts on each server: create, suspend, change package, delete | against each server's own API, api.<server's domain> |
an API token made on that server |
Licences when you create and delete servers
Call the partner API from the system that creates your servers: your provisioning scripts, your orchestration tool or your billing system's server-order hooks.
A typical order for a new managed server:
- Your system creates the virtual machine and knows its public IPv4 address.
- It calls
POST /v1/licence/partner/issuewith the customer's email and that address, with anIdempotency-Keysuch as the order number. - It runs the
installcommand from the answer on the new server, over SSH or with your cloud provider's start-up script, adding--yes,--domainand--emailso it installs without the browser and asks nothing (see Customise the installation). - The server emails the administrator when it is ready.
When the customer cancels, your system calls POST /v1/licence/partner/remove after deleting the server. When a
server moves to a new address, it calls move.
Tip: run a nightly check that compares your own list of servers with the fleet: a licence without a server is a place in your pool you are paying for.
Hosting accounts with WHMCS or Blesta
If you also sell shared hosting or reseller accounts on HF Panel servers, the ready-made billing modules create, suspend, upgrade and delete those accounts and give customers one-click sign-in. They use each server's token API, not the partner API.
- WHMCS module
- Blesta module
- Billing integration, for any other billing system
To issue licences from WHMCS or Blesta as well, call the partner API from the hook or provisioning step that creates a server in your billing system, as in the steps above. Keep the partner API key in the billing system's encrypted settings, never in a template.
Scripts
For anything you do on the servers themselves (accounts, domains, DNS, email, backups), call each server's token API; its OpenAPI description works with any OpenAPI client generator.
The partner API is a small JSON API, so any HTTP client works. A Python example that issues a licence and retries safely:
import json, os, urllib.request
def issue(email: str, ip: str, order: str) -> dict:
req = urllib.request.Request(
"https://api.hostfog.com/v1/licence/partner/issue",
data=json.dumps({"email": email, "ip": ip}).encode(),
headers={
"Authorization": "Bearer " + os.environ["HF_PARTNER_KEY"],
"Content-Type": "application/json",
"Idempotency-Key": "order-" + order,
},
method="POST",
)
with urllib.request.urlopen(req, timeout=30) as r:
return json.load(r)
Retry the same call with the same Idempotency-Key after a timeout, a 429 or a 5xx; it never issues two licences.