Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Add a DNS Zone — adddns

This function creates a DNS zone. All zone information other than domain name and IP address is created based on the standard zone template in WHM. (To edit that template, go to: https://YOURIP:2087/scripts2/editzonetemplate?template=standard) Your MX, nameserver, domain PTR, and A records will all be generated automatically.

Calling Functions

Using the XML API

To use the XML API to perform the adddns function from within your custom script:

  • Append the /xml-api/adddns function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/adddns

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the adddns function from within your custom script:

  • Append the /json-api/adddns function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/adddns

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The adddns function takes the following required variables as input:

  • domain (string) — Domain name for the zone that will be added.
  • ip (string) — IP address associated with the domain name.

The following parameters are optional. These parameters are only available in cPanel & WHM 11.28 and later:

  • template (string) — The template file you wish to use. If you wish to use a custom template you must place it in /var/cpanel/zonetemplates and specify the name of the template in this parameter. In addition to custom templates, you may also use one of the following templates provided with cPanel/WHM:
    • standard (default) — The default zone template. Use this value if you wish to create zone files for typical domains, or parked or addon domains.
    • simple — Use this value if you are only adding A entries.
    • standardvirtualftp — Use this value if you wish to specify an IP address for a virtual FTP server.
  • trueowner (string) — The username that will own the DNS zone.

Output

  • adddns — Root-level XML tag for the output of the adddns function.
    • result — Container for the results of the DNS zone addition.
      • status (boolean) — Status of the deletion request.
        • 1 — success.
        • 0 — failure.
      • statusmsg (string) — Information about the status of the request.

Examples

XML API

Calling https:example.com:2087/xml-api/adddns?domain=example.com&ip=1.2.3.4&template=standard&trueowner=user1 in WebHost Manager will produce results similar to:

<adddns>
     <result>
          <status>1</status>
          <statusmsg>Added example.com ok belonging to user user1</statusmsg>
   </result>
</adddns>

JSON API

Calling https:example.com:2087/json-api/adddns?domain=example.com&ip=1.2.3.4&template=standard&trueowner=user1 in WebHost Manager will produce results similar to:

{
   "result":[
      {
         "status":1,
         "statusmsg":"Added example.com ok belonging to user1"
      }
   ]
}

Topic revision: r10 - 08 Feb 2011 - 18:50:57 - Main.JustinSchaefer