首页 > 代码库 > WHM API 1 - createacct

WHM API 1 - createacct

WHM API 1 - createacct

 
 
Skip to end of metadata
 
Go to start of metadata
 

 

  • Overview
  • Parameters
  • Examples

 

Overview

This page contains the input variables, output variables, and examples in JSON and XML output formats for the createacct function.

The createacct function creates a hosting account and sets up its associated domain information.

 

Note

Icon
For help on how to use this function, read the tutorial page on how to call WHM API 1 Functions.

 

Parameters

InputTypeDescription
usernamestring

The username for the account that you wish to create (for example, username).

Note

Icon
Usernames must be eight characters or less, or, as of cPanel & WHM version 11.40, 16 characters or less if database prefixes are disabled. Also, usernames cannot start with a number, or the string test.
domainstringThe domain name to assign to the account (for example, example.com).
planstringThe package that you wish to apply to the new account (for example, reseller_gold).
pkgnamestringThe name of a new package to be created based on the settings used (for example, reseller_new).
savepkgbooleanThis value determines whether to save the settings as a new package. A value of 1 will save the settings as a new package.
featureliststringThe name of the feature list to be used when you create a new package (for example, no_ftp_100mb_gold).
quotaintegerThe disk space quota, in megabytes. Allowed values are: a number from 0 to 999999 where a value of 0 is unlimited.
passwordstringThe password that you wish to assign to the new account (for example, p@ss!w0rd$123).
ipstringThis value determines whether the domain has a dedicated IP address. A value of y will flag the domain for a dedicated IP address.
cgibooleanThis value determines whether the domain has CGI access. A value of 1 grants the domain CGI access.
frontpageboolean

This value determines whether the domain can install FrontPage extensions. A value of 1 allows FrontPage extensions to be installed.

Note:

Icon

cPanel & WHM will ignore all Microsoft® FrontPage® settings and parameters if either of the following statements are true:

  • Your server runs cPanel & WHM version 11.44 and FrontPage extensions are not installed on your server.
  • Your server runs cPanel & WHM version 11.46 or later.
dkim (optional)boolean

This value determines whether the domain has DKIM enabled. A value of 1 enables DKIM.

Note:

Icon

This parameter does not follow the Enable DKIM on domains for newly created accounts setting in WHM‘sTweak Settings interface (Home >> System Configuration >> Tweak Settings). If you wish to enable DKIM on this newly-created domain, set this parameter to a value of 1.

spf (optional)boolean

This value determines whether the domain has SPF enabled. A value of 1 enables SPF.

Note:

Icon

This parameter does not follow the Enable SPF on domains for newly created accounts setting in WHM‘s Tweak Settings interface (Home >> System Configuration >> Tweak Settings). If you wish to enable SPF on this newly-created domain, set this parameter to a value of 1.

hasshellbooleanThis value determines whether the domain has shell (SSH) access. A value of 1 grants shell access to the domain.
contactemailstringContact email address for the account (for example, user@example.com).
cpmodstring

The name of the cPanel theme that is assigned to the domain (for example: x3).

Note

Icon
If no value is provided, the function will use the cPanel default theme (set in WHM in the Basic cPanel & WHM Setup interface). This behavior only applies to version 11.36+.
maxftpstringThe maximum number of FTP accounts that the user can create. Allowed values are: a number from 0 to 999999 where a value of 0 is unlimited, unlimited, and null.
maxsqlstringThe maximum number of SQL databases that the user can create. Allowed values are: a number from 0 to 999999 where a value of 0 is unlimited, unlimited, and null.
maxpopstringThe maximum number of email accounts that the user can create. Allowed values are: a number from 0 to 999999 where a value of 0 is unlimited, unlimited, and null.
maxlststringThe maximum number of mailing lists that the user can create. Allowed values are: a number from 0 to 999999 where a value of 0 is unlimited, unlimited, and null.
maxsubstringThe maximum number of subdomains that the user can create. Allowed values are: a number from 0 to 999999 where a value of 0 is unlimited, unlimited, and null.
maxparkstringThe maximum number of parked domains that the user can create. Allowed values are: a number from 0 to 999999where a value of 0 is unlimited, unlimited, and null.
maxaddonstringThe maximum number of addon domains that the user can create. Allowed values are: a number from 0 to 999999 where a value of 0 is unlimited, unlimited, and null.
bwlimitstringThe bandwidth limit, in megabytes. This value must be a number from 0 to 999999, where a value of 0 is unlimited.
customipstringThis value specifies an IP address for the site.
languagestringThe language that you wish for the new account to use in the cPanel interface (for example, spanish-utf8).
useregnsbooleanThis value determines whether the domain will use the registered nameservers for the domain instead of the ones configured on the server. A value of 1 will use the registered nameservers for the domain.
hasuseregnsbooleanIf you set useregns to 1, you must set this value to 1.
resellerbooleanThis value determines whether you wish to grant reseller privileges to the account. A value of 1 will grant reseller privileges to the account.
forcednsbooleanThis value will overwrite an existing DNS Zone with this new account‘s information if one already exists. A value of 1 will overwrite an existing DNS zone with this new account‘s information.
mxcheckstring

Determines how the server will handle incoming mail for this domain. This variable can be set to one of the following:
local — The domain will accept mail, regardless of whether a higher-priority mail exchanger has been designated on the WHM Edit MX Entry interface. (If a higher-priority mail exchanger exists, mail will be routed to both domains.)
secondary (or backup) — The domain will act as a backup mail exchanger, and it will hold mail in queue if the primary exchanger becomes unavailable.

Note

Icon
You will still need to use the WHM Edit MX Entry interface to configure the primary MX entry to point to the appropriate exchanger.


remote — The domain will not accept mail, instead sending it to the primary mail exchanger. Note: You will still need to use the WHM Edit MX Entry interface to configure the primary MX entry to point to the appropriate exchanger.
auto — The server will automatically detect, and use, the configuration set on the WHM Edit MX Entry interface.

 MAX_EMAIL_PER_HOURinteger

The maximum number of emails the account can send in an hour. This parameter‘s default value is unlimited. A value of0 will result in an unlimited value.

Note

Icon
This variable is only accepted in cPanel & WHM Version 11.32 and later.
 MAX_DEFER_FAIL_PERCENTAGEinteger

The percentage of failed or deferred email messages the account can send per hour before outgoing mail is rate-limited. This parameter‘s default value is unlimited.

Note

Icon
This variable is only accepted in cPanel & WHM Version 11.32 and later.
 uidstring

The user ID for a new account. This must be a numeral, not already associated with disk usage, and does not pre-exist on the machine. You must be logged in as the root user.

Note

Icon
This variable is only accepted in cPanel & WHM Version 11.32 and later.
 gidstring

The group ID for a new account. This must be a numeral, not already associated with disk usage, and does not pre-exist on the machine. You must be logged in as the root user.

Note

Icon
This variable is only accepted in cPanel & WHM Version 11.34 and later.
 homedirstring

The home directory (HOMEDIR) to be used for a new account. You must be logged in as the root user (for example:/home/johndoe).

Note

Icon
This variable is only accepted in cPanel & WHM Version 11.34 and later.
OutputTypeDescription
createacctThe container for the results from the createacct function.
resultThe container for the results of the function.
optionsThe container for the domain options.
ipstringIP address with which the the domain is associated (for example, 123.456.789.10).
nameserverXstringThe nameserver for the domain. The property of nameserver may be appended by an integer (x) between 1 and 5 (for example: nameserver1).
nameserveraXstringIP address of the nameserver. The property of nameservera may be appended by an integer (x) between 1 and 5 (for example: nameservera1).
nameserverentryXstringDNS name of the nameservers the namerservers are registered. The property of nameserverentry may appear appended by an integer (x) between 1 and 5 (for example: nameserverentry1).
rawoutstringRaw output of the account creation operation in HTML format.

 

Examples

JSON
Input URL

https://hostname:2087/cpsess########/json-api/createacct

Output
{
   "result":[
      {
         "status":1,
         "statusmsg":"Account Creation Ok",
         "rawout":"<table style=\"border- bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"> <pre>Checking input data...System has 2 free ips.\n...Done</pre></td><td width=\"30\"> <img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td> </tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"> <pre>WWWAcct 12.1.0 (c) 1997-2008 cPanel, Inc....\n\nDns Zone check is enabled. \n+===================================+\n| New Account Info |\n+===================================+\n| Domain: example.com\n| Ip: 127.0.0.1 (n)\n| HasCgi: y\n| UserName: user123\n| PassWord: h@rd2gu3ss!p@ss\n| CpanelMod: x3\n| HomeRoot: /home\n| Quota: 0 Meg\n| NameServer1: ns1.example.net\n| NameServer2: ns2.example.net\n| NameServer3: ns1.example.com\n| NameServer4: ns2.example.com\n| Contact Email: \n| Package: level3==\n| Feature List: default\n| Language: english\n+===================================+\n...Done</pre> </td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"> </td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Running pre creation script (/scripts/prewwwacct)......Done</pre></td><td width=\"30\"><img align=absmiddlesrc=http://www.mamicode.com/"/cPanel_magic_revision_ 1181098607/icons/good.gif\"> </td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr> <td width=\"100%\"><pre>Adding User...Removing Shell Access (n)\n...Done</pre> </td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"> </td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"> <tr><td width=\"100%\"><pre>Copying skel files from /root/cpanel3-skel/ to /home/user123/......Done</pre></td><td width=\"30\"> <img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Adding Entries to httpd.conf......Done</pre></td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Setting up Mail & Local Domains...localdomains...valiases ...vdomainaliases...vfilters......Done</pre></td> <td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Configuring DNS...Bind reconfiguring on publicdocs using rndc\n...Done</pre></td><td width=\"30\"> <img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Restarting apache......Done</pre></td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table>\nChanging password for user123\nPassword for user123 has been changed\n<table style=\"border- bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Updating Authentication Databases...Updating ftp passwords for user123\nFtp password files updated.\nFtp vhost passwords synced\n...Done</pre></td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"> </td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Verifying MX Records and Setting up Databases......Done</pre></td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"> </td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Setting up Proxy Subdomains......Done</pre></td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table>\nBind reloading on publicdocs using rndc zone: [example.com]\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Sending Account Information......Done</pre></td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td> </tr></table>\nSystem has 2 free ips.\n<table style=\"border-bottom: 1px #ccc dotted;\"> <tr><td width=\"100%\"><pre>Running post creation scripts (/scripts/legacypostwwwacct, /scripts/postwwwacct, /scripts/postwwwacctuser)......Done</pre></td><td width=\"30\"> <img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr> </table>\nwwwacct creation finished\n<table style=\"border-bottom: 1px #ccc dotted;\"> <tr><td width=\"100%\"><pre>Setting up Domain Pointers......Done</pre></td><td width=\"30\"> <img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table> \n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"> <pre>Setting Reseller Privs......Done</pre></td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table>\n<table style=\"border-bottom: 1px #ccc dotted;\"><tr><td width=\"100%\"><pre>Account Creation Complete!!!...Account Creation Ok...Done</pre></td><td width=\"30\"><img align=absmiddle src=http://www.mamicode.com/"/cPanel_magic_revision_1181098607/icons/good.gif\"></td></tr></table>\n", "options":{ "nameserver4":"ns2.example.com", "nameserver":"ns1.example.net", "nameserverentry2":null, "nameserverentry3":null, "nameserverentry4":null, "nameserverentry":null, "ip":"127.0.0.1", "nameservera2":null, "nameservera3":null, "package":"level3==", "nameservera4":null, "nameserver2":"ns2.cpanelrocks.net", "nameservera":null, "nameserver3":"ns1.example.com" }
 }
 ]
}
XML
Input URL

https://hostname:2087/cpsess########/xml-api/createacct

Output
<createacct>
     <result>       
          <options>
                  <ip>192.168.0.20</ip>
                  <nameserver>ns1.domain.tld</nameserver>
                  <nameserver2>ns2.domain.tld</nameserver2>
                  <nameserver3/>
                  <nameserver4/>
                  <nameservera/>
                  <nameservera2/>
                  <nameservera3/>
                  <nameservera4/>
                  <nameserverentry/>
                  <nameserverentry2/>
                  <nameserverentry3/>
                  <nameserverentry4/>
                  <package>basic</package>
           </options>
           <rawout>
Checking input data...The ProFTPd configuration file /etc/proftpd.conf appears to be ok!
System has 0 free ips.
...Done
 
WWWAcct 12.1.0 (c) 1997-2008 cPanel, Inc....
 
Dns Zone check is enabled.
+===================================+
| New Account Info                  |
+===================================+
| Domain: domain.tld
| Ip: 192.168.0.20 (n)
| HasCgi: y
| UserName: myuser
| PassWord: h@rd2gu3ss!p@ss
| CpanelMod: x3
| HomeRoot: /home
| Quota: 0 Meg
| NameServer1: ns1.example.com
| NameServer2: ns2.example.com
| NameServer3: ns1.domain.com
| NameServer4:
| Contact Email: username@domain.tld
| Package: basic
| Feature List: default
| Language: english
+===================================+
...Done
 
Running pre creation script (/scripts/prewwwacct)......Done
Adding User...Removing Shell Access (n)
...Done
Copying skel files from /root/cpanel3-skel/ to /home/myuser/......Done
Adding Entries to httpd.conf......Done
Setting up Mail and Local Domains...localdomains...
valiases ...vdomainaliases...vfilters......Done
Configuring DNS...Bind reconfiguring on server1 using rndc
...Done
Restarting apache......Done
Changing password for myuser Password for myuser has been changed
Updating Authentication Databases...Updating ftp passwords for myuser
Ftp password files updated.
Ftp vhost passwords synced
...Done
Verifying MX Records and Setting up Databases......Done
Setting up Proxy Subdomains......Done
Bind reloading on server1 using rndc zone: [domain.tld]
Sending Account Information......Done
System has 0 free ips.
Running post creation scripts (/scripts/legacypostwwwacct,
/scripts/postwwwacct, /scripts/postwwwacctuser)......Done
wwwacct creation finished
Setting up Domain Pointers......Done
Setting Reseller Privs......Done
Account Creation Complete!!!...Account Creation Ok...Done
            </rawout>
            <status>1</status>
            <statusmsg>Account Creation Ok</statusmsg>
     </result>
</createacct>

WHM API 1 - createacct