Quick start
Every contPanel server has the API built in. There is nothing to install on the server — create a token and call it.
:2087 → Developer → New token. Limit it to your billing server’s IP address and choose full or read-only access.{"action":"test"} to https://SERVER:2087/api/. The answer contains "pong": true.curl -sk https://SERVER:2087/api/ -H "X-API-Key: cpk_YOUR_TOKEN" -d '{"action":"test"}'Authentication
Send the token in one of these headers. Both are accepted on every request:
| Header | Example |
|---|---|
X-API-Key | X-API-Key: cpk_3f9c… — recommended, passes every proxy |
Authorization | Authorization: Bearer cpk_3f9c… |
- Tokens start with
cpk_, are shown once when created and stored on the server only as a SHA-256 hash. - Access: Full access may change accounts; Read only may only call
test,server.info,package.list,account.list,account.getandusage. - Allowed addresses: optional list of IPs or CIDR ranges (IPv4 and IPv6). Calls from anywhere else are refused.
- TLS: the server uses its panel certificate. Until a real certificate is issued for the host name it is self-signed — use
-kin curl or disable peer verification in your HTTP client.
Requests & answers
One endpoint: POST https://SERVER:2087/api/. The body is a JSON object with an action and its parameters. Form-encoded bodies work too.
{"ok": true, "data": { … }}{"ok": false, "error": "username_taken", "message": "optional detail"}HTTP status is 200 for success, 400 for a failed action, 401 for a missing or wrong token, 403 for a refused address or a read-only token, 429 for the rate limit.
Errors
| error | Meaning |
|---|---|
api_unauthorized | Token missing or wrong |
api_ip_not_allowed | The caller’s address is not in the token’s list |
api_read_only | A read-only token tried to change something |
api_rate_limited | More than 300 calls in the last minute |
api_unknown_action | The action name does not exist |
license_locked | The server’s license is not valid; reading still works |
account_not_found | No account with that username |
username_taken · invalid_username | Username exists, or is not 3–16 lowercase letters/digits starting with a letter |
invalid_domain · site_exists | The domain is invalid or already on this server |
password_short | Passwords need at least 8 characters |
license_limit | The license’s account limit is reached |
api_failed | Unexpected server error; message has the detail |
Limits & security
- 300 calls per minute per token.
- The API answers only on port 2087; the customer port 2083 never serves it.
- Every change is written to the server log with the token name, action, account and caller address. Developer shows each token’s last use, address and call count.
- Deleting a token stops it immediately.
Reference
Parameters go next to action in the JSON body. username is always the contPanel account name.
test
readChecks the token and the connection.
{"ok":true,"data":{"pong":true,"version":"1.7.0","time":"2026-11-14T21:00:00+00:00"}}server.info
readVersion, host name, license state, number of accounts and sites, and current load.
{"ok":true,"data":{"version":"1.7.0","hostname":"server1.example.com",
"license":{"valid":true,"reason":""},"accounts":42,"sites":67,"system":{ "load":[0.21,0.18,0.12], "memory":{…}, "disk":{…} }}}package.list
readThe packages defined in Root → Packages. Use id or name wherever a package is expected.
{"ok":true,"data":[{"id":"starter","name":"Starter","disk_mb":5120,"max_sites":5,"max_dbs":5,"accounts":12}]}account.list
readAll accounts with package, owner, sites, databases, disk use and state.
{"ok":true,"data":[{"username":"alice","domain":"alice.com","email":"[email protected]","package":"starter",
"package_name":"Starter","owner":"admin","sites":2,"dbs":1,"disk_used":734003200,"disk_mb":5120,"suspended":false,"created_at":"2026-11-02 10:14"}]}account.get
readOne account, including its usage (same fields as usage).
| Parameter | Description |
|---|---|
username * | Account name |
account.create
writeCreates the Linux user, /home/USERNAME/public_html, the site with its PHP pool and web server config, the DNS zone, the main FTP login and starts AutoSSL.
| Parameter | Description |
|---|---|
username * | 3–16 characters, lowercase letters and digits, starts with a letter |
domain * | Primary domain, e.g. alice.com |
package * | Package id or name |
password | At least 8 characters. Empty → a strong password is generated and returned |
email | Contact address of the customer |
reseller | true to create a reseller account |
{"ok":true,"data":{"username":"alice","password":"S3cure!pass","domain":"alice.com"}}account.suspend
writeStops the account’s sites (a suspension page is shown), FTP and panel sign-in. Files and databases stay.
| Parameter | Description |
|---|---|
username * | Account name |
reason | Shown to root in the panel, e.g. unpaid |
account.unsuspend
writeBrings a suspended account back exactly as it was.
| Parameter | Description |
|---|---|
username * | Account name |
account.password
writeChanges the panel, main FTP and SFTP password together.
| Parameter | Description |
|---|---|
username * | Account name |
password | At least 8 characters. Empty → generated and returned |
account.package
writeMoves the account to another package (upgrade or downgrade). New limits apply at once.
| Parameter | Description |
|---|---|
username * | Account name |
package * | Package id or name |
account.delete
writeRemoves the account with its sites, databases, DNS zones, FTP logins, certificates and /home/USERNAME. This cannot be undone.
| Parameter | Description |
|---|---|
username * | Account name |
usage
readDisk use and this month’s web traffic. Without username it returns every account — one call is enough for a nightly sync.
| Parameter | Description |
|---|---|
username | Account name (optional) |
{"ok":true,"data":{"disk_mb":700,"disk_limit_mb":5120,"bandwidth_mb":18342,"bandwidth_month":"2026-11","sites":2,"databases":1,"suspended":false}}{"ok":true,"data":{"accounts":{"alice":{"disk_mb":700,"disk_limit_mb":5120,"bandwidth_mb":18342,…},"bob":{…}}}}sso
writeReturns a one-time link that signs the customer into their panel on port 2083. Valid for 60 seconds, usable once.
| Parameter | Description |
|---|---|
username * | Account name |
host | Host name for the link (default: the server’s host name) |
{"ok":true,"data":{"url":"https://server1.example.com:2083/sso.php?c=8f1e…","expires_in":60}}WHMCS & HostBill modules
WHMCS
Provisioning module with package loader, daily usage sync and single sign-on.
- Unzip into your WHMCS folder →
modules/servers/contpanel/ - System Settings → Servers → Add: module contPanel, host name, port
2087, Secure on, token in Access Hash. Test Connection. - Products → Module Settings: choose contPanel and the package.
HostBill
Hosting module with package loader, account and usage sync and “Log in to contPanel” for clients and admins.
- Unzip into your HostBill folder →
includes/modules/Hosting/contpanel/, then Settings → Modules → Hosting Modules: activate contPanel. - Settings → Apps → Add new App: contPanel, host name, Secure on, token in Hash (port 2087 by default). Test Connection.
- Product → Connect with App: choose contPanel and the package.
| Billing event | WHMCS | HostBill | API action |
|---|---|---|---|
| Order activated | CreateAccount | Create | account.create |
| Invoice overdue | SuspendAccount | Suspend | account.suspend |
| Invoice paid | UnsuspendAccount | Unsuspend | account.unsuspend |
| Cancelled | TerminateAccount | Terminate | account.delete |
| Password change | ChangePassword | ChangePassword | account.password |
| Upgrade / downgrade | ChangePackage | ChangePackage | account.package |
| Usage | UsageUpdate (daily) | getSynchInfo | usage |
| Log in button | ServiceSingleSignOn | getLoginUrl | sso |
Other modules
coremio/modules/Servers/ContPanel/), then add a server of type contPanel with the token as access hash.Examples
<?php
function contpanel($action, array $params = []) {
$ch = curl_init('https://server1.example.com:2087/api/');
curl_setopt_array($ch, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode(['action' => $action] + $params),
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-API-Key: ' . getenv('CONTPANEL_TOKEN')],
CURLOPT_SSL_VERIFYPEER => false, // self-signed until the panel certificate is issued
]);
$r = json_decode(curl_exec($ch), true);
if (empty($r['ok'])) throw new RuntimeException($r['error'] ?? 'connection failed');
return $r['data'];
}
$acc = contpanel('account.create', ['username' => 'alice', 'domain' => 'alice.com', 'package' => 'Starter']);
echo $acc['password'];
import os, requests
def contpanel(action, **params):
r = requests.post("https://server1.example.com:2087/api/",
json={"action": action, **params},
headers={"X-API-Key": os.environ["CONTPANEL_TOKEN"]},
verify=False, timeout=300).json()
if not r.get("ok"):
raise RuntimeError(r.get("error"))
return r["data"]
for user, u in contpanel("usage")["accounts"].items():
print(user, u["disk_mb"], "MB disk,", u["bandwidth_mb"], "MB traffic")
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // self-signed until the panel certificate is issued
async function contpanel(action, params = {}) {
const res = await fetch('https://server1.example.com:2087/api/', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-API-Key': process.env.CONTPANEL_TOKEN },
body: JSON.stringify({ action, ...params }),
});
const r = await res.json();
if (!r.ok) throw new Error(r.error);
return r.data;
}
const { url } = await contpanel('sso', { username: 'alice' });
console.log('Open:', url);
curl -sk https://server1.example.com:2087/api/ \
-H "X-API-Key: $CONTPANEL_TOKEN" \
-d '{"action":"account.suspend","username":"alice","reason":"unpaid"}'