Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function creates a Subaccount.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/UserManager/create_user?alternate_email=robert%40example.com&domain=example.com&password=12345luggage&real_name=Bob%20Doe&send_invite=0&services.email.enabled=1&services.email.quota=2&services.ftp.enabled=1&services.ftp.homedir=%2Fbob&services.webdisk.enabled=1&services.webdisk.private=0&services.webdisk.homedir=%2Fbob&services.webdisk.perms=0&type=sub&username=bob

Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Create Subaccount.
$Usermanager = $cpanel->uapi(
    'UserManager', 'create_user',
	array(
		'alternate_email'			=>	'robert@example.com',
		'domain'					=>	'example.com',
		'password'					=>	'12345luggage',
		'real_name'					=>	'Bob Doe',
		'send_invite'				=>	'0'
		'services.email.enabled'	=>	'1',
		'services.email.quota'		=>	'2',
		'services.ftp.enabled'		=>	'1',
		'services.ftp.homedir'		=>	'/bob',
		'services.webdisk.enabled'	=>	'1',
		'services.webdisk.private'	=>	'0',
		'services.webdisk.homedir'	=>	'/bob',
		'services.webdisk.perms'	=> 	'0',
		'type'						=>	'sub',
		'username'					=>	'bob',
		)
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Create Subaccount.
my $Usermanager = $cpliveapi->uapi(
    'UserManager', 'create_user',
	{
		'alternate_email'			=>	'robert@example.com',
		'domain'					=>	'example.com',
		'password'					=>	'12345luggage',
		'real_name'					=>	'Bob Doe',
		'send_invite'				=>	'0'
		'services.email.enabled'	=>	'1',
		'services.email.quota'		=>	'2',
		'services.ftp.enabled'		=>	'1',
		'services.ftp.homedir'		=>	'/bob',
		'services.webdisk.enabled'	=>	'1',
		'services.webdisk.private'	=>	'0',
		'services.webdisk.homedir'	=>	'/bob',
		'services.webdisk.perms'	=> 	'0',
		'type'						=>	'sub',
		'username'					=>	'bob',
	}
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 cPanel Template Toolkit
<!-- Create Subaccount. -->
[% execute('UserManager', 'create_user', {'alternate_email' => 'robert@example.com', 'domain' => 'example.com', 'password' => '12345luggage', 'real_name' => 'Bob Doe', 'send_invite' => '0', 'services.email.enabled' => '1', 'services.email.quota' => '2', 'services.ftp.enabled' => '1', 'services.ftp.homedir' => '/bob', 'services.webdisk.enabled' => '1', 'services.webdisk.private' =>  '0', 'services.webdisk.homedir' => '/bob', 'services.webdisk.perms' => '0', 'type' => 'sub', 'username' => 'bob'} ) %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 

 Command Line
uapi --user=username UserManager create_user alternate_email=robert%40example.com domain=example.com password=12345luggage real_name='Bob Doe' send_invite=0 services.email.enabled=1 services.email.quota=2 services.ftp.enabled=1 services.ftp.homedir=/bob services.webdisk.enabled=1 services.webdisk.private=0 services.webdisk.homedir=/bob services.webdisk.perms=0 type=sub username=bob

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{  
   "status":1,
   "metadata":{  

   },
   "messages":null,
   "errors":null,
   "data":{  
      "has_expired_invite":0,
      "invite_expiration":1467983724,
      "has_invite":1,
      "services":{  
         "webdisk":{  
            "enabled":1,
            "homedir":"bob",
            "perms":"rw",
            "enabledigest":0,
            "private":0
         },
         "ftp":{  
            "quota":"0.00",
            "homedir":"bob",
            "enabled":1
         },
         "email":{  
            "enabled":1,
            "quota":2
         }
      },
      "username":"bob",
      "full_username":"bob@example.com",
      "can_set_password":1,
      "avatar_url":null,
      "dismissed":0,
      "issues":[  

      ],
      "domain":"example.com",
      "synced_password":1,
      "alternate_email":"robert@example.com",
      "special":0,
      "merge_candidates":[  

      ],
      "guid":"BOB:EXAMPLE.COM:577D046C:FC7E72D7B90142A1C7697D9234B50D0978369FB80D3D1A2A72A98E81A268CFC9",
      "real_name":"Bob Doe",
      "can_delete":1,
      "has_siblings":0,
      "type":"sub",
      "sub_account_exists":0,
      "can_set_quota":0,
      "dismissed_merge_candidates":[  

      ],
      "phone_number":null,
      "parent_type":null
   }
}

Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
alternate_emailstring

An alternate email address for the Subaccount's user.

Note:

You must use this parameter if you set the send_invite value to 1.

This parameter defaults to null.

A valid email address.

user@example.com
avatar_urlstring

Warning:

We reserved this parameter for future use. Do not use this parameter.

The user's Subaccount profile photo.

This parameter defaults to null .

A valid HTTPS URL that points to an image file.

Note:

You must use the HTTPS protocol to prevent mixed content warnings when users view the image from another HTTPS URL.

 Click to view...

https://img.example.com/avatars/example.jpg

domainstring

Required

The Subaccount user's associated domain.

A domain that the cPanel account owns.

example.com
passwordstring

Required

The Subaccount's password.

Note:

Email, FTP, and Web Disk services use this password.

A secure password.12345luggage
phone_numberstring

Warning:

We reserved this parameter for future use. Do not use this parameter.

A phone number for the Subaccount user.

This parameter defaults to null. 

A valid phone number that conforms to ITU-T's E.164 -recommended standard for the representation of telephone numbers.+15551234567
real_namestring

The Subaccount user's name.

This parameter defaults to null. 

  • A first name.
  • A last name.
  • A first name and last name.
  • An empty string.
John Doe
send_inviteBoolean

Whether to send a reset password email to the Subaccount's alternate email address.

Note:

We introduced this parameter in cPanel & WHM version 56.

This parameter defaults to 0.

  • 1 — Send.
  • 0 — Do not send.
0
services.email.enabledBoolean

Whether to grant the Subaccount email access.

This parameter defaults to 0.

  • 1 — Can access.
  • 0Cannot access.
1
services.email.quotastring

The Subaccount's email disk space quota.

This parameter defaults to 0. 

  • A positive integer between 1 and 999999 that represents the maximum disk space that the Subaccount may use, in Megabytes (MB).
  • 0 — Unlimited.
500
services.ftp.enabledBoolean

Whether to grant the Subaccount FTP access.

This parameter defaults to 0.

  • 1 — Can access.
  • 0Cannot access.
1
services.ftp.homedirstring

The Subaccount's FTP home directory.

Note:

This parameter is required if you enabled the services.ftp.homedir parameter.

A valid path, relative to the cPanel account's home directory.

Note:

The directory must exist.

/Subaccount
services.webdisk.enabledBoolean

Whether to grant the Subaccount Web Disk access.

This parameter defaults to 0.

  • 1 — Can access.
  • 0Cannot access.
1
services.webdisk.enabledigestBoolean

Whether to enable the Web Disk Digest Authentication.

Notes:

  • Only enable Digest Authentication for clients that require additional compatibility support on certain versions of Windows® operating systems. This compatibility support is only required on servers that use a self-signed certificate for the cpsrvd and cpdavd daemons.
  • We recommend that you do not use Digest Authentication.

This parameter defaults to 0.

  • 1 — Enabled.
  • 0 — Disabled.
0
services.webdisk.privateBoolean

Whether to set the directory's permissions to public or private.

This parameter defaults to 0. 

  • 1 — Private (0700).
  • 0 — Public (0755).
1
services.webdisk.homedirstring

The Subaccount's Web Disk home directory.

This parameter is required if you enable the services.webdisk.enabled parameter.

A valid path, relative to the cPanel account's home directory.

/Subaccount
services.webdisk.permsstring

The Subaccount's file permissions for its Web Disk home directory.

Note:

The services.webdisk.homedir parameter determines the Subaccount's Web Disk home directory.

This parameter defaults to rw.

  • ro — Read-only permissions.
  • rw — Read and write permissions.
rw
typestring

The type of account.

This parameter defaults to sub.

  • sub — A Subaccount.
sub
usernamestring

Required

The username for the Subaccount.

A username that meets the Subaccount name limitations.

  • Length — 64 characters
  • Characters — a-z, A-Z, 0-9, dot (.), hyphen(-), underscore (_)

Note:

This value does not include the domain name.

example

Returns

ReturnTypeDescriptionPossible valuesExample
alternate_emailstring

An alternate email address for the subaccount's user.

A valid email address. user@example.com
avatar_urlstring

The user's subaccount profile photo.

 A valid HTTPS URL that points to an image file.
 Click to view...

https://img.example.com/avatars/example.jpg

can_deleteBooleanWhether the cPanel account user can delete the subaccount.
  • 1 — Can delete.
  • 0Cannot delete.
0
can_set_passwordBoolean

Whether the cPanel account user can change the subaccount's password.

 

  • 1 — Can change.
  • 0Cannot change.

Note:

The function returns a 0 value for subaccounts that inherit their password from the cPanel account.

1
can_set_quotaBooleanWhether the cPanel account user can change the subaccount's disk usage quota.
  • 1 — Can change.
  • 0Cannot change.
0
dismissedBoolean

Whether the cPanel account user dismissed the merge prompt for the service account.

Note:

Only service accounts return this value.

  • 1 — Dismissed.
  • 0 — Did not dismiss.
1
domainstringThe subaccount user's associated domain.A domain that the cPanel account owns.example.com
full_usernamestring

The subaccount's username and domain name.

A valid username, the @ character, and the associated domain.user@example.com
guidstring

The subaccount unique identifier.

The system assigned unique value.
 Click to view...

N4641:EXAMPLE.COM:564CC8A7:A82EA007D8348AC631C0170F9418EC1DEB0D164CC5A722A87C55EF5DD2AD98D4

issuesarrayInformation about any issues or problems with the subaccount.

This array contains the type, area, service, message, used, and limit returns.

 

type

string

The type of issue.

The function returns this value in the issues array.

  • error
  • warning
  • info
info

area

string

The affected section of cPanel & WHM.

The function returns this value in the issues array.

A valid section name.quota

service

string

The affected service.

The function returns this value in the issues array.

  • email
  • ftp
  • webdisk
email

message

string

The description of the issue.

The function returns this value in the issues array.

A valid string.Your account is over quota.

used

integer

The number of Megabytes (MB) that the account currently uses.

The function returns this value in the issues array.

A positive integer.2000

limit

integer

The set quota Megabyte (MB) limit for the affected subaccount.

The function returns this value in the issues array.

A positive integer.1500
merge_candidatesarrayAn array of hashes that represents the service accounts that the system could merge for this subaccount.This array contains the alternate_email, avatar_url, can_delete, can_set_password, can_set_quota, dismissed, domain, full_username, guid, has_siblings, issues, merge_candidates, parent_type, phone_number, real_name, services, special, sub_account_exists, synced_password, type, and username returns. 
has_siblingsBooleanWhether the service account shares a full_username value with another service account.
  • 1 — Shares.
  • 0 — Does not share.
0
parent_typestringThe type of account that could own the service account.
  • sub — A subaccount.
  • hypothetical — A hypothetical subaccount that does not yet exist, but the user could create as part of a merge.
  • nullNot a merge candidate.

 

 hypothetical
phone_numberstringThe subaccount user's phone number.A valid phone number that conforms to ITU-T's E.164-recommended standard for the representation of telephone numbers.+15551234567
real_namestring

The name of the subaccount's user.

  • A first name, a last name, or a first name and last name.
  • An empty string.
John Doe
serviceshashThis hash contains information about the subaccount's access to email, FTP, and Web Disk.This hash contains the email, ftp, and webdisk returns. 

email

hash

This hash contains the information that indicates the subaccount's email status.

The function returns this hash in the services hash.

This hash contains the enabled and quota returns.

 

enabled

Boolean

Whether the subaccount can access Webmail, POP, and IMAP services.

The function returns this value in the email hash.

  • 1 — Can access.
  • 0Cannot access.
1

quota

integer

The subaccount's email disk space quota.

The function returns this value in the email hash.

  • A positive integer between 1 and 999999 that represents the maximum disk space that the subaccount may use, in Megabytes (MB).
  • 0 — Unlimited.
100

ftp

hash

This hash contains the information that indicates the subaccount's FTP status.

The function returns this hash in the services hash.

This hash contains the enabled, quota, and homedir returns.

 

enabled

Boolean

Whether the subaccount can access FTP.

The function returns this value in the ftp hash.

  • 1 — Can access.
  • 0Cannot access.
0

quota

integer

The subaccount's FTP disk space quota.

The function returns this value in the ftp hash.

  • A positive integer between 1 and 999999 that represents the maximum disk space that the subaccount may use, in Megabytes (MB).
  • 0 — Unlimited.
100

homedir

string

The subaccount's FTP home directory.

The function returns this value in the ftp hash.

A valid path, relative to the cPanel account's home directory./subaccount

webdisk

hash

This hash contains information that indicates the subaccount's Web Disk status.

The function returns this hash in the services hash.

This hash contains the enabled, homedir, perms, and private returns.

 

enabled

Boolean

Whether the subaccount can access Web Disk.

The function returns this value in the webdisk hash.

  • 1 — Can access.
  • 0Cannot access.
0

homedir

string

The subaccount's Web Disk home directory.

The function returns this value in the webdisk hash.

A valid path, relative to the cPanel account's home directory./bob

perms

string

Whether to grant write permissions to the subaccount.

The function returns this value in the webdisk hash.

  • ro — Read-only permissions.
  • rw — Read and write permissions.
rw

private

Boolean

Whether to set the Web Disk directory's permissions to public or private.

The function returns this value in the webdisk hash.
  • 1 — Private (0700).
  • 0 — Public (0755).
0
specialBoolean

Whether the account is a system-created special account that the user cannot remove.

 

  • 1 — A special account.
  • 0Not a special account.
1
sub_account_existsBooleanWhether a subaccount exists with the same username.
  • 1 — Exists.
  • 0 — Does not exist.

Note:

The function returns a null value if the account is not a service account.

0
synced_passwordBoolean

Whether the user has synchronized the passwords for each of the subaccount's service accounts.

  • 1 — Synchronized.
  • 0Not synchronized.

Note:

The function returns a null value if the account is not a subaccount.

0
type string

The type of account.

  • sub — A subaccount.
  • hypothetical — A hypothetical subaccount that does not exist, but that the user could create as part of a merge.
  • service — A service account.
  • cpanel — The cPanel account.
sub
usernamestring

The username for the subaccount.

A username that meets the subaccount name limitations.

  • Length — 64 characters
  • Characters — a-zA-Z0-9, dot (.), hyphen (-), underscore (_)

Note:

This value does not include the domain name.

example