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
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/adddns?domain=example.com&ip=192.168.0.20
 Command Line
whmapi1 adddns domain=example.com ip=192.168.0.20 


Notes:

  • 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

Returns

This function only returns metadata.