Create subdomain

This function creates a subdomain.

Authorizations:
query Parameters
document_root
required
string

The subdomain's document root within the home directory.

Note:

  • An invalid document root path will cause this function to fail.
  • If the Restrict document roots to public_html value is set to On in WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings), this parameter must begin with the public_html/ path. For more information, read the cpanel.config file documentation.
Example: document_root=public_html/directory_name
domain
required
string <domain>

The subdomain name to create.

Example: domain=subdomain.example.com
use_canonical_name
integer
Default: 0

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

  • 1 — Use the canonical name.
  • 0 — Do not use the canonical name.
Enum: 0 1
Example: use_canonical_name=0

Responses

Response Schema: application/json
object
object

Request samples

whmapi1 --output=jsonpretty \
  create_subdomain \
  domain='subdomain.example.com' \
  document_root='public_html/directory_name'

Response samples

Content type
application/json
{
  • "data": {
    • "username": "example"
    },
  • "metadata": {
    • "command": "create_subdomain",
    • "reason": "OK",
    • "result": 1,
    • "version": 1
    }
}