API Documentation

The API functions are designed only for Master Resellers to perform operation on their resellers

API URL : http://serverip:2086/cgi/whmphp/master/api.php The output will be json encoded string.

Method : POST or GET
Required values : WHM username, ServerIP/domain, WHM password.
Permission : The user must have Reseller as well as Master Reseller permission

For WHMCS Module please refer this page

$serverip ="" ; // Server IP address of domain name if the domain is pointed to the server
$cpanel_username = "master" ; // cPanel username
$cpanel_password = "mypass" ; // cPanel password

$request = "/cgi/whmphp/master/api.php?action=listresellers";
$output = json_decode(connect($request),true);

// Here, the $output contains the list of resellers
// To print it use foreach

foreach($output['reseller'] as $reseller)
echo $reseller ;
// ends

// You can execute all the calls like this fashion.

// Function to connect to both whm and cpanel. No editing is required
function connect($request)
global $serverip,$cpanel_password,$cpanel_username;
$ch = curl_init (); // Initiate curl
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_URL, '' . 'https://' . $serverip . ':2087' . $request);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$authstr = 'Basic ' . base64_encode ($cpanel_username . ':' . $cpanel_password);
$curlheaders[0] = '' . 'Authorization: ' . $authstr;
curl_setopt ($ch, CURLOPT_HTTPHEADER, $curlheaders);
$data = curl_exec ($ch);
curl_close ($ch);
return $data ;
The following are the available functions
  • createreseller($domain,$username,$password,$email,$package)
  • suspendreseller($username)
  • unsuspendreseller($username)
  • terminatereseller($username)
  • listresellers()
  • setlimit($username,$disk,$band,$ns1,$ns2,$limit,$oversell_disk,$oversell_bw)
  • changepwd($username,$password)
For example,
Creating a reseller, you need to post values as follows
Note: Only the example of password based authentication is shown here. You can also modify the code and switch to access hash based authentication. For more information about cPanel Api authentication please refer this page