Create subdomain

This function creates a subdomain.

SecurityBasicAuth
Request
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
200

HTTP Request was successful.

Response Schema: application/json
object
object
get/create_subdomain
Request samples
whmapi1 --output=jsonpretty \
  create_subdomain \
  domain='subdomain.example.com' \
  document_root='public_html/directory_name'
Response samples
application/json
{
  • "data": {
    • "username": "example"
    },
  • "metadata": {
    • "command": "create_subdomain",
    • "reason": "OK",
    • "result": 1,
    • "version": 1
    }
}