Child pages
  • Guide to UAPI
76 more child pages

Versions Compared

Key

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

 

Column
width70%

Introduction

Excerpt
UAPI accesses the cPanel interface's features.
 Use this API to access and modify cPanel account data and settings.

Note
titleNotes:
  • If you encounter problems with a local access method (LiveAPI PHP, LiveAPI Perl, or Template Toolkit), attempt a browser-based call.
  • You cannot call this API's functions via another API's call methods. For more information, read the API method distinctions section below.

Basic usage

Multiexcerpt
MultiExcerptNameBasicUsage
Localtab Group
Localtab
activetrue
titlecPanel or Webmail Session URL
Code Block
languagetext
/execute/Module/function?parameter=value&parameter=value&parameter=value
Localtab
titleLiveAPI PHP Class
Code Block
languagephp
linenumberstrue
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Call a UAPI function.
$function_result = $cpanel->uapi(
    'Module', 'function',
    array(
        'parameter'     => 'value',
        'parameter'     => 'value',
        'parameter'     => 'value',
         )
);

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink

Localtab
titleLiveAPI Perl Module
Code Block
languageperl
linenumberstrue
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Call a UAPI function.
my $function_result = $cpliveapi->uapi(
    'Module', 'function',
    {
        'parameter'     => 'value',
        'parameter'     => 'value',
        'parameter'     => 'value',
    }
);

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink

Localtab
titlecPanel Template Toolkit
Code Block
languagetext
linenumberstrue
<!-- Call a UAPI function. -->
[% 
execute( 
     'Module', 'function', 
     { 
        'parameter' => 'value', 
        'parameter' => 'value', 
        'parameter' => 'value', 
     } 
); 
%]

Include Page
LIB:_TTLink
LIB:_TTLink

Localtab
titleCommand Line
Code Block
languagetext
uapi  --user=username --output=type Module function parameter=value parameter=value
Note
titleNotes:
  • UAPI calls via the command line do not return the metadata that other methods return if they experience errors that prevent a successful function run. For more information, read our Guide to UAPI - Return Data documentation.
  • cPanel & WHM introduced the command line feature in version 56.

UAPI calls through the command line consist of the following basic parts:

 

PartDescription
CommandThis value is always UAPI for calls to UAPI.
UserThe account-level username.
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.

ModuleThe UAPI module name.
FunctionThe UAPI function.
UserThe cPanel account username.
Input parameters and values

The function's input parameters and their values.

  • You must URI-encode values.
  • Space-separate multiple parameter=value pairs.
  • 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 examples:

    Code Block
    languagebash
    linenumberstrue
    uapi --user username Module function key=[\"sslinstall\",\"videotut\"]"
    uapi --user username Module function key='{"videotut","sslinstall"}'

Include Page
LIB:_BooleanNote
LIB:_BooleanNote

Note
titleNote:

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

Code Block
uapi --help

Note
titleNote:

For more information about browser-based UAPI calls, read the cPanel or Webmail Session URL calls section below. 

This example uses the following variables:

VariableDescriptionPossible valuesExample
ModuleThe function's module.Any UAPI module.Email
functionThe UAPI function.Any UAPI function in the specified module.addpop
parametersThe function's input parameters.

Any parameter from the specified function.

domain
valueThe value to assign to the input parameter.Parameters accept a variety of values.example.com

Anchor
BrowserCalls
BrowserCalls
cPanel or Webmail Session URL calls

You can access UAPI functions directly from any web browser when you make the call from a cPanel or Webmail session.

Browser-based calls 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:

    • 2082 —Unsecure calls as a specific cPanel account.
    • 2083 — Secure calls as a specific cPanel account.
    • 2095 —Unsecure calls via a Webmail session.
    • 2096 — Secure calls via a Webmail session.
Warning
titleWarning:

Unless you call this API via the WHM API, you cannot call this API via WHM's ports (2086 or 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. 

ActionThis portion of the URL will always be execute.
ModuleThe UAPI module name.
FunctionThe UAPI function.
Input parameters and values

The UAPI 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

Include Page
LIB:_PageURLWarning
LIB:_PageURLWarning

Anchor
APIMethod
APIMethod
API method distinctions

Multiexcerpt include
MultiExcerptNameAPIExamples
PageWithExcerptGuide to Testing Custom Code