How to Upgrade or Downgrade a Hosting Package via the Command Line (CLI)

  Uncategorized

Introduction

cPanel & WHM provides the whmapi1 command-line utility, which enables administrators to manage cPanel accounts directly from the server terminal. Using the changepackage API command, you can upgrade or downgrade a cPanel account by assigning it to a different hosting package without accessing the WHM web interface. This method is particularly useful for server administrators who prefer command-line management or need to automate account modifications.

Prerequisites

Before you begin, ensure that:

  • You have root SSH access to the cPanel & WHM server.
  • The target cPanel account already exists.
  • The hosting package you want to assign has already been created in WHM.
  • The server is running cPanel & WHM.
  • You know the exact name of the hosting package to be assigned.

IMPLEMENTATION

Step 1: Connect to the Server

Log in to the server via SSH as the root user:

ssh root@your-server-ip

Step 2: Verify Available Packages

 whmapi1 listpkgs | grep "name:"

Review the output and note the exact package name that you want to assign to the cPanel account.

Step 3: Check the Current Hosting Package

To view the hosting package currently assigned to a cPanel account, run:

whmapi1 accountsummary user=example | grep "plan:"

Replace example with the actual cPanel username.

Step 4: Upgrade or Downgrade the Hosting Package

To assign a different hosting package to the account, run:

whmapi1 changepackage user=example pkg=PACKAGE_NAME

Replace:

  • username with the cPanel username.
  • PACKAGE_NAME with the name of the desired hosting package.

Example: Upgrade the Package

whmapi1 changepackage user=example pkg=high-package

Example: Downgrade the Package

whmapi1 changepackage user=example pkg=Low-package

If the command is successful, WHM will return a confirmation indicating that the hosting package has been updated.

Step 5: Verify the Package Assignment

To confirm that the package has been successfully updated, run:

whmapi1 accountsummary user=username

Verify that the plan field in the output displays the newly assigned hosting package.

Conclusion

Upgrading or downgrading a hosting package using the whmapi1 command-line utility is a quick and efficient way to manage cPanel accounts without using the WHM web interface. This approach is especially beneficial for administrators who automate server management tasks or manage multiple accounts through scripts. After changing the package, always verify the account details to ensure the correct hosting plan has been applied successfully.

LEAVE A COMMENT