Manage cPanel hosting accounts via API (version 134.0.11 compatible).
bash
# Using API token (recommended)
export CPANEL_HOST="https://your-server.com:2087"
export CPANEL_TOKEN="your-api-token"
# Test connection
exec command="curl -s -H 'Authorization: whm $CPANEL_TOKEN' '$CPANEL_HOST/json-api/version' | jq ."
List Accounts:
bash
exec command="curl -s -H 'Authorization: whm $CPANEL_TOKEN' '$CPANEL_HOST/json-api/listaccts?api.version=1' | jq ."
Create Email Account:
bash
exec command="curl -s -H 'Authorization: cpanel $CPANEL_TOKEN' '$CPANEL_HOST/execute/Email/add_pop?email=user&password=secure123&domain=example.com' | jq ."
APIPurposeEndpoint PrefixWHM APIServer admin, account management/json-api/UAPIcPanel user operations/execute/cPanel API 2Legacy (deprecated)/json-api/cpanel2
Authorization: whm <token> (WHM) or Authorization: cpanel <token> (UAPI)bash
curl -u 'username:password' 'https://server:2087/json-api/...'
Create Account:
bash
exec command='curl -s -H "Authorization: whm $CPANEL_TOKEN" "$CPANEL_HOST/json-api/createacct?api.version=1&username=newuser&domain=newdomain.com&password=secure123&plan=default" | jq .'
Suspend/Unsuspend:
bash
# Suspend
exec command='curl -s -H "Authorization: whm $CPANEL_TOKEN" "$CPANEL_HOST/json-api/suspendacct?api.version=1&user=username&reason=non-payment" | jq .'
# Unsuspend
exec command='curl -s -H "Authorization: whm $CPANEL_TOKEN" "$CPANEL_HOST/json-api/unsuspendacct?api.version=1&user=username" | jq .'
Terminate Account:
bash
exec command='curl -s -H "Authorization: whm $CPANEL_TOKEN" "$CPANEL_HOST/json-api/removeacct?api.version=1&user=username" | jq .'
List DNS Zones:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/DNS/zone_records?domain=example.com" | jq .'
Add DNS Record:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/DNS/add_zone_record?domain=example.com&name=www&type=A&address=192.168.1.1&ttl=3600" | jq .'
List Email Accounts:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/Email/list_pops?domain=example.com" | jq .'
Create Email Account:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/Email/add_pop?email=newuser&password=secure123&domain=example.com"a=250" | jq .'
Set Email Forwarder:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/Email/add_forwarder?domain=example.com&email=user&fwdopt=fwd&fwdemail=dest@example.org" | jq .'
Create MySQL Database:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/Mysql/create_database?name=mydb" | jq .'
Create MySQL User:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/Mysql/create_user?name=myuser&password=secure123" | jq .'
Grant Privileges:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/Mysql/set_privileges_on_database?user=myuser&database=mydb&privileges=ALL%20PRIVILEGES" | jq .'
List SSL Certificates:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/SSL/list_certs" | jq .'
Install Let's Encrypt:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/SSL/install_ssl?domain=example.com&cert=$(cat cert.pem | jq -sR .)&key=$(cat key.pem | jq -sR .)" | jq .'
List Files:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/Fileman/list_files?dir=public_html" | jq .'
Upload File:
bash
exec command='curl -s -H "Authorization: cpanel $CPANEL_TOKEN" "$CPANEL_HOST/execute/Fileman/upload_files?dir=public_html&file-1=@localfile.txt" | jq .'
Create Account Backup:
bash
exec command='curl -s -H "Authorization: whm $CPANEL_TOKEN" "$CPANEL_HOST/json-api/backupacct?api.version=1&user=username" | jq .'
Restore Account:
bash
exec command='curl -s -H "Authorization: whm $CPANEL_TOKEN" "$CPANEL_HOST/json-api/restoreacct?api.version=1&user=username" | jq .'
The skill includes helper scripts:
scripts/cpanel_api.sh - Generic API caller with error handlingscripts/create_account.sh - Create hosting accountscripts/manage_dns.sh - DNS zone managementscripts/manage_email.sh - Email account operationsscripts/manage_database.sh - MySQL/PostgreSQL operationsscripts/backup_account.sh - Backup/restore operationsExecute scripts using exec tool:
bash
exec command="bash ~/.picoclaw/workspace-default/skills/dxyz-cpanel/scripts/cpanel_api.sh listaccts"
Load reference files using read_file tool when needed:
bash
CPANEL_HOST="https://your-server.com:2087" # WHM port
CPANEL_TOKEN="your-api-token" # API token
CPANEL_USER="root" # WHM username
Create ~/.cpanel/config.json:
json
{
"host": "https://your-server.com:2087",
"token": "your-api-token",
"default_plan": "default",
"default_quota": 1000,
"default_bwlimit": 10000
}
This skill supports:
metadata.result for statusapi.version=1 for consistent responsesErrorCauseSolutionAccess deniedInvalid token/permissionsRegenerate token, check ACLAccount existsDuplicate usernameUse different usernameInvalid domainDomain format/syntaxCheck DNS, use FQDNQuota exceededDisk limit reachedIncrease quota or cleanup