Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Change Package — changepackage

This function changes the hosting package associated with a cPanel account.

Calling Functions

Using the XML API

To use the XML API to perform the changepackage function from within your custom script:

  • Append the /xml-api/changepackage function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/changepackage

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the changepackage function from within your custom script:

  • Append the /json-api/changepackage function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/changepackage

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The changepackage function takes the following required variables as input:
  • user (string) — User name of the account to change the package for.
  • pkg (string) — Name of the package that the account should use.

Output

  • changepackage — Root-level XML tag for the output of the changepackage function.
    • result — Result of the package change.
      • rawout — Raw output of the changepackage function.
      • status (boolean) — Whether or not the upgrade was successful.
        • 1 — yes.
        • 0 — no.
      • statusmsg (string) — Status message about the result of the function call.

Examples

XML API

Calling https://example.com:2087/xml-api/changepackage?user=bob&pkg=gold in WebHost Manager will produce output similar to:

<changepackage>
    <result>
        <rawout>
            Changing bwlimit to unlimited Meg
            Changing Feature List to default
            Changing max pop accounts from unlimited to unlimited
            Changing max sql accounts from unlimited to 10
            Changing max ftp accounts from unlimited to 10
            Changing max lists from 10 to 5
            Changing max sub domains from unlimited to 10
            Changing language from english to english
            Changing max parked domains from 9999 to 0
            Changing max addon domains from 9999 to 0
            Adding Shell Access
            Shell already set to /bin/bash
            Changing cpanel module from x3 to x
            Changing plan from Limit One to level3
            Resetting QUOTA....
            Using Quota v3 Support
            Bandwidth limit (0) is lower than (unlimited) (all limits removed)
            Enabling......asdfasdf.com...Done
            Warning, this will not cause ip-less accounts to become ip access, 
             or the reverse. 
        </rawout>
        <status>1</status>
        <statusmsg>Account Upgrade/Downgrade Complete for asdfasdf</statusmsg>
    </result>
</changepackage>

JSON API

Calling https://example.com:2087/json-api/changepackage?user=bob&pkg=gold in WebHost Manager will produce output similar to:

{
   "result":[
      {
         "status":1,
         "statusmsg":"Account Upgrade/Downgrade Complete for bob",
         "rawout":"<pre>\nChanging bwlimit to unlimited Meg\nChanging Feature List to 
default\nChanging max pop accounts from 3 to unlimited\nChanging max sql accounts 
from 6 to unlimited\nChanging max ftp accounts from 0 to unlimited\nChanging max 
lists from unlimited to unlimited\nChanging max sub domains from 3 to unlimited
\nChanging language from english to english\nChanging max parked domains 
from 4 to 2\nChanging max addon domains from 5 to 2\nAdding Shell Access
\nChanging shell for bob.\nShell changed.\nChanging cpanel module from x3 to 
x3\nChanging plan from level3  to gold\nResetting QUOTA....\nUsing Quota v3 
Support\nBandwidth limit (0) is lower than (unlimited) (all limits removed)<br />
<blockquote><div style='float:left;'>Enabling...</div><div style='float:left;'>
...example.com...</div><div style='float:left;'>Done</div>
</blockquote><br /><div class='clearit' style='clear:both; width:80%;'>&nbsp;</div>
<span class=\"b2\">Warning, this will not cause ip-less accounts to become ip 
access, or the reverse.</span>\n"
      }
   ]
}

Topic revision: r6 - 29 Sep 2009 - 17:40:46 - MelanieSeibert