Building new cpanel account via API

leonep

Well-Known Member
Nov 18, 2014
163
8
68
Pescara
cPanel Access Level
Root Administrator
Hi,
I am building a web site for manage my hosts. I have my registred users on my own database (mySql) . I have usernames and passwords stored.

Now i want to use API for create new users in cPanel from php .
(/json-api/createacct?username=user&domain=example.com&plan=package_name&featurelist=default&quota=0&password=12345luggage&ip=n&cgi=1&hasshell=1&[email protected]&cpmod=x3&maxftp=5&maxsql=5&maxpop=10&maxlst=5&maxsub=1&maxpark=1&maxaddon=1&bwlimit=500&language=en&useregns=1&hasuseregns=1&reseller=0&forcedns=1&mxcheck=local&MAX_EMAIL_PER_HOUR=500&MAX_DEFER_FAIL_PERCENTAGE=80)

I don't know the correct way to do this , because i have hash passwords in DB and i know it is impossible to reverse.

Probably it's easy but i need help

Thanks you very much
 

anton_latvia

Well-Known Member
PartnerNOC
May 11, 2004
401
13
168
Latvia
cPanel Access Level
Root Administrator
You can't reverse mysql passwords.
If you want to create new accounts on WHM server, all you need is Remote Access Key of the server. I suggest that you look through API - somewhere there were links to ready-php classes, that are great help with various functions, not just account creation.

With RemoteAccessKey you basically can do a lot of things, as you access your server as root.
 

leonep

Well-Known Member
Nov 18, 2014
163
8
68
Pescara
cPanel Access Level
Root Administrator
thanks for reply

registration.php on my website --> users choose their own password --> verify if choosed password strenght is good for my cpanel setting (required strenght 60)--> store password and user details on my db --> purchase a service --> creation account in cpanel

i have problem in the last phase i want to create account with password choosed by customers !
well i can register accounts in cpanel after registration.php because i have password in session but i don't want this i want only after purchase.
thank you
 
Last edited:

anton_latvia

Well-Known Member
PartnerNOC
May 11, 2004
401
13
168
Latvia
cPanel Access Level
Root Administrator
I am using this API to make function call more simple:
cPanel::PublicAPI - search.cpan.org

Take a look there, there are some examples, including account creation. Let me know, if you can't make it work.
 

anton_latvia

Well-Known Member
PartnerNOC
May 11, 2004
401
13
168
Latvia
cPanel Access Level
Root Administrator
in order to create account you need to have either root or reseller password or server remote-access key. May be I don't understand, what you are trying to do.. when you create account - you can set any password you want, but i guess it can not be encrypted, since account creation script will encrypt it..
 

leonep

Well-Known Member
Nov 18, 2014
163
8
68
Pescara
cPanel Access Level
Root Administrator
I got a registration page on my website where users choose their own passwords. For security reasons i store in my database the hash of these passwords. After the purchase of services i want to create accounts using api but i have only the hash...

may be i can random generate password but i must send to customers and is not good to send passwords throught email .I also like to have same password for my customers accounts on website and cpanel customers accounts

sorry if i was not clear ! thank you very much for your patience
 

anton_latvia

Well-Known Member
PartnerNOC
May 11, 2004
401
13
168
Latvia
cPanel Access Level
Root Administrator
well, that's what I thought, in fact.. ;) well, either you store plain-text password for limited period of time (say 1 hour, so customer can complete registration) or encrypt it with some de-cryptable algorithm. May be option is to store plain text-pw in a separate field or separate database, also for short period of time. I personally don't see other way, sorry.