v1

latestOpenAPI 3.0.2cPanel License2026-08-06657427.1 MB
SubDomain

Create subdomain

This function creates a subdomain.

Important:

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

get/SubDomain/addsubdomain

Query parameters

domainstring required
Example:subdomain

The subdomain name to create.

rootdomainstring domain required
Example:example.com

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

canoff0 | 1
Example: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.
dirstring path
Example:/public_html/directory_name

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.

disallowdot0 | 1
Example:1

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

  • 1 - Remove dots from the domain.
  • 0 - Do not remove dots from the domain.

Response

HTTP Request was successful.

apiversioninteger

The version of the API.

funcstring

The name of the method called.

modulestring

The name of the module called.

Example response

{
  "apiversion": 3,
  "func": "addsubdomain",
  "module": "SubDomain",
  "result": {
    "status": 1
  }
}