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
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/api_token_create?api.version=1&token_name=subway
 Command Line
whmapi1 api_token_create token_name=subway 

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",
	  "last_used":"null"
   },
   "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>
	<last_used>
</data>

Note:

Use WHM's API Shell interface (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

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_timestringThe API token's creation time.

A date, in Unix time format.

1483625276
last_usedstringThe most recent time at which a user logged in to WHM or called an API function with this API token.This value always returns null.null