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

Description

This function creates an API token. You can use API tokens instead of a password or access hash key to execute WHM API 1 functions over HTTPS. For more information about API tokens, read our Manage API Tokens documentation.

Important:

You must call this function over an SSL connection.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/api_token_create?api.version=1&name=subway&acl-1=kill-acct&acl-2=list-acct
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/api_token_create?api.version=1&token_name=subway&acl-1=killacct&acl-2=list-acct
 Command Line
whmapi1 api_token_create token_name=subway acl-1=kill-acct acl-2=list-acct

Notes:

  • 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. 
  • We introduced this functionality in cPanel & WHM version 11.52.0.8.

 Output (JSON)
{  
   "data":{  
      "name":"subway",
      "token":"UWU28DCA23NKY76CN17MDPKM3O7EFQY8",
      "create_time":"1483625276",
	  "acls":[
		 "kill-acct",
		 "list-acct"
		],
   },
   "metadata":{  
      "reason":"OK",
      "command":"api_token_create",
      "version":1,
      "result":1
   }
}
 Output (XML)
<result>
<metadata>
	<reason>OK</reason>
	<result>1</result>
	<command>api_token_create</command>
	<version>1</version>
</metadata>
<data>
	<name>subway</token_name>
	<token>UWU28DCA23NKY76CN17MDPKM3O7EFQY8</token>
	<create_time>1483625276</create_time>
	<acls>kill-acct</acls>
	<acls>list-acct</acls>
</data>

Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
token_name
string

Required

The API token's name.

Notes:

  • An API token name’s maximum length is 50 characters and the name may only contain alphanumeric characters, dashes ( - ), and underscores ( _ ).
  • You must assign a name that does not already exist to the API token.
A valid string.subway
acl-*string

The privileges to assign to the token.

Note:

  • To assign multiple privileges to the token, increment the parameter name. For example: acl-1, acl-2acl-3.
  • You can only assign privileges that you possess to the API token.
  • We added this parameter in cPanel & WHM version 68.

If you do not use this parameter, the system will assign all of your privileges to the token.

A valid privilege that the user possesses.

 Click to view a list of privileges...
  • acct-summary
  • add-pkg
  • add-pkg-ip
  • add-pkg-shell
  • allow-addoncreate
  • allow-emaillimits-pkgs
  • allow-parkedcreate
  • allow-unlimited-bw-pkgs
  • allow-unlimited-disk-pkgs
  • allow-shell
  • basic-system-info
  • basic-whm-functions
  • clustering
  • cors-proxy-get
  • cpanel-api
  • cpanel-integration
  • create-acct
  • create-dns
  • create-user-session
  • demo-setup
  • digest-auth
  • edit-account
  • edit-dns
  • edit-mx
  • edit-pkg
  • generate-email-config
  • limit-bandwidth
  • list-acct
  • list-pkgs
  • locale-edit
  • mailcheck
  • manage-api-tokens
  • manage-dns-records
  • manage-oidc
  • manage-styles
  • mysql-info
  • news
  • ns-config
  • park-dns
  • passwd
  • quota
  • rearrange-accts
  • resftp
  • restart
  • show-bandwidth
  • ssl
  • ssl-buy
  • ssl-gencert
  • ssl-info
  • track-email
  • thirdparty
  • upgrade-account
  • viewglobalpackages
  • all
kill-acct

Returns

ReturnTypeDescriptionPossible valuesExample
namestring

The new API token's name.

Note:

Use this value to revoke an API token with WHM API 1's api_token_revoke function.

A valid token name. subway

token

 

 

string

The new API token to use to authenticate to WHM.

Warning:

Make certain that you save your API token in a safe location. You cannot access the token again after you use this function.

A valid API token.
 Click to view...
UWU28DCA23NKY76CN17MDPKM3O7EFQY8
create_timeintegerThe API token's creation time.

A date, in Unix time format.

1483625276
last_usedstring

The most recent time at which a user logged in to WHM or called an API function with this API token.

Note:

We removed this return in cPanel & WHM version 66.

This value always returns null.null
aclsarray

An array of privileges assigned to the token.

Note:

We added this return in cPanel & WHM version 68.

An array of valid privileges.kill-acct