In cPanel & WHM version 80, we introduced cPanel application programming interface (API) tokens. cPanel users can issue these API tokens. The server recognizes API tokens and allows other users to run API functions with the account's data. API functions allow you to view and change account data without the need to log 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.
How to use a cPanel API token
To use a cPanel API token, first, create a cPanel API token in cPanel's Manage API Tokens interface (cPanel >> Home >> Security >> Manage API Tokens). Then, use the token to run API functions on the server.
Create an API token
To create an API token:
- Navigate to cPanel's Manage API Tokens interface (cPanel >> Home >> Security >> Manage API Tokens).
- Click Create. The Create API Token interface will appear.
Enter a name in the API Token Name text box.
- An API token name can only contain up to 50 characters.
- You can only enter letters (
z) and (
Z), numbers (
9), dashes ( - ), and underscores ( _ ).
- You must enter a name that does not already exist on the account.
Click Create. A new interface will appear.
To copy the API token, click Copy. You must enter this token each time that you call an API function, similar to a password.
You cannot access the token after you navigate away from the interface. If you forget or misplace this token, you must revoke the token and then create a new one.
Click Yes, I Saved My Token.
To create a new token, select the Create another token after I click Yes, I saved my token checkbox.
To return to the List API Tokens interface, deselect the Create another token after I click Yes, I saved my token checkbox.
Run API functions with the token
You must use the API token that you created in cPanel.
To call a UAPI or cPanel API 2 function with an API token, run the following command from the command line:
This example uses the following format:
|The cPanel account's username.|
|The API token.|
|Your cPanel server's domain.|
Alternatively, you can enter your server's IP address.
The API module name.
The API function's name.
|The function's input parameters.|
|The value to assign to the input parameter.|
For example, your command may resemble the following example: