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

 

Description

This function deletes a Subaccount. This function returns only metadata if no other service accounts exist with the same username and domain. 

  • If one service account uses the same username and domain, the function returns the service account's information.
  • If two or more service accounts use the same username and domain, the function returns a hypothetical Subaccount. 

Note:

A hypothetical Subaccount consists of two or more service accounts that use the same username and domain.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/UserManager/delete_user?username=example1&domain=example.com

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.
 
// Deletes the Subaccount.
$Usermanager = $cpanel->uapi(
    'UserManager', 'delete_user',
  array(
        'username'        => 'example1',
        'domain'          => 'example.com',
        )
);

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.
 
# Deletes the Subaccount.
my $Usermanager = $cpliveapi->uapi(
    'UserManager', 'delete_user',
   {
        'username'        => 'example1',
        'domain'          => 'example.com',
   }
);

Note:

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

 

 cPanel Template Toolkit
<!-- Deletes the Subaccount. -->
[% execute('UserManager', 'delete_user', {'username' => 'example1', 'domain' => 'example.com',} ) %]

Note:

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

 

 Command Line
uapi --user=username UserManager delete_user username=example1 domain=example.com

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)
{  
   "errors":null,
   "messages":null,
   "status":1,
   "metadata":{  

   },
   "data":{  
      "has_invite":0,
      "has_siblings":0,
      "username":"example1",
      "invite_expiration":null,
      "can_set_password":0,
      "merge_candidates":[  
         {  
            "dismissed":0,
            "phone_number":null,
            "avatar_url":null,
            "domain":"example.com",
            "guid":"EXAMPLE1:EXAMPLE.COM:577D1AF6:E9897AA23C50E177FEEDB5168B240A3458334E6DC955653D3FBBB24538F1F807",
            "type":"service",
            "real_name":null,
            "sub_account_exists":0,
            "full_username":"example1@example.com",
            "alternate_email":null,
            "can_set_quota":1,
            "parent_type":null,
            "services":{  
               "webdisk":{  
                  "enabled":0
               },
               "ftp":{  
                  "enabled":0
               },
               "email":{  
                  "enabled":1,
                  "quota":0
               }
            },
            "special":0,
            "can_delete":1,
            "can_set_password":1,
            "invite_expiration":null,
            "has_siblings":0,
            "username":"example1",
            "has_invite":0,
            "issues":[  

            ],
            "dismissed_merge_candidates":[  

            ],
            "has_expired_invite":0,
            "merge_candidates":[  

            ],
            "synced_password":0
         },
         {  
            "issues":[  

            ],
            "synced_password":0,
            "merge_candidates":[  

            ],
            "has_expired_invite":0,
            "dismissed_merge_candidates":[  

            ],
            "invite_expiration":null,
            "can_set_password":1,
            "has_invite":0,
            "username":"example1",
            "has_siblings":0,
            "can_set_quota":1,
            "alternate_email":null,
            "can_delete":1,
            "special":0,
            "services":{  
               "email":{  

               },
               "ftp":{  
                  "quota":"42.00",
                  "homedir":"example1@example.com",
                  "enabled":1
               },
               "webdisk":{  
                  "enabled":0
               }
            },
            "parent_type":null,
            "domain":"example.com",
            "avatar_url":null,
            "phone_number":null,
            "dismissed":0,
            "full_username":"example1@example.com",
            "sub_account_exists":0,
            "real_name":null,
            "type":"service",
            "guid":"EXAMPLE1:EXAMPLE.COM:577D1AF6:D7DC771B2C35109DC57FC7ED4257D7EEA4F4F06FDCB5203E5DB7BD1863C407B0"
         },
         {  
            "has_expired_invite":0,
            "dismissed_merge_candidates":[  

            ],
            "synced_password":0,
            "merge_candidates":[  

            ],
            "issues":[  

            ],
            "has_siblings":0,
            "username":"example1",
            "has_invite":0,
            "can_set_password":1,
            "invite_expiration":null,
            "services":{  
               "email":{  

               },
               "webdisk":{  
                  "enabledigest":1,
                  "homedir":"home/example/public_html/webdav",
                  "perms":"rw",
                  "enabled":1,
                  "private":0
               },
               "ftp":{  

               }
            },
            "parent_type":null,
            "can_delete":1,
            "special":0,
            "can_set_quota":1,
            "alternate_email":null,
            "type":"service",
            "guid":"EXAMPLE1:EXAMPLE.COM:577D1AF6:C2F3566DCE80D6B1A3B25512E73C64BF6B7B4FA7E791A8E89DF091FE2242ECB6",
            "full_username":"example1@example.com",
            "sub_account_exists":0,
            "real_name":null,
            "avatar_url":null,
            "phone_number":null,
            "dismissed":0,
            "domain":"example.com"
         }
      ],
      "synced_password":0,
      "dismissed_merge_candidates":[  

      ],
      "has_expired_invite":0,
      "issues":[  

      ],
      "real_name":null,
      "full_username":"example1@example.com",
      "sub_account_exists":0,
      "guid":"EXAMPLE1:EXAMPLE.COM:577D1AF6:BA8D199D4AB1DF97B69EE912B9607B4EF2558AE0D743510F98062E1CC5ACD698",
      "type":"hypothetical",
      "domain":"example.com",
      "dismissed":0,
      "phone_number":null,
      "avatar_url":null,
      "can_delete":0,
      "special":0,
      "parent_type":null,
      "services":{  
         "email":{  
            "enabled":0
         },
         "ftp":{  
            "enabled":0
         },
         "webdisk":{  
            "enabled":0
         }
      },
      "alternate_email":null,
      "can_set_quota":0
   }
}

Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
username string

Required

The Subaccount's username.

 

A username that meets the account name limitations.
  • Length — 64 characters
    • Characters — a-zA-Z0-9, dot (.), hyphen (-), underscore (_)

Note:

This value does not include the domain name.

example
domainstring

Required

The Subaccount's associated domain.

A domain that the cPanel account owns.example.com

Returns

Note:

This function returns only metadata if the specified username and domain do not match any service accounts or hypothetical Subaccounts.

ReturnTypeDescriptionPossible valuesExample
alternate_emailstring

An alternate email address for the account's user.

A valid email address. user@example.com
avatar_urlstring

The user's account 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 account.
  • 1 — Can delete.
  • 0Cannot delete.
0
can_set_passwordBoolean

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

 

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

Note:

The function returns 0 for accounts that inherit their password from the cPanel account.

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

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
dismissed_merge_candidates array of hashesAn array of hashes that represent the service accounts that the user dismissed the merge prompt for.

This array will always return empty.

Note:

We reserved this return for future use.

 
domainstringThe account user's associated domain.A domain that the cPanel account owns.example.com
full_usernamestring

The account's username and domain name.

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

The account unique identifier.

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

N4641:EXAMPLE.COM:564CC8A7:A82EA007D8348AC631C0170F9418EC1DEB0D164CC5A722A87C55EF5DD2AD98D4

has_expired_invite Boolean

Whether the Subaccount owns an expired invitation.

Note:

We introduced this return in cPanel & WHM version 60. 

  • 1 — Owns an expired invitation.
  • 0 — Does not own an expired invitation.
0
has_invite Boolean

Whether the Subaccount owns an active invitation.

Note:

We introduced this return in cPanel & WHM version 60. 

  • 1 — Owns an invitation.
  • 0 — Does not own an invitation.
0
has_siblings BooleanWhether the service account shares a full_username value with another service account.
  • 1 — Shares.
  • 0 — Does not share.
0
invite_expiration integer

The time at which the new Subaccount invitation will expire.

If the account does not own an active invitation, this value returns null.

Note:

We introduced this return in cPanel & WHM version 60. 

  • A valid Unix epoch time.
  • null
1466258282
issuesarrayInformation about any issues or problems with the account.

This array includes 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

stringThe affected section of cPanel & WHM.quotaquota

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 string value.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 account.

The function returns this value in the issues array.

A positive integer.1500
merge_candidatesarray

The service accounts that the system could merge for this account.

Note:

You can find descriptions for this array's returns within this table.

This array includes 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. 
parent_typestringThe type of account that could own the service account.
  • sub — An account.
  • hypothetical — A hypothetical account that does not yet exist, but that the user could create as part of a merge.
  • nullNot a merge candidate.

 

 hypothetical
phone_numberstringThe account 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 account's user.

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

email

hash

Information that indicates the account's email status.

The function returns this value in the services hash.

This hash includes the enabled and quota returns.

 

enabled

Boolean

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

The function returns this value in the email hash.

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

quota

string

The account'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 account may use, in Megabytes (MB).
  • 0 — Unlimited.
100

ftp

hash

Information about the account's FTP status.

The function returns this value in the services hash. 

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

 

enabled

Boolean

Whether the account can access FTP.

The function returns this value in the ftp hash.

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

quota

integer

The account's FTP disk space quota.

The function returns this value in the ftp hash. 

  • An integer that represents the account's maximum FTP disk usage, in Megabytes (MB).
  • 0 — Unlimited.
100

homedir

string

The account's FTP home directory.

The function returns this value in the ftp hash. 

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

webdisk

hash

Information about the account's Web Disk status.

The function returns this value in the services hash. 

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

 

enabled

Boolean

Whether the account can access Web Disk.

The function returns this value in the webdisk hash. 

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

homedir

string

The account's Web Disk 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 account.

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 an account 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 account'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.

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

The account username.

 

A username that meets the account name limitations.

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

Note:

This value does not include the domain name.

example