API Tokens in cPanel
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:
Item | Description | Example |
---|---|---|
username |
The cPanel account's username. | username |
APITOKEN |
The API token. | U7HMR63FGY292DQZ4H5BFH16JLYMO01M |
example.com |
Your cPanel server's domain or IP address | example.com |
Module |
The API module name. | Email |
function |
The API function's name. | add_pop |
parameter |
The function's input parameters. | email |
value |
The 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'