1. Home
  2. Docs
  3. Developer Guide
  4. API
  5. API Introduction and Authentication

API Introduction and Authentication

The CWP API lets other software — billing systems such as WHMCS or Blesta, your own scripts, or a mobile app — manage a CWP server automatically: create and suspend hosting accounts, manage packages, domains, email, FTP, databases, SSL certificates and cron jobs, and log users in to their panel.

This page explains how the API works and how to make your first call. The other pages in this section describe every function with real request and response examples.

How it works

  • Endpoint: https://YOUR-SERVER:2304/v1/FUNCTION/, for example https://203.0.113.10:2304/v1/account/
  • Method: always POST, with form fields (application/x-www-form-urlencoded)
  • Authentication: an API key sent in the key field
  • Operation: the action field — usually add, udp (update), del, list, susp (suspend) or unsp (unsuspend)
  • Response: JSON (or XML, chosen per key)

The API runs as its own service on port 2304 with the server’s SSL certificate. Make sure the port is open in the firewall for the IP addresses that will call the API.

Step 1: Create an API key

In the CWP admin panel open CWP Settings → API Manager and click Allow new Api access.

API Manager in the CWP admin panel
Create New API Key window
FieldWhat to enter
Short NameA label, for example WHMCS Integration
Ip OriginThe IP address of the system that will call the API. Only requests from this IP are accepted. ALL (or %) allows any IP — avoid it on production servers.
Key codeClick Generate to create a random key. Treat it like a password.
Ownerroot for full access, or a reseller account — then the key can only manage that reseller’s own customers and packages
Format RequestJSON (recommended) or XML
Enable Functions forPresets that switch on the functions typically needed by CWP to CWP transfers, WHMCS, CLUSTER CWP or the APP CWP mobile app
API FunctionsSwitch on exactly the actions this key may use (see the table below)

Click Create. The key appears in the API Credentials List, where you can switch it off, edit it or delete it. The Interactive Documentation tab shows the parameters of each function inside the panel.

Warning: Give each integration its own key, limited to its IP address and to the functions it really needs. Never put an API key in JavaScript or anywhere a website visitor could see it.

Step 2: Test the connection

curl -k -X POST https://203.0.113.10:2304/v1/testconex/ -d "key=YOUR_API_KEY"

Response:

{"status":"OK","result":"Conex Api OK"}

-k skips certificate verification and is only needed while the server uses a self-signed certificate. In production, install a valid certificate for the server hostname and call the API by that hostname.

Step 3: Your first real call

List all hosting accounts:

curl -k -X POST https://203.0.113.10:2304/v1/account/ -d "key=YOUR_API_KEY&action=list"
{"status":"OK","msj":[{"username":"john","domain":"example.com","email":"john@example.com","package_name":"default","status":"active", ...}]}

Functions and permissions

Each function needs its permission to be switched on for the key in API Manager.

Function (URL)ActionsAPI Manager row
accountadd, udp, del, list, susp, unspAccount
accountdetaillistAccount Details
account_metadatalistMetadata Account
accountquotalistAccount Quota
quotalimitlistQuota limit
changepackudpAccount pack change
changepassudpChange of password
user_sessionlistAutologin
packagesadd, udp, del, listPackages
admindomainsadd, del, listDomains and Subdomains
emailadd, udp, del, list, susp, unspEmail
emailadminlistEmail Admin Server
ftpadd, udp, del, listFTP
databasemysqladd, del, list, susp, unspMySQL Databases
usermysqladd, udp, del, listMySQL Users
autossladd, del, list, renewAutoSSL
dkimaddDkim (Domain)
cronjobsusersadd, del, listCronjobs Users
typeserverlistType Server
testconex—always allowed for a valid key

Security checklist

  • Restrict every key to one Ip Origin.
  • Enable only the functions the integration needs.
  • Use HTTPS with a valid certificate and keep port 2304 closed to the rest of the internet.
  • Switch off or delete keys you no longer use.
  • All calls are logged on the server in /var/log/cwp/cwp_api.log (date, key and result) — useful for troubleshooting and auditing.

Next steps

Was this article helpful to you? No Yes