Connect Blesta, HostBill and other billing systems (json-api)

For server administrators · Updated 2026-10-29

On this page
  1. Before you start
  2. Set up the billing system
  3. Calling a function
  4. Functions
  5. Good to know
  6. Examples
  7. Common questions

Besides the REST API, the server answers a /json-api/<function> interface on port 2087 with the function names many hosting billing systems use: createacct, suspendacct, changepackage and so on.

Before you start

  • An administrator or reseller API token. A reseller's token works only on the reseller's accounts and within their privileges.
  • Add the billing server's IP address to the Whitelisted IPs of Brute Force Protection.

Set up the billing system

  1. Add a server with the hosting control panel module that asks for a username and an API token.
  2. Hostname: the server's hostname, port 2087, with SSL.
  3. Username: your admin or reseller username. API token: the token.
  4. In each product, enter the package name exactly as it is in the panel.

The request must carry the token in the Authorization header, as Bearer <token> or as sahaab <username>:<token>.

Calling a function

GET or POST https://<server>:2087/json-api/<function>?api.version=1&<parameters>

With api.version=1 the answer is:

{"metadata": {"version": 1, "reason": "OK", "result": 1, "command": "listaccts"}, "data": { ... }}

result is 1 on success, 0 on failure, with the reason in reason. Without api.version=1 the answer uses the older format that older modules expect.

Functions

FunctionWhat it doesParameters
createacctCreate an accountusername, domain, plan (package name), contactemail, password
suspendacctSuspenduser, reason (optional)
unsuspendacctUnsuspenduser
removeacctTerminateuser
changepackageChange the packageuser, pkg
passwdChange the passworduser, password
modifyacctChange contact email, main domain or usernameuser, any of contactemail, domain, newuser
listacctsList accountsoptional search, searchtype (user, domain, owner, package, ip), searchmethod=exact
accountsummaryOne accountuser
listpkgsPackages and their limits—
showbwBandwidth per account for a monthoptional month, year, search
create_user_sessionOne-time sign-in link (60 seconds)user
gethostnameThe server's hostname—
versionThe panel version—
applistThe supported functions—

Good to know

  • If createacct has no plan, the token owner's first package is used. Without contactemail, the token owner's email is used. It returns the account's IP and nameservers.
  • A package name with the reseller's username in front (reseller1_Basic) also finds Basic.
  • Account details include the domain, contact email, package, owner, IP, suspension and reason, disk used and limit, and the package's limits.
  • A read-only token may call only version, applist, listaccts, accountsummary, listpkgs, showbw and gethostname.

Examples

Create an account:

curl -s -H "Authorization: Bearer $TOKEN" \
  "https://server1.example.com:2087/json-api/createacct?api.version=1" \
  --data-urlencode "username=shop1" \
  --data-urlencode "domain=shop-example.com" \
  --data-urlencode "plan=Basic" \
  --data-urlencode "[email protected]" \
  --data-urlencode "password=Str0ng-Passw0rd!"

Suspend:

curl -s -H "Authorization: Bearer $TOKEN" \
  "https://server1.example.com:2087/json-api/suspendacct?api.version=1&user=shop1&reason=Unpaid+invoice"

Sign-in link for the customer (data.url):

curl -s -H "Authorization: Bearer $TOKEN" \
  "https://server1.example.com:2087/json-api/create_user_session?api.version=1&user=shop1"

Common questions

The billing system says "Access denied". Why?

The token is wrong, expired, not allowed from that address, or the reseller lacks the privilege; the reason follows "Access denied". See API errors.

Was this article helpful?

Still stuck?

Ask the AI about your exact situation — it answers from this knowledge base — or contact us.