generate API tokens for resellers in cPanel

This blog represents the steps to Generating API tokens for resellers in WHM/CPANEL.

Overview:

The API token is part of a new set of defaults that every reseller has access to. Newly created Resellers should have these default privileges.  API tokens allow you to log in to your server without the need for a password. You can use an API token to authenticate with WHM’s remote API. If you use a remote billing solution, you will need to set up an API token on all of your cPanel & WHM servers.

Requirements:

The following steps guide you to get the API token in WHM:

  1. Please enter the Manage API Tokens location from the below path:  Home »Development »Manage API Tokens
  2. Click the (+ Generate token ) option in the Manage API Tokens.
  3. Provide the token name under the Manage API Tokens.
  4. After selecting the privileges please hit the save button.
  5. Now you will get the below output with the token.
    You successfully created the API token “test”.Copy the following token to a safe place: XXXXXXXXXXXXXXXX
  6. Click: Yes, I saved my token button.
  7. That’s it from the WHM part.

WHMCS PROCESS:

  • We need to add a server for the Cpanel product to be assigned to the WHMCS.
  • Please go to the below location. Setup > Products/Services  > servers > Add a new server
  • Provide the server details to connect the server.
  • Add the generated token in the corresponding field in the WHMCS Add a new server.
  • Tick the SSL mode checkbox.
  • Complete the add new server filed processes.

Please follow the below steps to activate the API token for a particular user from the command line:

When updating, Cpanel attempts to add these default privileges to old resellers but we have seen some cases where this doesn’t happen so we ran it manually for a particular user.

~]#/scripts/fix_reseller_acls –add-default-privs –reseller=username

The output should be:
~~~
[*] Processing reseller: ‘username’….
[*] Adding default privileges to ‘username’…
[*] Added default privileges to ‘username’…
[+]Proccessed reseller: ‘username’
~~~

And now we should able to access the API token interface while using the reseller. If you would like to add this to all resellers you can use the ‘–all-resellers’ flag when logged in as the ROOT user:

~~~
#/scripts/fix_reseller_acls –add-default-privs –all-resellers
~~~