Create subdomain

This function creates a subdomain.

Important:

When you disable the Web Server role, the system disables this function.

Authorizations:
query Parameters
domain
required
string

The subdomain name to create.

Example: domain=subdomain
rootdomain
required
string <domain>

The domain on which to create the new subdomain. The domain must already exist on the cPanel account.

Example: rootdomain=example.com
canoff
integer
Default: 1

Whether to use a canonical name (CNAME) in the Apache® configuration for self-referential URLs.

  • 1 - Use the CNAME.
  • 0 - Do not use the CNAME.
Enum: 0 1
Example: canoff=1
dir
string <path>

The subdomain's document root within the home directory, given as a valid directory path relative to the user's home directory.

This value defaults to the user's home directory /public_html/ path.

Note:

If the Restrict document roots to public_html value is set to Off in WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings), this parameter defaults to the /username/ path. For example, the username user's subdomain example would default to the /home/username/example path.

Example: dir=/public_html/directory_name
disallowdot
integer
Default: 0

Whether to remove the dot (.) characters from the domain value.

  • 1 - Remove dots from the domain.
  • 0 - Do not remove dots from the domain.
Enum: 0 1
Example: disallowdot=1

Responses

Response Schema: application/json
apiversion
integer

The version of the API.

func
string

The name of the method called.

module
string

The name of the module called.

object

Request samples

uapi --user=username SubDomain addsubdomain domain='subdomain' rootdomain='example.com'

Response samples

Content type
application/json
{
  • "apiversion": 3,
  • "func": "addsubdomain",
  • "module": "SubDomain",
  • "result": {
    • "data": null,
    • "errors": null,
    • "messages": null,
    • "metadata": { },
    • "status": 1,
    • "warnings": null
    }
}