We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction


Excerpt

WHM API 0 accesses the WHM interface's features.

 You can use this API to perform server administration tasks, administer cPanel and WHM reseller accounts, and manage cPanel & WHM services.


Note
titleNotes:
  • Some WHM API 0 functions and parameters require that the authenticated user has specific privileges. Use the applist function to return a list of available WHM API 0 functions for the current authenticated user.
  • You cannot call this API's functions via another API's call methods. For more information, read the API method distinctions section below.


Warning
titleWarning:

WHM API 0 is deprecated. We strongly recommend that you only use the equivalent WHM API 1 functions instead. 

Basic usage


Multiexcerpt
MultiExcerptNameBasicUsage


Localtab Group


Localtab
activetrue
titleJSON API


Code Block
languagetext
https://hostname.example.com:2087/cpsess##########/json-api/accountsummary?user=username

WHM API calls through JSON consist of the following basic parts:

PartDescription
Server and port

The web server's HTTP address and the port number to use. Generally, this value begins with https:// and the domain name.

When you call this API, use the following ports:

  • 2086 — Unsecure calls as a specific WHM account.
  • 2087 — Secure calls as a specific WHM account.
Warning
titleWarning:

You cannot call this API via cPanel ports (2082 or 2083) or Webmail ports (2095 or 2096).


Security token

The current session's security token.

Note
titleNote:

Cookie-based calls (for example, calls from a web browser) require a security token. For other authentication methods, read our Guide to API Authentication documentation. 


API type

The API output type that you wish to receive.

  • Use json-api to return JSON-formatted output.
FunctionThe WHM API function.
Input parameters and values

The function's input parameters and their values.

  • Separate multiple parameter=value pairs with the ampersand character (&).
  • You must URI-encode these values.

Include Page
LIB:_BooleanNote
LIB:_BooleanNote

 



Localtab
titleXML API

Multiexcerpt include
MultiExcerptNameLong Warning
PageWithExcerptLIB:_XMLDeprecated

Code Block
languagetext
https://hostname.example.com:2087/cpsess##########/xml-api/accountsummary?user=username


Warning
titleWarning:

Include Page
LIB:_XMLWarning
LIB:_XMLWarning

WHM API calls through XML consist of the following basic parts:

PartDescription
Server and port

The web server's HTTP address and the port number to access.

  • Generally, this value begins with  https://  and the domain name.
  • For secure calls to the WHM API, the port is always 2087.
Security token

The current session's security token.

Note
titleNote:

Cookie-based calls (for example, calls from a web browser) require a security token. For other authentication methods, read our Guide to API Authentication documentation. 


API type

The API output type that you wish to receive.

  • Use xml-api to return XML-formatted output.
FunctionThe WHM API function.
Input parameters and values

The function's input parameters and their values.

  • Separate multiple parameter=value pairs with the ampersand character (&).
  • You must URI-encode these values.

Include Page
LIB:_BooleanNote
LIB:_BooleanNote

 



Localtab
titleCommand Line


Code Block
languagetext
whmapi0 accountsummary user=username


Note
titleNote:

cPanel & WHM introduced the command line feature in version 11.52.0.8.

WHM API calls through the command line consist of the following basic parts:

PartDescription
Command

This value is always whmapi0 for calls to WHM API 0.

Note
titleNote:

If you run CloudLinux™, you must use the full path of the whmapi0 command: 

Code Block
/usr/local/cpanel/bin/whmapi0



Output Type

The API output type that you wish to receive.

  • Use --output=json to return JSON-formatted output.
  • Use --output=jsonpretty to return indented JSON-formatted output.
  • Use --output=xml to return XML-formatted output.

    Multiexcerpt include
    MultiExcerptNameShort Macro
    PageWithExcerptLIB:_XMLDeprecated

  • Use --output=yaml to return YAML-formatted output.
Note
titleNote:

This parameter defaults to --output=yaml.


FunctionThe WHM API function.
Input parameters and values

The function's input parameters and their values.

  • Separate multiple parameter=value pairs with a space character.
  • You must URI-encode these values.
  • Special characters within a key's value may cause an error. You must either escape any special characters within values or surround the value with appropriate quotes. For more information, read Wikipedia's Escape Characters article.
    For example, a bash shell command with a JSON-encoded value may appear similar to one of the following:
    • whmapi0 function key=[\"sslinstall\",\"videotut\"]"
    • whmapi0 function key='{"videotut","sslinstall"}'

Include Page
LIB:_BooleanNote
LIB:_BooleanNote


Note
titleNote:

For more information about this feature, run the following command:

Code Block
whmapi0 --help





Include Page
LIB:_PageURLWarning
LIB:_PageURLWarning


Anchor
APIMethod
APIMethod
API method distinctions

Multiexcerpt include
MultiExcerptNameAPIExamples
PageWithExcerptGuide to Testing Custom Code