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

Add a Package — addpkg

Overview

This function adds a new hosting package.

Calling Functions

Using the XML API

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

  • Append the /xml-api/addpkg 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/addpkg

  • 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 addpkg function from within your custom script:

  • Append the /json-api/addpkg 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/addpkg

  • 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 addpkg function takes the following variables as input.

The following variable is required:

  • name (string) — Name of the package.

The following variables are optional:

  • featurelist (string) — Name of the feature list to be used for the package.
  • quota (integer) — Disk space quota for the package (in Megabytes). Maximum: unlimited
  • ip (boolean) — Whether the account has a dedicated IP.
    • 1 — yes.
    • 0 — no.
  • cgi (boolean) — Whether the account has CGI access.
    • 1 — yes.
    • 0 — no.
  • frontpage (boolean) — Whether the account can install FrontPage extensions.
    • 1 — yes.
    • 0 — no.
  • cpmod (string) — The default theme for the package.
    • If no value is provided, the function will use the cPanel default theme (set in WHM in the Basic cPanel & WHM Setup screen). This behavior only applies to version 11.36+.
  • language (string) — Name of the language to be used for this package by default.
  • max_defer_fail_percentage (integer) — The percentage of failed or deferred email messages the account can send per hour before outgoing mail is rate-limited. This parameter's default value is unlimited.
  • max_email_per_hour (integer) — The maximum number of emails the account can send in an hour. This parameter's default value is unlimited. Entering 0 here will result in an unlimited value.
  • maxftp (integer) — The number of FTP accounts an account assigned to the package can create. Maximum: 999
  • maxsql (integer) — The number of SQL databases an account assigned to the package can create. Maximum: 999
  • maxpop (integer) — The number of email accounts an account assigned to the package can create. Maximum: 999
  • maxlst (integer) — The number of email lists an account assigned to the package can create. Maximum: 999
  • maxsub (integer) — The number of subdomains an account assigned to the package can create. Maximum: 999
  • maxpark (integer) — The number of parked domains an account assigned to the package can create. Maximum: 999
  • maxaddon (integer) — The number of addon domains an account assigned to the package can create. Maximum: 999
  • hasshell (boolean) — Whether the account has shell access.
    • 1 — yes.
    • 0 — no.
  • bwlimit (integer) — The amount of bandwidth the account can use in a month. Maximum: unlimited

The following variable was introduced in version 11.34:

  • digestauth (boolean) — Whether the account should have digest authentication enabled.
    • 1 — yes.
    • 0 — no.

The following variable was introduced in version 11.40:

  • _PACKAGE_EXTENSIONS (space delimited) — The package extensions associated with this package.
    • If you have one or more package extensions associated with the package, you can also input the variables associated with the extension when you use the addpkg function. Consult the documentation for your extension for a list of possible variables.
      PICK Remember: The _PACKAGE_EXTENSIONS key, its values, and all associated package extensions variables are case-sensitive.

Output

  • addpkg — Root-level XML tag for the output of the addpkg function.
    • result — Result of the package addition function.
      • pkg (string) — Name of the package.
      • status (boolean) — Whether the operation was successful.
        • 1 — yes.
        • 0 — no.
      • statusmsg (string) — Message about the result of the operation.

Examples

XML API

note Note: Submit the entire request as a single string. For display purposes, the example below may be wrapped.

Calling https://example.com:2087/xml-api/addpkg?name=packagename&featurelist=Default&quota=0&ip=1&cgi=1&frontpage=1&cpmod=x3 &maxftp=9&maxsql=99&maxpop=999&maxlst=999&maxsub=888&maxpark=88&maxaddon=888 &hasshell=1&bwlimit=9999 in WebHost Manager will produce output similar to the following:

<addpkg>
     <result>
            <pkg>packagename</pkg>
            <status>1</status>
            <statusmsg>Created the package packagename</statusmsg>
      </result>
</addpkg>

This will add the package packagename, with the settings listed in the call.

JSON API

note Note: Submit the entire request as a single string. For display purposes, the example below may be wrapped.

Calling https://example.com:2087/json-api/addpkg?name=package1&featurelist=Default&quota=0&ip=1&cgi=1&frontpage=1&cpmod=x3 &maxftp=9&maxsql=99&maxpop=999&maxlst=999&maxsub=888&maxpark=88&maxaddon=888 &hasshell=1&bwlimit=9999 in WebHost Manager will produce output similar to the following:

{
   "result":[
      {
         "status":1,
         "statusmsg":"Created the package package1",
         "pkg":"package1"
      }
   ]
}

This will add the package package1, with the settings listed in the call.

Topic revision: r13 - 19 Sep 2013 - 16:22:57 - Main.SarahHaney