Page tree
Skip to end of metadata
Go to start of metadata

Overview

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.

Note:

API tokens run UAPI functions and cPanel API 2 functions, not cPanel API 1 functions. For more information, read our Quickstart Development Guide documentation.

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:

  1. Navigate to cPanel's Manage API Tokens interface (cPanel >> Home >> Security >> Manage API Tokens).
  2. Click Create. The Create API Token interface will appear.
  3. Enter a name in the API Token Name text box.

    Note:

    • An API token name can only contain up to 50 characters.
    • You can only enter letters (a – z) and (A – Z), numbers (0 – 9), dashes ( - ), and underscores ( _ ).
    • You must enter a name that does not already exist on the account.
  4. 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.

      Important:

      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.

  5. Click Yes, I Saved My Token.

    Note:

    • 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

Remember:

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:

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.

example.com

Note:

Alternatively, you can enter your server's IP address.

Module

The API module name.

Email
function

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

Additional documentation