{"id":362,"date":"2021-07-23T12:28:30","date_gmt":"2021-07-23T12:28:30","guid":{"rendered":"https:\/\/ssdsunucum.com\/blog\/how-to-use-cpanel-api-tokens\/"},"modified":"2021-07-23T12:28:30","modified_gmt":"2021-07-23T12:28:30","slug":"how-to-use-cpanel-api-tokens","status":"publish","type":"post","link":"https:\/\/ssdsunucum.com\/blog\/how-to-use-cpanel-api-tokens\/","title":{"rendered":"How to Use cPanel API Tokens"},"content":{"rendered":"<\/p>\n<div class=\"col-md-9\">\n<div class=\"flex-column flex-md-row article-header\"><\/div>\n<hr>\n<h2 id=\"overview\">Overview<\/h2>\n<p>In cPanel &#038; WHM version 80, we introduced cPanel application programming interface (API) tokens. cPanel users can issue these API tokens. The server recognizes API tokens and allows other users to run API functions with the account\u2019s data. API functions allow you to view and change account data without the need to log in to the cPanel interface. For example, you could issue an API token to a third-party developer. That third-party developer could use that token to check disk usage.<\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>API tokens run UAPI functions and cPanel API 2 functions, <strong>not<\/strong> cPanel API 1 functions. For more information, read our Quickstart Development Guide documentation.<\/li>\n<li>If you do <strong>not<\/strong> see this feature, your system administrator has disabled it. Contact them and ask them to enable this feature in WHM\u2019s <em>Feature Manager<\/em> interface (<em>WHM &gt;&gt; Home &gt;&gt; Package &gt;&gt; Feature Manager<\/em>).<\/li>\n<\/ul><\/div>\n<\/div>\n<h2 id=\"how-to-use-a-cpanel-api-token\">How to use a cPanel API token<\/h2>\n<p>To use a cPanel API token, first, create a cPanel API token in cPanel\u2019s <em>Manage API Tokens<\/em> interface (<em>cPanel<\/em> &gt;&gt; <em>Home<\/em> &gt;&gt; <em>Security<\/em> &gt;&gt; <em>Manage API Tokens<\/em>). Then, use the token to run API functions on the server.<\/p>\n<h3 id=\"create-an-api-token\">Create an API token<\/h3>\n<p>You can use one of the following methods to create an API token:<\/p>\n<ul>\n<li>\n<p>Use cPanel\u2019s <em>Manage API Tokens<\/em> interface (<em>cPanel<\/em> &gt;&gt; <em>Home<\/em> &gt;&gt; <em>Security<\/em> &gt;&gt; <em>Manage API Tokens<\/em>).<\/p>\n<\/li>\n<li>\n<p>Use the UAPI <code>Tokens::create_full_access<\/code> function.<\/p>\n<\/li>\n<\/ul>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n<ul>\n<li>In cPanel &#038; WHM version 82, when an API token expires, the system does <strong>not<\/strong> remove it. You <strong>must<\/strong> manually delete an API token.<\/li>\n<li>You can remove an API token with cPanel\u2019s <em>Manage API Tokens<\/em> interface (<em>cPanel &gt;&gt; Home &gt;&gt; Security &gt;&gt; Manage API Tokens<\/em>) or the UAPI <code>Tokens::revoke<\/code> function.<\/li>\n<\/ul><\/div>\n<\/div>\n<h3 id=\"run-api-functions-with-the-token\">Run API functions with the token<\/h3>\n<div class=\"callout callout-success\">\n<div class=\"callout-heading\">Remember:<\/div>\n<div class=\"callout-content\">\n<p>You <strong>must<\/strong> use the API token that you created in cPanel.<\/p>\n<\/p><\/div>\n<\/div>\n<p>To call a <code>UAPI<\/code> or <code>cPanel API 2<\/code> function with an API token, run the following command from the command line:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-GO\" data-lang=\"GO\"><span style=\"color:#a6e22e\">curl<\/span> <span style=\"color:#f92672\">-<\/span><span style=\"color:#a6e22e\">H<\/span><span style=\"color:#960050;background-color:#1e0010\">'<\/span><span style=\"color:#a6e22e\">Authorization<\/span>: <span style=\"color:#a6e22e\">cpanel<\/span> <span style=\"color:#a6e22e\">username<\/span>:<span style=\"color:#a6e22e\">APITOKEN<\/span><span style=\"color:#e6db74\">' '<\/span><span style=\"color:#a6e22e\">https<\/span>:<span style=\"color:#f92672\">\/\/<\/span><span style=\"color:#a6e22e\">example<\/span>.<span style=\"color:#a6e22e\">com<\/span>:<span style=\"color:#ae81ff\">2083<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">execute<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">Module<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">function<\/span><span style=\"color:#960050;background-color:#1e0010\">?<\/span><span style=\"color:#a6e22e\">parameter<\/span>=<span style=\"color:#a6e22e\">value<\/span><span style=\"color:#960050;background-color:#1e0010\">'<\/span><\/code><\/pre>\n<\/div>\n<p>This example uses the following format:<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"left\">Item<\/th>\n<th align=\"left\">Description<\/th>\n<th align=\"left\">Example<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"left\"><code>username<\/code><\/td>\n<td align=\"left\">The cPanel account\u2019s username.<\/td>\n<td align=\"left\"><code>username<\/code><\/td>\n<\/tr>\n<tr>\n<td align=\"left\"><code>APITOKEN<\/code><\/td>\n<td align=\"left\">The API token.<\/td>\n<td align=\"left\"><code>U7HMR63FGY292DQZ4H5BFH16JLYMO01M<\/code><\/td>\n<\/tr>\n<tr>\n<td align=\"left\"><code>example.com<\/code><\/td>\n<td align=\"left\">Your cPanel server\u2019s domain.<\/td>\n<td align=\"left\"><code>example.com<\/code> <\/p>\n<div class=\"callout callout-info\">\n<div class=\"callout-heading\">Note:<\/div>\n<div class=\"callout-content\">\n        Alternatively, you can enter your server\u2019s IP address.\n    <\/div>\n<\/div>\n<\/td>\n<\/tr>\n<tr>\n<td align=\"left\"><code>Module<\/code><\/td>\n<td align=\"left\">The API module name.<\/td>\n<td align=\"left\"><code>Email<\/code><\/td>\n<\/tr>\n<tr>\n<td align=\"left\"><code>function<\/code><\/td>\n<td align=\"left\">The API function\u2019s name.<\/td>\n<td align=\"left\"><code>add_pop<\/code><\/td>\n<\/tr>\n<tr>\n<td align=\"left\"><code>parameter<\/code><\/td>\n<td align=\"left\">The function\u2019s input parameters.<\/td>\n<td align=\"left\"><code>email<\/code><\/td>\n<\/tr>\n<tr>\n<td align=\"left\"><code>value<\/code><\/td>\n<td align=\"left\">The value to assign to the input parameter.<\/td>\n<td align=\"left\"><code>12345luggage<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>For example, your command may resemble the following example:<\/p>\n<div class=\"highlight\">\n<pre style=\"color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-GO\" data-lang=\"GO\"><span style=\"color:#a6e22e\">curl<\/span> <span style=\"color:#f92672\">-<\/span><span style=\"color:#a6e22e\">H<\/span><span style=\"color:#960050;background-color:#1e0010\">'<\/span><span style=\"color:#a6e22e\">Authorization<\/span>: <span style=\"color:#a6e22e\">cpanel<\/span> <span style=\"color:#a6e22e\">username<\/span>:<span style=\"color:#a6e22e\">U7HMR63FHY282DQZ4H5BIH16JLYSO01M<\/span><span style=\"color:#e6db74\">' '<\/span><span style=\"color:#a6e22e\">https<\/span>:<span style=\"color:#f92672\">\/\/<\/span><span style=\"color:#a6e22e\">example<\/span>.<span style=\"color:#a6e22e\">com<\/span>:<span style=\"color:#ae81ff\">2083<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">execute<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">Email<\/span><span style=\"color:#f92672\">\/<\/span><span style=\"color:#a6e22e\">add_pop<\/span><span style=\"color:#960050;background-color:#1e0010\">?<\/span><span style=\"color:#a6e22e\">email<\/span>=<span style=\"color:#a6e22e\">newuser<\/span><span style=\"color:#f92672\">&<\/span><span style=\"color:#a6e22e\">password<\/span>=<span style=\"color:#ae81ff\">12345<\/span><span style=\"color:#a6e22e\">luggage<\/span><span style=\"color:#960050;background-color:#1e0010\">'<\/span><\/code><\/pre>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview In cPanel &#038; WHM version 80, we introduced cPanel application programming interface (API) tokens. cPanel users can issue these API tokens. The server recognizes API tokens and allows other users to run API functions with the account\u2019s data. API functions allow you to view and change account data without the need to log in &hellip;<\/p>\n","protected":false},"author":1,"featured_media":363,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/362"}],"collection":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/comments?post=362"}],"version-history":[{"count":0,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/posts\/362\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media\/363"}],"wp:attachment":[{"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/media?parent=362"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/categories?post=362"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ssdsunucum.com\/blog\/wp-json\/wp\/v2\/tags?post=362"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}