Page tree
Skip to end of metadata
Go to start of metadata

 

Introduction

You can call cPanel API and UAPI functions through the WHM API.

Note:

We introduced this feature in cPanel & WHM version 11.48.

This method is useful, for example, when you develop plugins for WHM users, particularly resellers, but need to access cPanel functions. You can make these calls from within either the WHM or cPanel interfaces.

For more information about WHM API calls, read our Guide to WHM API 1 documentation.

Basic usage

WHM API calls consist of the following basic parts:

ItemDescriptionExample
Server

The web server's HTTP address.

Generally, this value is https:// and the hostname.

https://hostname.example.com
Port

The port number to access.

  • 2087 — Secure connection.
  • 2086 — Insecure connection.

Notes:

  • We strongly recommend that you use port 2087 and a secure connection.
  • If you use port 2086 and enable the Always redirect to SSL option in WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings), the system redirects insecure API calls and causes errors.
2087
Security TokenThe current session's security token.cpsess123456789
Output format

The output type to return.

Important:

  • This API's XML output does not comply with XML standards, is slower than JSON output to produce, and may result in validation errors. We strongly recommend that you use JSON.
  • cPanel & WHM version 66 deprecated XML output.
  • You must use the correct JSON or XML versions of the cPanel User, cPanel API or UAPI Module, cPanel API or UAPI Function, and cPanel API Version parameters below.

json_api

or

xml_api

FunctionThe WHM API function to call. For cPanel API1, cPanel API2, and UAPI, use the cpanel function.cpanel
cPanel User

The cPanel username for the account through which to call the function.

Make certain that you specify the username in lowercase characters only. cPanel & WHM automatically converts usernames to lowercase when you create a cPanel account. For this reason, if you supply a username that includes some or all capital letters, the call will fail.

cpanel_jsonapi_user=user

or

cpanel_xmlapi_user=user

cPanel API or UAPI Module

The UAPI module name.

Important:

Module names are case-sensitive

cpanel_jsonapi_module=Email

or

cpanel_xmlapi_module=Email

cPanel API or UAPI Function

The UAPI function name.

Important:

Function names are case-sensitive

cpanel_jsonapi_func=listpopswithdisk

or

cpanel_xmlapi_func=listpopswithdisk

cPanel API Version

The cPanel API version to use.

  • 1 — Use cPanel API 1.
  • 2 — Use cPanel API 2.
  • 3 — Use UAPI.

Warning:

If you do not supply this parameter, the system defaults to cPanel API 2.

 

 

cpanel_jsonapi_apiversion=3

or

cpanel_xmlapi_version=3

Variable Names and Values

The function's input parameters and their values.

Notes:

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