We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Child pages
  • WHM API 1 Functions - adddns
Skip to end of metadata
Go to start of metadata

Description

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:

In cPanel & WHM version 76 and later, when you disable the DNS role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/adddns?domain=example.com&ip=192.168.0.20&has_ipv6=1&ipv6=2001%3A0db8%3A0%3A0%3A1%3A0%3A0%3A1
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/adddns?domain=example.com&ip=192.168.0.20&has_ipv6=1&ipv6=2001%3A0db8%3A0%3A0%3A1%3A0%3A0%3A1
 Command Line
whmapi1 adddns domain=example.com ip=192.168.0.20 has_ipv6=1 ipv6=2001%3A0db8%3A0%3A0%3A1%3A0%3A0%3A1


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
  "metadata": {
    "version": 1,
    "reason": "Added example.com ok belonging to user username",
    "result": 1,
    "command": "adddns"
  }
}
 Output (XML)
<result>
    <metadata>
        <version>1</version>
        <reason>Added example.com ok belonging to user username</reason>
        <result>1</result>
        <command>adddns</command>
    </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
domainstring

Required

The new zone's domain.

A valid domain name on the server.example.com
ipstring

Required

The domain's IP address.

A valid IP address.192.168.0.20
templatestring

The zone file template.

If you do not use this parameter, the function uses the standard zone file template.

  • standard
  • simple
  • standardvirtualftp
  • The name of a custom zone template file in the /var/cpanel/zonetemplates directory.
standard
trueownerstring

The new zone's owner.

This parameter defaults to the currently-logged in cPanel or WHM user's username.

A valid cPanel or WHM username.

user
has_ipv6Boolean

Whether to add an IPv6 address to the new zone.

Note:

We added this parameter in cPanel & WHM version 11.44.

This parameter defaults to 0.

  • 1 — Add the IPv6 address in the ipv6 parameter to the new zone.
  • 0 — Do not add an IPv6 address to the new zone.
1
ipv6string

The domain's IPv6 address.

Note:

We added this parameter in cPanel & WHM version 11.44.

This parameter default to null.

A valid IPv6 address.2001:0db8:0:0:1:0:0:1

Returns

This function only returns metadata.