Changing a cPanel Account Package via WHM API

  Uncategorized

Introduction

In WHM/cPanel, each hosting account is assigned a package that defines its resource limits (such as disk space, bandwidth, number of domains, etc.).
There are cases where you may need to change the package of an existing account (e.g., upgrading from a starter plan to a higher plan).

This document outlines the procedure to switch a cPanel account to a different package using the WHM API and verify the changes.

Prerequisites

Before proceeding, ensure the following:

  1. Root/SSH Access
    You must have SSH access to the WHM server with root privileges.
  2. WHM API Availability
    The server should have WHM API (whmapi1) installed and accessible. This is usually available by default on cPanel/WHM servers.
  3. Target Package Exists
    The package you want to assign (e.g., L-Starter) must already be created in WHM under PackagesAdd a Package.
  4. Username of the cPanel Account
    You must know the exact cPanel account username to be updated.

Steps to Change the Package

Step 1: Run the WHM API command

Use the following command to change the package of the user:

$ whmapi1 --output=jsonpretty changepackage user='<username>' pkg='L-Starter'
  • Replace <username> with the actual cPanel username.
  • Replace L-Starter with the desired package name.
  • The --output=jsonpretty option displays the response in a structured format for better readability.

If successful, you should see a JSON output indicating the package update.

Step 2: Verify the Package Assignment

Run the following command to confirm that the package was updated:

$ grep ^PLAN /var/cpanel/users/<username>

Expected output (example):

PLAN=L-Starter

This confirms that the user is now assigned to the L-Starter package.

Conclusion

By using the WHM API (whmapi1) command, you can efficiently change the package of any cPanel account without manually navigating through the WHM interface.
Verification via the /var/cpanel/users/<username> file ensures that the changes have been applied correctly.

This method is especially useful for administrators who manage multiple accounts and want to automate package changes via scripts or provisioning workflows.

LEAVE A COMMENT