# Create subdomain

This function creates a subdomain.

Important:

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

Endpoint: GET /SubDomain/addsubdomain
Version: 11.136.0.4
Security: BasicAuth

## Query parameters:

  - `domain` (string, required)
    The subdomain name to create.
    Example: "subdomain"

  - `rootdomain` (string, required)
    The domain on which to create the new subdomain.  The domain must already exist on the cPanel account.
    Example: "example.com"

  - `canoff` (integer)
    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

  - `dir` (string)
    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: "/public_html/directory_name"

  - `disallowdot` (integer)
    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

## Response 200 fields (application/json):

  - `apiversion` (integer)
    The version of the API.
    Example: 3

  - `func` (string)
    The name of the method called.
    Example: "addsubdomain"

  - `module` (string)
    The name of the module called.
    Example: "SubDomain"

  - `result` (object)

  - `result.data` (object,null)

  - `result.errors` (array,null)
    List of errors if the API failed.

  - `result.messages` (array,null)
    List of messages generated by the API.

  - `result.metadata` (object)

  - `result.status` (integer)
    * 1 - Success
* 0 - Failed: Check the errors field for more details.
    Enum: 0, 1

  - `result.warnings` (array,null)
    List of warnings generated by the API. Warnings describe non-critical failures or other problematic conditions noted while running a API.


