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 Zone Record — addzonerecord

This function will add a DNS zone record to the server.

Calling Functions

Using the XML API

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

  • Append the /xml-api/addzonerecord 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/addzonerecord

  • 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 addzonerecord function from within your custom script:

  • Append the /json-api/addzonerecord 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/addzonerecord

  • 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 following input variable is required for all record additions:

  • zone (string) — Name of the zone to be added, expressed like a domain name.
    • Example: example.com

The following input variables may or may not be required, depending upon the type of record being added (for more information, see the table below):

  • name (string) — The name of the zone record.
    • For example: example.com.
    • PICK Remember: This input value requires the trailing dot (.).
  • address (string) — The IP address of the zone being added.
    • Example: 127.0.0.1
  • class (string) — The class of the record.
    • note Note: This value is typically IN, for "Internet."
  • cname (string) — The canonical name in a CNAME record.
  • exchange (string) — In an MX record, the name of the destination mail server.
  • nsdname (string) — A domain name to use for a nameserver. Example: ns1.example.com
  • ptrdname (string) — The domain to which the IP address will point.
  • priority (integer) — In an MX record, this parameter specifies the priority of the destination mail server.
    • note Note: 0 is the highest priority.
    • note Note: You should enter this data as user.example.com rather than user@example.com.
  • type (string) — The type of zone record being added.
    • Example: A, CNAME, NS, etc.
  • ttl (integer) — The record's time to live.

You must use the following 4 parameters when adding an SRV record:

  • priority (integer) — The overall priority for the SRV record.
  • weight (integer) — The weight of the record, relative to records of the same priority.
  • port (integer) — The port number on which users can access a particular service.
  • target (string) — The hostname of the machine providing a specified service.

Common record types and associated input variables

For your reference when assembling the zone record to add, here are a few common record types and their associated input variables.

Record type Required variables Optional variables
A zone, address, type class, ttl
MX zone, name, exchange, priority, type class, ttl
CNAME zone, cname, type class, ttl
NS zone, nsdname, type class, ttl
PTR zone, name, ptrdname, type ttl
SRV priority, weight, port, target domain, name, type, ttl

Output

  • addzonerecord — Root-level XML tag for the output of the addzonerecord function.
    • result — Container for the results of the function.
      • status (boolean) — Status of the request.
        • 1 — true.
        • 0 — false.
      • statusmsg (string) — Additional information from the server about the addition of the DNS zone.

Examples

XML API

Calling https://example.com:2087/xml-api/addzonerecord?zone=example.com&name=example.com.&address=127.0.0.1&type=A&class=IN in WebHost Manager will produce output similar to:

<addzonerecord>
    <result>
        <status>1</status>
        <statusmsg>Bind reloading on host using rndc zone: [example.com]</statusmsg>
    </result>
</addzonerecord>

JSON API

Calling https://example.com:2087/json-api/addzonerecord?zone=example.com&name=example.com.&address=127.0.0.1&type=A&class=IN in WebHost Manager will produce output similar to:

{ "result" : [ { "status" : 1,
        "statusmsg" : "Bind reloading on host using rndc zone: [example.com]\n"
      } ] }

Topic revision: r12 - 07 Aug 2013 - 16:43:56 - Main.ShavaunTesareski