How to Use cPanel API Tokens
Last modified: July 19, 2022
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.
- API tokens run UAPI functions and cPanel API 2 functions, not cPanel API 1 functions.
- To learn more about using API functions, read our Quickstart Development Guide documentation.
- If you do not see this feature, your system administrator has disabled it. Contact them and ask them to enable this feature in WHM’s Feature Manager interface (WHM » Home » Package » Feature Manager).
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
You can use one of the following methods to create an API token:
Use cPanel’s Manage API Tokens interface (cPanel » Home » Security » Manage API Tokens).
Use the UAPI
- In cPanel & WHM version 82, when an API token expires, the system does not remove it. You must manually delete an API token.
- You can remove an API token with cPanel’s Manage API Tokens interface (cPanel » Home » Security » Manage API Tokens) or the UAPI
Run API functions with the token
You must use the API token that you created in cPanel.
To call a
cPanel API 2 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:
||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:
curl -H'Authorization: cpanel username:U7HMR63FHY282DQZ4H5BIH16JLYSO01M' 'https://example.com:2083/execute/Email/add_pop?email=newuser&password=12345luggage'