A cPanel API token is a long code that lets a script or application call the cPanel API without your password. You create it from cPanel > Security > Manage API Tokens, give it an expiration date and send it in the header Authorization: cpanel user:token. It gives access to the whole hosting account, which is why Konet has two rules: delete every token you don't use and never give it to an AI tool.
What an API token does and when I need one
With the token a program calls the functions of UAPI and cPanel API 2, that is, whatever you do from the cPanel screens: email, autoresponders, DNS records, databases, disk usage. The old cPanel API 1 does not work with tokens. The official cPanel API documentation is at api.docs.cpanel.net.
Real uses:
- Turning an autoresponder on and off on a schedule, e.g. every weekend.
- Automatic Let's Encrypt certificate issuance with DNS-01 for a server outside the hosting, which writes the TXT record in your zone.
- A monitoring tool that reads disk usage or email accounts.
- Connecting your developer's application to the hosting.
When you don't need one:
- For an autoresponder during a specific period, such as a holiday, the Start and Stop fields of cPanel Autoresponders are enough.
- For a partner who needs access to part of the account, create a user with roles in Manage Team or an FTP account limited to a specific folder.
What access a token gives
A token you create from cPanel has full access. It can do whatever your plan allows, from creating email accounts to deleting a database. The interface does not let you restrict it to specific functions. Whoever has the token does not need the cPanel password. That is why you protect it like the password, and even more.
Only the owner of the cPanel account creates, views and revokes tokens. Manage Team users have no access to this tool.
How do I create an API token
- Log in to cPanel and open Security > Manage API Tokens.
- Click Create.
- In API Token Name enter a name that says where it will be used, e.g.
autoresponder-cron. Up to 50 characters, with letters, numbers, dashes and underscores. - In Should the API Token Expire? select Specify an expiration date and pick the nearest date that works for you. The default is one year. Do not select The API Token will not expire.
- Click Create.
- Click Copy and store the token somewhere safe, e.g. in a password manager.
- Click Yes, I Saved My Token.
The token is shown once. If you leave the page without copying it, you will not see it again. You revoke it and create a new one. You cannot change the expiration date later, and the token expires at 23:59:59 server time on the day you set.
If you don't see Manage API Tokens in the Security section, open a ticket from the Client Area.
How do I call cPanel UAPI with the token
Every call sends the header Authorization: cpanel USERNAME:TOKEN to the address https://example.gr:2083/execute/Module/function, where Module is the group of functions (e.g. Email) and function is the function. The username is the cPanel one, not an email address.
Example 1, list email accounts
From the computer or server that runs the automation:
curl -s -H "Authorization: cpanel exampleuser:TOKEN" \
"https://example.gr:2083/execute/Email/list_pops"
The response is JSON. status 1 means success, 0 means failure with a description in errors:
{"apiversion":3,"func":"list_pops","module":"Email",
"result":{"status":1,"errors":null,
"data":[{"email":"info@example.gr","login":"info@example.gr",
"suspended_incoming":0,"suspended_login":0}]}}
In your scripts always check status, not only that a response arrived.
Example 2, scheduled autoresponder
Turning on an autoresponder for info@example.gr. start and stop are times in Unix timestamp format and interval is the hours between two replies to the same sender:
curl -s -G -H "Authorization: cpanel exampleuser:TOKEN" \
"https://example.gr:2083/execute/Email/add_auto_responder" \
--data-urlencode "email=info" \
--data-urlencode "domain=example.gr" \
--data-urlencode "from=Example" \
--data-urlencode "subject=We are closed" \
--data-urlencode "body=We will reply on Monday." \
--data-urlencode "is_html=0" \
--data-urlencode "charset=UTF-8" \
--data-urlencode "interval=24" \
--data-urlencode "start=$(date +%s)" \
--data-urlencode "stop=$(date -d 'next monday 08:00' +%s)"
Turning it off:
curl -s -G -H "Authorization: cpanel exampleuser:TOKEN" \
"https://example.gr:2083/execute/Email/delete_auto_responder" \
--data-urlencode "email=info@example.gr"
You put the two commands in a scheduled task (cron) on the machine that runs them. If you schedule them from cPanel Cron Jobs, at Konet the minimum interval is 10 minutes.
Where do I keep the token
- In a file or environment variable that only the script's user can read, not inside the code.
- Never inside
public_html, in a Git repository, in a shared document or in notes. - Never as a parameter in the URL, because URLs are written to logs. Always in the
Authorizationheader. - Never in an email, chat or ticket. Konet never asks you for your token.
Konet's two rules for API tokens
- Delete any token you don't use. If an automation stopped or the developer finished the job, revoke the token right away. When you need it again, you create a new one in a minute.
- Do not give the token to AI tools. Do not paste it into a chatbot or coding assistant, or into a file such a tool reads. Whatever goes in there often ends up public later. If you ask for help with a script, replace the token with the word
TOKEN.
With these two rules, and with an expiration date, an API token is a safe and very good option for automation.
Expiration, renewal and revocation
In the Manage API Tokens list you see Token Name, Created and Expires. The row turns yellow when the token is close to expiring and red when it has expired. An expired token is not deleted by itself. There is no renewal. You create a new one, put it in your scripts and revoke the old one.
To revoke, click Manage next to the token, then Revoke and Yes, Revoke the Token. For several at once, tick the rows, click Revoke and Revoke Selected API Tokens. After revocation every script using the token stops working immediately.
I see a token I didn't create, what do I do
A token you don't recognize, or a cPanel email that an API token was created when you did not create one, is a sign that someone has access to your account. cPanel may send such a notification to the email you have in Contact Information, so keep an address there that you read.
- Revoke immediately all tokens you don't recognize.
- Change your cPanel password. The token is a separate credential, so you need both steps.
- Turn on Two-Factor Authentication.
- Open a ticket so we can check the account.
Frequently Asked Questions
Why don't I see Manage API Tokens in my cPanel?
Either you logged in as a Manage Team user, who has no access, or the tool is not active on the plan. Log in as the owner, and if it does not appear, open a ticket.
Can I restrict a token to email only or DNS only?
Not from cPanel. The token has access to the whole account. For limited access use Manage Team or an FTP account.
I lost the token, can I see it again?
No. Revoke it and create a new one.
What is the difference from a WHM API token?
A WHM API token is created by the reseller owner from WHM and concerns managing many accounts. There it can be limited to specific privileges. A cPanel API token concerns only your own cPanel account.
If I change the cPanel password, do the tokens stop?
Do not take it for granted. If you want to cut off a token's access, revoke it from Manage API Tokens.
Is it safe to give a token to my developer?
Only with an expiration date, for a specific job, and you revoke it when it is done. For ongoing work prefer a Manage Team user.