SOLVED Create FTP account via API 2 and associate it to a subdomain

liviuhariton

Member
Jul 4, 2017
8
1
3
Tulcea, Romania
cPanel Access Level
Root Administrator
Hello everyone,

I have an issue with the API 2 and I can't find a solution. The scenario is:
  • I create a new subdomain sub.domain.com - everything is okay here (I'm using SubDomain::addsubdomain)
  • I try to create a new FTP account by using Ftp::addftp but the username will be [email protected] but I want it to be [email protected]
How can I achieve this (the documentation does not give me any clues on this)

Thank you in advance!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
  • Like
Reactions: liviuhariton

liviuhariton

Member
Jul 4, 2017
8
1
3
Tulcea, Romania
cPanel Access Level
Root Administrator
Hello,

You can use the "domain" parameter with this API function. EX:

Code:
cpapi2 --user=$cpanel-user Ftp addftp user=$ftp-user domain=$subdomain.domain.tld pass=$luggage1234567
I've opened an internal case (DOC-9176) with our Documentation Team to ensure this information is reflected on the following document:

cPanel API 2 Functions - Ftp::addftp - Software Development Kit - cPanel Documentation

Thank you.
Awesome, thank you! With the new parameter the username is now created as I wanted.

BUT, there is a new problem: when I try to login with the newly created credentials the authentication fails with "530 Login authentication failed". Even if I update the password of the FTP account via cPanel interface, the login still fails...

By using the API2, I have created the following FTP account:
When I try to connect, via FTP, to sub.domain.com (with the above credentials), the authentication fails...
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
When I try to connect, via FTP, to sub.domain.com (with the above credentials), the authentication fails...
Are you sure the subdomain resolves to the cPanel server? Also, are you including the "@domain.tld" suffix in the username? Do you notice any specific error messages in /var/log/messages when authentication fails?

Thank you.
 

cPanelMichael

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

liviuhariton

Member
Jul 4, 2017
8
1
3
Tulcea, Romania
cPanel Access Level
Root Administrator
Yes, indeed, I've added the domain and it's working just fine. Thanks!

As for your question: I'm building a custom interface that allows me to create subdomains, email accounts, ftp users, mysql databases and mysql users (associated to the database) on the fly and I did not manage to find a PHP wrapper built for UAPI.

I found one for API2 instead (this one github.com/pguso/cpanel-api/blob/master/src/Hostkit/Common/Api/Cpanel.php)... If you know a PHP wrapper for UAPI that does the same thing, please let me know about it as I don't have any preferences for what API to use as long as I obtain what I need...
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
I'm glad to see adding the domain parameter helped. I've also added a note to the Documentation case to ensure the parameter is reflected on the corresponding cPanel API 2 document for the delete FTP account function.

I found one for API2 instead (this one cpanel-api/Cpanel.php at master · pguso/cpanel-api · GitHub)... If you know a PHP wrapper for UAPI that does the same thing, please let me know about it as I don't have any preferences for what API to use as long as I obtain what I need...
In the example, you see a entry like this for cPanel API 2:

Code:
&cpanel_jsonapi_apiversion=2
For UAPI, it's "apiversion=3". So you'd simply adjust the value and make changes to the function names if necessary.

Thank you.
 

cPanelMichael

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

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,261
463
Hello,

There's currently no time frame for the availability of a corresponding UAPI function. I encourage you to submit a feature request for the addition of a UAPI function to manage subdomains:

Submit A Feature Request

Thank you.