Skip to content
Last updated

Overview

cPanel & WHM recognizes API tokens and allows applications or users to run API functions with the cPanel account's data. API functions allow you to view and change cPanel account data without logging in to the cPanel interface. For example, you could issue an API token to a third-party developer. That third-party developer could use that token to check disk usage.

Creating an API token

You can create API tokens in the cPanel interface or via UAPI's Tokens::create_full_access function. For information about how to create an API token in the cPanel interface, read cPanel's Manage API Tokens interface (cPanel >> Home >> Security >> Manage API Tokens) documentation.

Using an API token

To call a UAPI function with an API token, run the following command from the command line:

curl -H'Authorization: cpanel username:APITOKEN' 'https://example.com:2083/execute/Module/function?parameter=value'

This example uses the following format:

ItemDescriptionExample
usernameThe cPanel account's username.username
APITOKENThe API token.U7HMR63FGY292DQZ4H5BFH16JLYMO01M
example.comYour cPanel server's domain or IP addressexample.com
ModuleThe API module name.Email
functionThe API function's name.add_pop
parameterThe function's input parameters.email
valueThe value to assign to the input parameter.12345luggage

For example, your command may resemble the following example:

curl -H'Authorization: cpanel username:U7HMR63FHY282DQZ4H5BIH16JLYSO01M' 'https://example.com:2083/execute/Email/add_pop?email=newuser&password=12345luggage'