UAPI Functions - UserManager::create_user

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

 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',
        )
);


 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',
    }
);

 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'} ) %]

 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.

 Output (JSON)

{
    "messages": null,
    "data": {
        "alternate_email": "robert@example.com",
        "can_set_password": 1,
        "username": "bob",
        "can_delete": 1,
        "special": 0,
        "parent_type": null,
        "issues": [],
        "domain": "example.com",
        "services": {
            "email": {
                "quota": 2,
                "enabled": 1
            },
            "ftp": {
                "enabled": 1,
                "quota": "0.00",
                "homedir": "bob"
            },
            "webdisk": {
                "enabledigest": 0,
                "homedir": "bob",
                "perms": "rw",
                "private": 0,
                "enabled": 1
            }
        },
        "synced_password": 1,
        "guid": "BOB:EXAMPLE.COM:56EC06FA:7902285ACB6F078509A9ECDFEAFD63CF903BB7572C2B23BD51C6AC8414567AE6",
        "merge_candidates": [],
        "can_set_quota": 0,
        "type": "sub",
        "avatar_url": null,
        "sub_account_exists": null,
        "dismissed": null,
        "full_username": "bob@example.com",
        "real_name": "Bob Doe",
        "phone_number": null,
        "dismissed_merge_candidates": [],
        "has_siblings": null
    },
    "status": 1,
    "metadata": {},
    "errors": null
}

 

Note:

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

 

Parameters

Parameter

Type

Description

Possible values

Example

alternate_email

string

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_url

string

 

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.

 

domain

string

Required

The subaccount user's associated domain.

A domain that the cPanel account owns.

example.com

password

string

Required

The subaccount's password.

Note:

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

A secure password.

12345luggage

phone_number

string

 

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'sE.164-recommended standard for the representation of telephone numbers.

+15551234567

real_name

string

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_invite

Boolean

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.enabled

Boolean

Whether to grant the subaccount email access.

This parameter defaults to 0.

  • 1 — Can access.
  • 0 — Cannotaccess.

1

services.email.quota

string

The subaccount's email disk space quota.

This parameter defaults to 0. 

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

500

services.ftp.enabled

Boolean

Whether to grant the subaccount FTP access.

This parameter defaults to 0.

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

1

services.ftp.homedir

string

The subaccount's FTP home directory.

Note:

This parameter is required if you enabled FTP access.

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

Note:

The directory must exist.

 

/subaccount

services.webdisk.enabled

Boolean

Whether to grant the subaccount Web Disk access.

This parameter defaults to 0.

  • 1 — Can access.
  • 0 — Cannotaccess.

1

 services.webdisk.enabledigest 

 Boolean 

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 cpdavddaemons.
  • We recommend that you do notuse Digest Authentication.

This parameter defaults to 0.

  • 1 — Enabled.
  • 0 — Disabled.

0

services.webdisk.private

Boolean

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.homedir

string

The subaccount's Web Disk home directory.

This parameter is required if you enable Web Disk access.

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

/subaccount

services.webdisk.perms

string

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

Note:

The services.webdisk.homedirparameter determines the subaccount's Web Disk home directory.

This parameter defaults to rw.

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

rw

type

string

The type of account.

This parameter defaults to sub.

  • sub — A subaccount.

sub

username

string

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

 

Return

Type

Description

Possible values

Example

alternate_email

string

An alternate email address for the subaccount's user.

A valid email address.

 user@example.com 

avatar_url

string

 The URL to the user's subaccount profile photo.

Note:

Use the HTTPS protocol to prevent mixed content warnings when users view it from another HTTPS URL.

 A valid HTTPS URL that points to an image file.

 

can_delete

 boolean 

Whether the cPanel account user can delete the subaccount.

  • 1 — Can delete.
  • 0 — Cannot delete.

0

can_set_password

boolean

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

 

  • 1 — Can change password.
  • 0 — Cannot change password.

Note:

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

1

can_set_quota

boolean

Whether the cPanel account user can change the subaccount's disk usage quota.

  • 1 — Can change quota.
  • 0 — Cannot change quota.

0

dismissed

boolean

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

Note:

Only service accounts return this value.

  • 1 — Dismissed prompt.
  • 0 — Did not dismiss prompt.

1

domain

string

 The subaccount user's associated domain.

A domain that the cPanel account owns.

example.com

full_username

string

The subaccount's username and domain name.

 A valid username, the @ character, and the associated domain.

user@example.com

guid

string

 The subaccountunique identifier.

Note:

The subaccount's globally unique identifier (GUID) does not change when you adjust its other attributes.

The system assigned unique value.

 

issues

array

This array of hashes contains information about any issues or problems with the subaccount.

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

 

type

string

The type of issue.

The function returns this value in theissues array.

  • error
  • warning
  • info

info

area

string

The affected section of cPanel & WHM.

quota

quota

service

string

The affected service.

The function returns this value in theissues array.

  • email
  • ftp
  • webdisk

email

message

string

The description of the issue.

The function returns this value in theissues array.

A message that contains a description of the issue.

 Your account is over quota.

used

string

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

The function returns this value in theissues array.

A positive integer.

2000

limit

string

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

The function returns this value in theissues array.

A positive integer.

1500

merge_candidates

array

An 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, andusername values.

 

has_siblings

boolean

Whether the service account shares afull_username value with another service account.

  • 1 — Shared.
  • 0 — Not shared.

0

parent_type

string

The 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.
  • null— Not a merge candidate.

 

 hypothetical

phone_number

string

The subaccount user's phone number.

A valid phone number that conforms to ITU-T'sE.164 recommended standard for the representation of telephone numbers.

+15551234567

real_name

string

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

services

hash

This hash contains  information about the  subaccount's access to email, FTP, and Web Disk.

This hash contains the email, ftp, and webdiskvalues.

 

email

hash

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

This hash contains the enabled and quota values.

 

enabled

boolean

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

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

1

quota

string

The subaccount's email disk space quota.

  • A positive integer between one and 999,999 that represents the maximum disk space that the subaccount may use, in megabytes (MB).
  • 0 — The subaccount's disk space is unlimited.

100

ftp

hash

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

This hash contains the enabled, quota, and homedirvalues.

 

enabled

boolean

Whether the  subaccount can access FTP.

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

0

quota

string

The subaccount's FTP disk space quota.

  • An integer that represents the subaccount's maximum FTP disk usage, in Megabytes (MB).
  • A value of 0 grants the subaccount unlimited FTP disk space.

100

homedir

string

The subaccount's FTP home directory.

A relative path from the cPanel account's home directory on the server.

/subaccount

webdisk

hash

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

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

 

enabled

boolean

Whether the  subaccount can access Web Disk.

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

0

homedir

string

The path to the subaccount's directory, relative to the cPanel account's home directory.

A valid path.

/bob

perms

string

Whether to grant write permissions to the subaccount.

  • 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.

Notes:

  • When the directory is public, the home directory's permissions are 0755.
  • When the directory is private, the home directory's permissions are 0700.
  • 1 — Private.
  • 0 — Public.

 

0

special

boolean

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

 

  • 1 — A special account.
  • 0 — Not a special account.

1

 sub_account_exists 

boolean

 Whether a  subaccount exists with the same username.

  • 1 — Yes.
  • 0 — No.

Note:

The function returns this attribute as nullvalue if the account type is not a service account.

0

synced_password

boolean

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

  • 1 — Passwords synchronized.
  • 0 — Passwords not synchronized.

Note:

The function returns this attribute as nullvalue if the account type 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

username

string

The username for the subaccount.

Notes:

This value does not include the domain name.

A username that meets the subaccount name limitations.

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

example

 

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....