Skip to content

whmapi1, uapi, cpapi2 — when to use which cPanel API, and why it still matters

cPanel ships three API surfaces, each with a different scope and a different call convention. A short guide to which one you should reach for, by task.

Scripts written against cPanel APIs accrete over years. A junior engineer copies an example from one decade, an intermediate engineer extends it with a call from a different decade, and the result is a script that mixes whmapi1, uapi, and cpapi2 calls — sometimes for the same logical operation. Each API works, each has different defaults, and the mixed-API script breaks in surprising ways when cPanel deprecates one of the older surfaces. Knowing which API to reach for is operational hygiene.

What’s happening

cPanel has three live API surfaces today. whmapi1 is the WHM-scoped API: server-wide operations like creating accounts, managing packages, running transfers. It’s called as root, returns JSON, and is the canonical surface for server admin work. uapi is the cPanel-scoped API: per-account operations like creating email accounts, adding databases, managing FTP. It’s called as the cPanel user (or proxied from root), returns JSON, and is the modern replacement for cpapi2. cpapi2 is the legacy cPanel-scoped API: still present, still functional for most calls, but cPanel has been deprecating individual modules for years. New scripts should not use it; existing scripts should migrate when the module gets a deprecation warning.

How to verify

For any operation you’re about to script, check which API has the canonical call:

whmapi1 --output=jsonpretty | head -20
whmapi1 list_users --output=jsonpretty | jq -r '.data.users[]' | head -3
uapi --user=acme Email list_pops --output=jsonpretty
cpapi2 --user=acme Email listpopswithdisk
ls /usr/local/cpanel/Cpanel/API/ | head -20

The Cpanel/API/ directory shows which uapi modules are available. The WHM/ directory shows whmapi1 modules. If a module exists in both Cpanel/API/ and Cpanel/Api2/, prefer the uapi version — cpapi2 is in legacy mode.

The fix

The decision tree, by task:

  1. Server-wide account ops (create, modify, suspend, terminate, change package): whmapi1. There’s no uapi equivalent for these.
  2. Per-account ops as the customer (mail accounts, databases, FTP, DNS records on owned domains): uapi. Faster, returns better error messages, will be supported indefinitely.
  3. Per-account ops as root (for automation): whmapi1 --user=acme for the few endpoints that support it, otherwise uapi --user=acme invoked as root which proxies as the user.
  4. Anything in cpapi2: migrate when you have to, leave alone when it works. The deprecation notes in /usr/local/cpanel/docs/ list which modules are next on the chopping block.
  5. Mixed scripts: rewrite them when you touch them. A single script using both cpapi2 and uapi will surprise you the day cPanel deprecates the cpapi2 module you depend on.

For shops with a script library that’s accreted over years, Stack Harbor’s cPanel server management practice audits API usage and migrates calls in batches so deprecation announcements don’t become incidents.