How to add subdomain to account under a reseller through API2

devel

Member
Sep 21, 2013
5
0
1
cPanel Access Level
Reseller Owner
Hello all.

I have a master reseller account under which customer accounts are registered. I would like to add addon domains to these customer accounts using a cpanel instance authenticated with the master reseller account.

This is trivially done using the web interface. However, when I try to do it using the cpanel sdk/api2, I can only add the addon domain to the reseller account itself, not its sub-accounts.

I'm using PHP. Here's the relevant code-snippet adding the addon domain. I understand that the api call used doesn't have the "user" parameter which I was lead to believe it had, and that this is the reason the domain is added to the reseller:

Code:
...
$cpCfg = array(
    'cpanel'=>array(
        'service'=>array(
            'cpanel' => array(
                'host' => $ip,
                'user' => $rusr,
                'password' => $rpw,
            )   
        )   
    )   
);

$cp = Cpanel_PublicAPI::getInstance($cpCfg);
$queryMF = array(
    'module' => 'AddonDomain',
    'function' => 'addaddondomain',
);
$queryArgs = array(
    'user' => $usr,
    'dir' => $domain,
    'newdomain' => $domain,
    'subdomain' => $domain
);
$response = $cp->cpanel_api2_request('cpanel', $queryMF, $queryArgs);
...
So, the question is, how can I have this effect the sub-account (here contained in $usr) instead of the reseller accounts?
I have searched wide and far already, but I have yet to find something that actually solves the problem.

Any help or tips will be greatly appreciated. Thank you!

Regards,
devel
 

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,607
76
308
cPanel Access Level
Root Administrator
Are you using the user's name, or the resellers name, when performing the login?
 

devel

Member
Sep 21, 2013
5
0
1
cPanel Access Level
Reseller Owner
Hi Kenneth. Thanks for your reply.

I'm using the reseller's username and password when logging in. The problem is that I don't have the passwords of the accounts under the reseller at hand--otherwise I would have used those directly.
 

devel

Member
Sep 21, 2013
5
0
1
cPanel Access Level
Reseller Owner
Bumping this thread after almost two weeks. Hope that's not disallowed. Unfortunately I still haven't been able to find a working solution. Any help will be appreciated, thanks!
 

devel

Member
Sep 21, 2013
5
0
1
cPanel Access Level
Reseller Owner
Hi cPAndrewHodge. Thank you for the tip, it worked!. I would never have attempted that on my own, and I am very surprised that it is implemented like so.

I would mark the thread title with [SOLVED], but it seems I cannot change it myself.