Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function deletes a cPanel or WHM account.

Warning:

You cannot recover deleted accounts. 

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/removeacct?user=username
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/removeacct?user=username
 Command Line
whmapi0 removeacct user=username

Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 0 documentation or run the whmapi0 --help command. 
  • We introduced this functionality in cPanel & WHM version 11.52.0.8.

 Output (JSON)
{  
   "result":[  
      {  
         "statusmsg":"username account removed",
         "rawout":"Running pre removal script (/usr/local/cpanel/scripts/prekillacct)......Done\nCollecting Domain Name and IP...User: username\nDomain: example.com\n...Done\nLocking account and setting shell to nologin...Locking password for user username.\npasswd: Success\n...Done\nKilling all processes owned by user......Done\nRemoving Sessions.........Done\nRemoving Suspended Info.........Done\nRemoving Web Logs......Done\nRemoving Bandwidth Files......Done\nRemoving Email Sending Limits Cache......Done\nRemoving DKIM keys......Done\nRemoving Crontab......Done\nRemoving HTTP Virtual Hosts...Removed the following non-SSL virtual hosts: example.com\nRemoved the following SSL virtual hosts: \n...Done\nRemoving ftp Virtual Hosts......Done\nRemoving user's web content directory symlinks......Done\nRemoving MySQL databases and users...Listing MySQL dbs for removal....Fetching MySQL DB Owner information....Revoking MySQL Privs.......Done\nRemoving MySQL horde data......Done\nRemoving PostgreSQL databases and users......Done\nRemoving User & Group.......Success...Done\nRemoving DNS Entries...example.com => deleted from user. \n...Done\nRemoving Email Setup...Removing /etc/valiases/example.com\n...Done\nRemoving mailman lists......Done\nUpdating Databases......Done\nRemoving bandwidth limits......Done\nRemoving Counter Data......Done\nAdding IP back to the IP address pool...System has 0 free ips.\n...Done\nRemoving user's cPanel Databases & Updating......Done\nReloading Services......Done\nRemoving mail and service configs...\n...Done\nSending Contacts......Done\nUpdating internal databases...Updating FTP passwords for username\nPurging ftp user username\nFTP password files updated.\nFTP vhost passwords synced\n...Done\nRunning post removal scripts (/usr/local/cpanel/scripts/legacypostkillacct, /usr/local/cpanel/scripts/postkillacct)......Done\nAccount Removal Complete!!!...username account removed...Done\n",
         "status":1
      }
   ]
}
 Output (XML)
<removeacct>
   <result>
      <rawout>
         Running pre removal script (/usr/local/cpanel/scripts/prekillacct)......Done Collecting Domain Name and IP...User: username Domain: example.com ...Done Locking account and setting shell to nologin...Locking password for user username. passwd: Success ...Done Killing all processes owned by user......Done Removing Sessions.........Done Removing Suspended Info.........Done Removing Web Logs......Done Removing Bandwidth Files......Done Removing Email Sending Limits Cache......Done Removing DKIM keys......Done Removing Crontab......Done Removing HTTP Virtual Hosts...Removed the following non-SSL virtual hosts: example.com Removed the following SSL virtual hosts: ...Done Removing ftp Virtual Hosts......Done Removing user's web content directory symlinks......Done Removing MySQL databases and users...Listing MySQL dbs for removal....Fetching MySQL DB Owner information....Revoking MySQL Privs.......Done Removing MySQL horde data......Done Removing PostgreSQL databases and users......Done Removing User & Group.......Success...Done Removing DNS Entries...example.com => deleted from user. ...Done Removing Email Setup...Removing /etc/valiases/example.com ...Done Removing mailman lists......Done Updating Databases......Done Removing bandwidth limits......Done Removing Counter Data......Done Adding IP back to the IP address pool...System has 0 free ips. ...Done Removing user's cPanel Databases & Updating......Done Reloading Services......Done Removing mail and service configs... ...Done Sending Contacts......Done Updating internal databases...Updating FTP passwords for username Purging ftp user username FTP password files updated. FTP vhost passwords synced ...Done Running post removal scripts (/usr/local/cpanel/scripts/legacypostkillacct, /usr/local/cpanel/scripts/postkillacct)......Done Account Removal Complete!!!...username account removed...Done
      </rawout>
      <status>1</status>
      <statusmsg>username account removed</statusmsg>
   </result>
</removeacct>

Parameters

ParameterTypeDescriptionPossible valuesExample
userstring

Required

The account's username.

The username of a cPanel account on the server.

username
keepdnsBoolean

Whether to retain the account's DNS entries.

This parameter defaults to 0.

  • 1 — Retain DNS entries.
  • 0 — Delete DNS entries.
0

Returns

ReturnTypeDescriptionPossible valuesExample
resultarray of hashesAn array of hashes of function information.This hash includes the status, statusmsg, and rawout returns. 

status

Boolean

Whether the system successfully called the function.

The function returns this value in the result hash.

  • 1 — Success.
  • 0 — Failure.

 

1

statusmsg

string

A message of success or a reason for failure.

The function returns this value in the result hash.

  • A success message.
  • An error message.

username account removed

rawout

string

The function's output messages.

The function returns this value in the result hash.

One or more output strings.
 Click to view...
Running pre removal script (/usr/local/cpanel/scripts/prekillacct)......Done\nCollecting Domain Name and IP...User: username\nDomain: example.com\n...Done\nLocking account and setting shell to nologin...Locking password for user username.\npasswd: Success\n...Done\nKilling all processes owned by user......Done\nRemoving Sessions.........Done\nRemoving Suspended Info.........Done\nRemoving Web Logs......Done\nRemoving Bandwidth Files......Done\nRemoving Email Sending Limits Cache......Done\nRemoving DKIM keys......Done\nRemoving Crontab......Done\nRemoving HTTP Virtual Hosts...Removed the following non-SSL virtual hosts: example.com\nRemoved the following SSL virtual hosts: \n...Done\nRemoving ftp Virtual Hosts......Done\nRemoving user's web content directory symlinks......Done\nRemoving MySQL databases and users...Listing MySQL dbs for removal....Fetching MySQL DB Owner information....Revoking MySQL Privs.......Done\nRemoving MySQL horde data......Done\nRemoving PostgreSQL databases and users......Done\nRemoving User & Group.......Success...Done\nRemoving DNS Entries...example.com => deleted from user. \n...Done\nRemoving Email Setup...Removing /etc/valiases/example.com\n...Done\nRemoving mailman lists......Done\nUpdating Databases......Done\nRemoving bandwidth limits......Done\nRemoving Counter Data......Done\nAdding IP back to the IP address pool...System has 0 free ips.\n...Done\nRemoving user's cPanel Databases & Updating......Done\nReloading Services......Done\nRemoving mail and service configs...\n...Done\n...Done\nSending Contacts......Done\nUpdating internal databases...Updating FTP passwords for username\nPurging ftp user username\nFTP password files updated.\nFTP vhost passwords synced\n...Done\nRunning post removal scripts (/usr/local/cpanel/scripts/legacypostkillacct, /usr/local/cpanel/scripts/postkillacct)......Done\nAccount Removal Complete!!!...username account removed...Done\n