Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function creates a DNS zone. 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.

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
whmapi0 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 0 documentation or run the whmapi0 --help command. 
  • We introduced this functionality in cPanel & WHM version 11.52.0.8.

 Output (JSON)
{
   "result":[
      {
         "status":1,
         "statusmsg":"Added example.com ok belonging to user1"
      }
   ]
}
 Output (XML)
<adddns>
     <result>
          <status>1</status>
          <statusmsg>Added example.com ok belonging to user username</statusmsg>
   </result>
</adddns>

   

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.

A valid cPanel or WHM username.

user

 

Returns

ReturnTypeDescriptionPossible valuesExample
resulthashA hash of function status information.This hash contains the status and statusmsg returns. 

status

Boolean

Whether the function succeeded.

The function returns this value in the result hash.

  • 1 — Success.
  • 0 — Failure.
1

statusmsg

string

A message of success or a reason for failure.

The function returns this value in the result hash.

  • Added example.com ok belonging to user
  • An error message.

Added example.com ok belonging to user