Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Terminate Account — removeacct

This function permanently removes a cPanel account.

PICK Remember: Once an account has been deleted, it cannot be recovered.

Calling Functions

Using the XML API

To use the XML API to perform the removeacct function from within your custom script:

  • Append the /xml-api/removeacct function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/removeacct

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the removeacct function from within your custom script:

  • Append the /json-api/removeacct function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/removeacct

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The removeacct function takes the following variables as input.

The following variable is required:

  • user (string) — User name to terminate.

The following variable is optional:

  • keepdns (boolean) — Whether to keep DNS entries for the domain.
    • 1 — yes.
    • 0 — no. (This is the default value.)

Output

  • removeacct — Root-level XML tag for the output of the removeacct function.
    • result — Container for the results of the operation.
      • rawout (in HTML format) — Raw output of the removal operation.
      • status (boolean) — Status of the operation.
        • 1 — success.
        • 0 — failure.
      • statusmsg (string) mdash; Message about the status of the operation.

Examples

XML API

Calling https://example.com:2087/xml-api/removeacct?user=user123 in WebHost Manager will produce something similar to:

<removeacct>
    <result>
        <rawout> 
         Running pre removal script (/scripts/prekillacct)......Done
         Collecting Domain Name and IP...User: user123
         Domain: example.com...Done
         Killing all processes owned by user......Done
         Cleaning passwd,shadow,group......Done
         Removing User from Group..........Done
         Removing Web Logs......Done
         Removing Bandwidth Files......Done
         Removing Crontab......Done
         Removing Virtual Hosts...Removed Extra Entries from httpd.conf...Done
         Removing MySQL databases and users......Done
         Removing PostgreSQL databases and users......Done
         Removing System User......Done
         Removing Group......Done
         Removing DNS Entries...example.com => deleted from server. ...Done
         Removing Email Setup...
         Removing /etc/valiases/example.com...Done
         Removing mailman lists......Done
         Removing remotedomains,secondarymx,localdomains entries......Done
         Removing Counter Data......Done
         Adding ip back to the ip address pool...System has 2 free ips....Done
         Removing user's cPanel Databases and Updating......Done
         Reloading Services......Done
         Removing mail and service configs......Done
         Sending Contacts......Done
         Updating internal databases...Updating ftp passwords for user123
         Purging ftp user user123
         Ftp password files updated.
         Ftp vhost passwords synced...Done
         Running post removal scripts (/scripts/legacypostkillacct, 
         /scripts/postkillacct)......Done
         Account Removal Complete!!!...user123 account removed...Done
        </rawout> 
        <status>1</status>
        <statusmsg>user123 account removed</statusmsg>
    </result>
</removeacct>

JSON API

Show Hide

Calling https://example.com:2087/json-api/removeacct?user=user123 in WebHost Manager will produce something similar to:

{
   "result":[
      {
         "status":1,
         "statusmsg":"user123 account removed",
         "rawout":"Running pre removal script (/scripts/prekillacct)......DoneCollecting 
Domain Name and IP...User: user123\nDomain: example.com\n...DoneKilling all processes 
owned by user......DoneCleaning passwd,shadow,group......DoneRemoving 
User from Group..........DoneRemoving Web Logs......DoneRemoving Bandwidth Files......
DoneRemoving Crontab......DoneRemoving Virtual Hosts...Removed Extra Entries 
from httpd.conf\nexample.com not found in httpd.conf.\nRemoved Entry from 
proftpd.conf\n...DoneRemoving MySQL databases and users......DoneRemoving 
PostgreSQL databases and users......DoneRemoving System User......DoneRemoving 
Group......DoneRemoving DNS Entries...example.com => deleted from server. 
\n...DoneRemoving Email Setup...Removing /etc/valiases/example.com\n...DoneRemoving 
mailman lists......DoneRemoving remotedomains,secondarymx,localdomains 
entries......DoneRemoving Counter Data......DoneAdding ip back to the ip address 
pool...System has 0 free ips.\n...DoneRemoving user's cPanel Databases & 
Updating......DoneReloading Services......DoneRemoving mail and service 
configs...\n...DoneSending Contacts......DoneUpdating internal databases...Updating ftp 
passwords for user123\nPurging ftp user user123\nFtp password files updated.\nFtp vhost 
passwords synced\n...DoneRunning post removal scripts (/scripts/legacypostkillacct, 
/scripts/postkillacct)......DoneAccount Removal Complete!!!...user123 account 
removed...Done"
      }
   ]
}

Topic revision: r8 - 23 Aug 2013 - 21:02:30 - Main.LaurenceSimon