Child pages
  • UAPI Functions - Tokens::list
Skip to end of metadata
Go to start of metadata

Description

This function returns a list of a cPanel account's API tokens.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Tokens/list?user=username


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Get a list of the cPanel account's API tokens.
$variable = $cpanel->uapi(
    'Tokens', 'list'
);


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Get a list of the cPanel account's API tokens.
my $variable = $cpliveapi->uapi(
    'Tokens', 'list'
);


Note:

For more information, read our Guide to the LiveAPI System.

 Command Line
uapi --user=username Tokens list


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
   "result":{
      "messages":null,
      "metadata":{
         "transformed":1
      },
      "status":1,
      "warnings":null,
      "data":[
         {
            "features":[
               "mysql"
            ],
            "create_time":1549471343,
			"expires_at": 1609372800,
            "has_full_access":0,
            "name":"example2"
         },
         {
            "features":[
               "autossl",
               "popaccts"
            ],
            "create_time":1549471330,
            "expires_at":~
            "has_full_access":0,
            "name":"example1"
         },
         {
            "features":[

            ],
            "create_time":1549471289,
            "expires_at":1609372800,
            "has_full_access":1,
            "name":"example"
         },
         {
            "name":"example3",
            "has_full_access":0,
            "create_time":1549460846,
            "expires_at":~
            "features":[
               "addondomains",
               "parkeddomains",
               "subdomains"
            ]
         }
      ],
      "errors":null
   }
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

This function does not accept parameters.

Returns

ReturnTypeDescriptionPossible valuesExample
dataarray of hashesA hash of data for the API tokens on the account.Each hash contains the create_time, expires_at, features, has_full_access, and name returns.

create_time

integer

The API token's creation date and time.

This function returns this value in the unnamed hash.

A valid timestamp, in Unix Epoch format.

1549471343

expires_at

integer

The API token's expiration time. If the API token does not expire, the function returns a null value.

This function returns this value in the unnamed hash.

Note:

We added this return in cPanel & WHM version 82.

  • A valid timestamp, in Unix Epoch format.
  • A null value.
1609372800

features

array of strings

The account features that the API token has access to.

This function returns this value in the unnamed hash.

  • An array of cPanel features.
  • An empty array, if the API token has full access.

mysql

has_full_access

Boolean

Whether the API token has full access to the account's features.

This function returns this value in the unnamed hash.

  • 1 — The API token has full access to the account's features.
  • 0 — The API token does not have full access to the account's features.
0

name

string

The API token's name.

This function returns this value in the unnamed hash.

A valid API token name.example2