You can find our user documentation at docs.cpanel.net.

Check out our new API beta site!

Child pages
  • WHM API 1 Functions - api_token_list
Skip to end of metadata
Go to start of metadata

Description

This function lists a WHM account's API tokens.

Examples


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/api_token_list?api.version=1
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/api_token_list?api.version=1
 Command Line
whmapi1 api_token_list --user=username


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
	"metadata": {
		"command": "api_token_list",
		"reason": "OK",
		"result": 1,
		"version": 1
	},
	"data": {
		"tokens": {
			"example": {
				"acls": {
					"upgrade-account": 0,
					"create-acct": 0,
					"edit-account": 0,
					"limit-bandwidth": 0,
					"suspend-acct": 0,
					"list-accts": 0
				},
				"name": "example",
				"create_time": 1500503835,
				"expires_at": 1609372800
			}
		}
	}
}
 Output (XML)
<result>
	<metadata>
		<result>1</result>
		<command>api_token_list</command>
		<reason>OK</reason>
		<version>1</version>
	</metadata>
	<data>
		<tokens>
			<example>
				<create_time>1483625276</create_time>
				<expires_at>1609372800</expires_at>
					<acls>
						<kill-acct>0</kill-acct>
						<list-acct>0</list-acct>
						<upgrade-acct>0</upgrade-acct>
						<create-acct>0</create-acct>
						<edit-acct>0</edit-acct>
						<limit-bandwidth>0</limit-bandwidth>
					</acls>
				<name>example</name>
			</example>
		</tokens>
	</data>
</result> 


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
--userstring

A reseller's username.

Note:

  • You can only use this parameter on the command line.
  • If you use this parameter, the function will return that reseller account's API tokens.
  • If you do not use this parameter, the function only returns the root account's API tokens.
  • We added this parameter in cPanel & WHM version 68.
A valid reseller's username.username

Returns

ReturnTypeDescriptionPossible valuesExample
tokens hash

A hash of the WHM account's API token names.

Note:

In cPanel & WHM version 66 and earlier, this value returns an array of hashes of API token data.

This hash contains the token-name return.

Note:

In cPanel & WHM version 66 and earlier, this hash contains the name, create_time, and last_used returns.


token-name

hash

A hash of API token details.

Note:

  • This return's name is the API token's name.
  • We added this return in cPanel & WHM version 68.
This hash contains the acls, name, create_time and expires_at returns.

acls

hash

A hash of privileges available to the user.

The function returns this value in the token-name hash.

Note:

We added this return in cPanel & WHM version 68.

This hash includes the acl-name return.


acl-name

Boolean

Whether the Access Control List (ACL) is enabled.

The function returns this value in the acls hash.

Note:

  • We added this return in cPanel & WHM version 68.
  • The return's name is the ACL's name.
  • 1 — Enabled.
  • 0 — Disabled.
1

name

string

The API token's name.

The function returns this value in the token-name hash.

A valid API token name.example

create_time

integer

The API token's creation time.

The function returns this value in the token-name hash.

A valid timestamp, in Unix Epoch format.

1483625276

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 token-name hash.

Note:

We added this return in cPanel & WHM version 82.

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