How To Create An Addon Domain using the API?

clickwhale

Registered
Apr 25, 2016
1
0
51
Mumbai
cPanel Access Level
Root Administrator
Hi,

We are creating an in-house software that needs to use the Cpanel api to create addon domains on our own server.

Yes we have root access.

The current UAPI does not seem to have an equivalent function.

Using the cpanel api2 shows that it's deprecated (meaning removed soon?)

So is this very important function no longer available now?

Thanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463

cPanelKeithS

Active Member
Staff member
Oct 14, 2008
33
2
133
On the backend, an add-on domain is technically a subdomain of the main cpanel user's domain with another domain parked on top of it.

First, Create the subdomain - sub.cpanelusersdomain.com

Then, Create an Alias (park) pointing to the subdomain - parkedontopofsub.com

The add-on domain's http files can be uploaded to the subdomain's directory - /home/cpaneluser/www/sub.cpanelusersdomain.com
 
  • Like
Reactions: cPRex

tullnet

Registered
Jul 9, 2004
2
1
153
Hi

I am trying to use the api to park a domain (I have a reseller account).

I can successfully add a subdomain using:
$apiUrl = "https://<hostname>:2083/execute/SubDomain/addsubdomain?domain=$domain&rootdomain=$rootdomain&dir=$dir";

and I can use the whm api to, for example, access an accounts summary:
$apiUrl = "https://<hostname>:2087/json-api/accountsummary?api.version=1&user=udl";

But I cannot get the park domain to work:
$apiUrl = "https://<hostname>:2087/json-api/create_parked_domain_for_user?api.version=1&domain=$domain&username=$username&web_vhost_domain=$subdomain";

I get a permission error. Permission denied: You do not have the required privileges to run “create_parked_domain_for_user”.

Is this only available to root, is it a specific permission my provider need to activate, or is there something I'm missing?

Thanks
 

tullnet

Registered
Jul 9, 2004
2
1
153
As far as I can tell, that API call is only available to the root user.
Thanks. Looks like I will have to keep doing it manually then until I can justify getting my own server with root access. :(
(It's a shame, because I've managed to automate every other step I needed)
 
  • Like
Reactions: cPRex