Add Zone Record — addzonerecord

This function is only available in WHM 11.25 and later.

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 folliowing 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
  • preference (integer) — In an MX record, the priority of the destination mail server.
    • note Note: 0 is the highest priority.
    • note Note: The data should be entered 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.

Common record types and associated input variables

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

Record type Required variables Optional variables
A zone, address, type class, ttl
MX zone, exchange, preference, type class, ttl
CNAME zone, cname, type class, ttl
NS zone, nsdname, type class, 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 in WebHost Manager will produce output similar to:

<addzonerecord>
     <result>
            <status>1</status>
            <statusmsg>Wrote zone file.</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 in WebHost Manager will produce output similar to:

{
   "result":[
      {
         "status":1,
         "statusmsg":"Wrote zone file."
      }
   ]
}

Topic revision: r4 - 11 Nov 2009 - 21:51:49 - Main.JustinSchaefer
 

Copyright © cPanel 2000-2009.