Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

customip value not responsive with cpanel PHP XML API

Discussion in 'cPanel Developers' started by jonbarnes, Mar 5, 2012.

  1. jonbarnes

    jonbarnes Registered

    Mar 5, 2012
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    Hi I am trying to run a simple api command that creates a new account and assigns it to a specific ip (which is determined elsewhere in the program). I can use the 'createacct' function fine except the 'customip' value seems to be ignored when setting up the new account. As a workaround, I can then submit a 'setsiteip' query that will change the IP but I would like to do this all from the 'createacct' function if possible.

    Here is what I have so far:

    ); //the first query has been automatically setting it to the shared root IP and then I change it to the desired IP address with the second query
    foreach($queries as $query){
    	$curl = curl_init();		
    	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);	
    	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0); 	
    	curl_setopt($curl, CURLOPT_HEADER,0);			
    	curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);	
    	$header[0] = "Authorization: Basic " . base64_encode($whmusername.":".$whmpassword) . "\n\r";
    	curl_setopt($curl, CURLOPT_HTTPHEADER, $header);  
    	curl_setopt($curl, CURLOPT_URL, $query);			
    	$result = curl_exec($curl);
    	if ($result == false) {
    		error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");	
    	echo $result."<br />";
    Instead, I would like to have:
    but, as stated above, the 'customip' value seems to be disregarded as the single query above still assigns the shared root IP. I'm new to the API but it seems fairly straightforward and I can't tell why it is not assigning my requested IP.

    Thanks in advance,

    p.s. I have checked to make sure all the values work and the IP address exists
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Nov 29, 2006
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    To clarify, is this account being created going to have a dedicated IP or are you trying to explicitly specify a specific shared IP address the account should be created on?
  3. Brian

    Brian Well-Known Member

    Dec 1, 2010
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    Root Administrator
    The issue is likely that you're telling the API "yes and no" at the same time in regards to the dedicated IP with your options.

    The following arguments are being set by your example:


    "customip" has no meaning unless "ip" is set to "y" (yes). You must firstly tell the API you want a dedicated IP (ip=y) and then you can optionally instruct a preferred IP with customip.

    Be aware of two further caveats that may be at play if you resolve that and the problem persists.

    [1] If you're performing this API call as a reseller, you must have the 'add-pkg-ip' ACL privilege (Allow Creation of Packages with a Dedicated IP). Without it, the options are for naught and the shared IP will only ever result.

    [2] If the custom IP you've specified is not considered an open and available IP according to "WHM -> Show IP Address Usage", then WHM will fall back to the shared IP address as opposed to failing the creation.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice