Comprehensive Guide to WHM API 1 Functions in cPanel Print

  • 0


๐ŸŽฏ 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.


ย 


Was this answer helpful?

« Back