I don't know in the API, but I can give you the steps to do it manually on the backend.
Code:
cd /var/cpanel/users
cp username username.bak
vi username
In that file, remove the DNS lines for the addon and sub domains. If you are using vi, you can do 1000dd and remove 1000 lines at a time. Having made a backup of the file before editing it ensures that, if you make a mistake, everything will be restorable.
After you've removed the domains you want out of the file, you can reload the userdomains to wipe out those domains:
Code:
/scripts/updateuserdomains
Next, you need to remove the entries for Apache in the /var/cpanel/userdata/username folder:
Code:
cd /var/cpanel/userdata/username
cp main main.bak
vi main
In that file, you can remove all of the addon and subdomains you want to be gone, then save the file. Again, there's a backup being made if there were any issues.
You'd also want to move the subdomain.domain.com files out of that folder. It is probably easiest to just make a copy of the folder and copy the main file and the main domain and any other domains you still want into the new folder, then make that new folder the one you are using.
After you've made those changes, you'd simply need to rebuild Apache:
Code:
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak100713
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
While the above might seem complicated, it's a lot faster than removing each of those addons one by one in cPanel for that many domains.
One more area you might want to remove are the DNS zones. Those are in /var/named/ location with addondomain.com.db as the name for each addon domain name. Those are a lot more difficult to remove. If you aren't wanting to re-add these domains anywhere, you could just leave the DNS zones there. Otherwise, I really don't suggest removing zones manually. You'd want to go into the WHM interface and delete the domains in Delete DNS Zone area (you can delete multiple zones at once there by selecting all the domains to remove by highlighting each one).
I apologize that I don't know a way in the API to do this for you. I considered answering this yesterday, but I wasn't sure if you'd want this type of method to do it. If not, that's understandable of course. I only am replying so you get some sort of response on at least one other way to do it other than using cPanel.