๐ฏ Simplify Server Management with WHM API 1
WHM API 1 is a robust suite of functions designed to simplify server administration and cPanel account management. This guide provides a detailed overview of commonly used functions, categorized for easy navigation and formatted with vibrant styling for better readability. ๐
๐ WHM API 1 Overview
๐ก WHM API 1 is a versatile and powerful API toolset designed to provide administrators with full control over cPanel accounts and server management. This API enables automation, simplifies repetitive tasks, and enhances efficiency by allowing granular control over server operations. With WHM API 1, you can:
โ Streamline workflows
๐ Automate tasks
๐จ Create customized solutions tailored to your hosting needs.
๐ Secure and scalable management is within your reach with this powerful toolset.
๐ ๏ธ Getting Started with WHM API 1
๐ฅ๏ธ Accessing WHM API 1
WHM API 1 functions can be accessed in three main ways:
โ๏ธ Command Line Interface (CLI)
๐ Execute API commands directly from your server terminal.
Example:
whmapi1 createacct username=myuser domain=mydomain.com password=mypassword
๐ HTTP Requests
๐ก Interact with WHM API 1 remotely using curl
or Postman.
Example:
curl -H "Authorization: cpanel root:<api_token>" \
https://your-server:2087/json-api/createacct?username=myuser&domain=mydomain.com&password=mypassword
๐ Programming Scripts
๐ป Use languages like Python, PHP, or Bash to integrate WHM API 1 into your applications.
๐ Authentication
To use WHM API 1, secure authentication is required:
๐ API Tokens
๐ Generate and use API tokens for secure and restricted access.
Example header:
Authorization: cpanel root:API_TOKEN
๐ Access Hash
Authenticate with an access hash for script-based requests.
Example:
curl -H "Authorization: WHM root:<access_hash>" \
https://your-server:2087/json-api/function
๐ WHM API 1 Key Functions
1. Account Management
๐ ๏ธ Common Tasks
-
โ Create Account
Command:whmapi1 createacct username=username domain=example.com password=password
-
๐๏ธ Remove Account
Command:whmapi1 removeacct user=username
-
โ Suspend Account
Command:whmapi1 suspendacct user=username reason='Reason for suspension'
-
โ Unsuspend Account
Command:whmapi1 unsuspendacct user=username
2. Email Management
๐ง Managing Email Accounts
-
โ Suspend Outgoing Email
Command:whmapi1 suspend_outgoing_email user=cpanelusername
-
โ Unsuspend Outgoing Email
Command:whmapi1 unsuspend_outgoing_email user=cpanelusername
-
๐ List Email Accounts
Command:whmapi1 list_pops user=cpanelusername
-
โ๏ธ Create Email Account
Command:whmapi1 addpop email=email@domain.com password=password quota=quota user=cpanelusername
-
๐๏ธ Delete Email Account
Command:whmapi1 delpop email=email@domain.com user=cpanelusername
3. DNS Management
๐ Configuring DNS Zones
-
โ Add DNS Zone
Command:whmapi1 adddns user=cpanelusername domain=example.com
-
โ๏ธ Edit DNS Zone
Command:whmapi1 editzonerecord zone=example.com line=1 address=1.2.3.4
-
๐๏ธ Remove DNS Zone
Command:whmapi1 killdns domain=example.com
4. Package Management
๐ฆ Managing Hosting Packages
-
โ Create Package
Command:whmapi1 addpkg name=package_name quota=quota bandwidth=bandwidth maxsql=maxsql
-
๐๏ธ Delete Package
Command:whmapi1 killpkg name=package_name
5. SSL Management
๐ Securing Your Domains
-
๐ ๏ธ Install SSL Certificate
Command:whmapi1 installssl domain=example.com crt='certificate_content' key='private_key_content' cabundle='ca_bundle_content'
-
๐๏ธ Delete SSL Certificate
Command:whmapi1 deletessl domain=example.com
6. Backup Management
๐พ Creating and Restoring Backups
-
๐ ๏ธ Create Backup
Command:whmapi1 createrepo user=username
-
โป๏ธ Restore Backup
Command:whmapi1 restorepkg user=username
7. Server Information
๐ Gathering Server Data
-
๐ Get Server Information
Command:whmapi1 gethostname
-
๐ Get Server Load
Command:whmapi1 loadavg
8. User Management
๐ค Modifying User Accounts
-
๐ Change User Password
Command:whmapi1 passwd user=username password=newpassword
-
๐ Modify User Quota
Command:whmapi1 editquota user=username quota=newquota
9. Additional Useful Functions
โ๏ธ Miscellaneous Tasks
-
๐ List Accounts
Command:whmapi1 listaccts
-
๐๏ธ Terminate Account
Command:whmapi1 terminateacct user=username
-
โ Suspend Reseller Account
Command:whmapi1 suspendreseller user=username
-
โ Unsuspend Reseller Account
Command:whmapi1 unsuspendreseller user=username
10. Security Management
๐จ Managing IP Blocklists
-
Add IP to Blocklist:
whmapi1 add_blacklist_ip ip=1.2.3.4 comment="Blocked due to malicious activity"
-
Remove IP from Blocklist:
whmapi1 remove_blacklist_ip ip=1.2.3.4
-
List Blocked IPs:
whmapi1 list_blacklist_ips
๐ Managing API Tokens
-
Create API Token:
whmapi1 api_token_create name=my_token acl-list=full
-
Delete API Token:
whmapi1 api_token_destroy token_id=123456
-
List API Tokens:
whmapi1 api_token_list
11. Advanced DNS Management
๐ง Managing Zone Files
-
List DNS Zones:
whmapi1 listzones
-
Export Zone File:
whmapi1 getzonerecords zone=example.com
-
Import Zone File:
whmapi1 importzone user=username domain=example.com zonefile='/path/to/zonefile'
12. PHP Configuration
โ๏ธ Managing PHP Settings
-
Change PHP Version for an Account:
whmapi1 modifyacct user=username plan=myhostingpackage phpversion=ea-php80
-
List Available PHP Versions:
whmapi1 listphpversions
-
Set PHP INI Directive:
whmapi1 php_ini_set_directive directive=memory_limit value=512M user=username
13. Service Management
๐ก Monitoring and Managing Services
-
Restart a Service:
whmapi1 restartservice service=apache
-
List Active Services:
whmapi1 servicestatus
-
Check Service Status:
whmapi1 status
14. Two-Factor Authentication (2FA)
๐ Enhancing Account Security
-
Enable 2FA for an Account:
whmapi1 twofactorauth_set_status user=username enabled=1
-
Disable 2FA for an Account:
whmapi1 twofactorauth_set_status user=username enabled=0
-
Check 2FA Status for an Account:
whmapi1 twofactorauth_get_status user=username
15. Reseller Account Management
๐ค Managing Resellers
-
Create Reseller Account:
whmapi1 setresellerlimits user=username reseller=1
-
Set Reseller Limits:
whmapi1 setresellerlimits user=username maxftpaccounts=10 maxsql=50
-
Terminate Reseller Account:
whmapi1 removeacct user=username
16. File and Directory Management
๐ Handling Files and Directories
-
Create a Directory:
whmapi1 createdir dir=/home/username/public_html/newdirectory
-
Delete a File:
whmapi1 deletefile path=/home/username/public_html/oldfile.html
-
List Files in a Directory:
whmapi1 listfiles dir=/home/username/public_html
17. Bandwidth Management
๐ Monitoring and Managing Bandwidth
-
View Bandwidth Usage for an Account:
whmapi1 showbw user=username
-
Reset Bandwidth Limit for an Account:
whmapi1 resetbw user=username
18. Log Management
๐ Viewing and Clearing Logs
-
View cPanel Error Log:
whmapi1 get_error_log
-
Clear cPanel Access Logs:
whmapi1 clear_log logtype=access
19. WHM Customization
๐จ Customizing WHM Features
-
Set WHM Theme:
whmapi1 settheme theme=paper_lantern
-
Change WHM Language:
whmapi1 setlang lang=en
20. Database Management
๐ Managing Databases
-
Create MySQL Database:
whmapi1 createdb dbname=username_dbname user=username
-
Delete MySQL Database:
whmapi1 removedb dbname=username_dbname
-
List MySQL Databases:
whmapi1 listdbs user=username
-
Change MySQL User Password:
whmapi1 setdbpassword user=username db_user=dbusername password=newpassword
Conclusion
WHM API 1 empowers server administrators with a comprehensive toolset to efficiently manage cPanel accounts and server configurations. From account creation to backup management, mastering these commands simplifies operations and ensures smooth server performance.
For more details, refer to the official WHM API 1 documentation. For personalized assistance, explore our Knowledge Base or submit a support ticket.
๐ก Pro Tip: Automate repetitive tasks using scripts or cron jobs to save time and reduce errors.
ย