Create DNS zone

This function creates a DNS zone. This function also adds an XDNS entry for the domain in the following locations:

  • The /var/cpanel/users/USER file, where USER represents the trueowner parameter's value.
  • The /etc/vdomainaliases/DOMAIN directory, where DOMAIN represents the new zone's domain.
  • The /etc/vfilters/DOMAIN directory, where DOMAIN represents the new zone's domain.

When you call this function, the system uses the domain name and IP address that you supply. WHM's standard zone template determines all other zone information.

This function generates the DNS zone's MX record, domain PTR, and A records automatically.

Important:

When you disable the DNS role, the system disables this function.

Authorizations:
query Parameters
domain
required
string <domain>

The new zone's domain.

Example: domain=example.com
ip
required
string <ipv4>

The domain's IP address.

Example: ip=192.168.0.20
has_ipv6
integer
Default: 0

Whether to add an IPv6 address to the new zone.

  • 1 — Add the IPv6 address in the ipv6 parameter to the new zone.
  • 0 — Do not add an IPv6 address to the new zone.
Enum: 0 1
Example: has_ipv6=1
ipv6
string <ipv6> Nullable

The domain's IPv6 address.

Example: ipv6=2001:0db8:0:0:1:0:0:1
template
string
Default: "standard"

The zone file template.

  • standard
  • simple
  • standardvirtualftp
  • The name of a custom zone template file in the /var/cpanel/zonetemplates directory.
Example: template=standard
trueowner
string <username> Nullable

The new zone's owner. This parameter defaults to the currently-authenticated user.

Example: trueowner=user

Responses

Response Schema: application/json
object

Request samples

whmapi1 --output=jsonpretty \
  adddns \
  domain='example.com' \
  ip='192.168.0.20'

Response samples

Content type
application/json
{
  • "metadata": {
    • "command": "adddns",
    • "reason": "Added example.com ok belonging to user username",
    • "result": 1,
    • "version": 1
    }
}