Update a DNS zone

This function updates a given DNS zone. It can add, edit, and remove many records in a single call. It also ensures that each record not removed will occupy the same number of lines after the edit as it did before the edit.

Authorizations:
query Parameters
serial
required
integer >= 0
Example: serial=202001010100

The current serial number in the DNS zone’s SOA (Start of Authority) record. If this value does not match the zone’s current state, the request fails.

zone
required
string
Example: zone=example.com

The name of one of the user’s DNS zones.

add
Array of strings <json>
Examples:
An A record.
add='{"dname":"example", "ttl":14400, "record_type":"A", "data":["11.22.33.44"]}'
A TXT record.
add='{"dname":"example", "ttl":14400, "record_type":"TXT", "data":["string1", "string2"]}'

The records to add to the zone. Each item must be a serialized JSON object that contains:

  • dname — The record’s name.
  • ttl — The record’s TTL (Time-To-Live) value.
  • record_type — The record’s type. For example, A or TXT.
  • data — An array of strings. The format and number of the strings depend on the record_type value.
edit
Array of strings <json>
Example: edit='{"line_index": 9, "dname":"example", "ttl":14400, "record_type":"TXT", "data":["string1", "string2"]}'

The records to edit in the zone. Each item must be a serialized JSON object that contains:

  • line_index — The line number in the DNS zone where the record starts. This is a 0-based index, so to edit the first line in the file use the 0 value. To edit the second line, give 1, and so forth.
  • dname — The record’s name.
  • ttl — The record’s TTL (Time-To-Live) value.
  • record_type — The record’s new type. For example, A or TXT.
  • data — An array of strings. The format and number of the strings depend on the record_type value.
remove
Array of integers
Example: remove=22

The line indexes of records to remove from the zone.

Responses

Response Schema: application/json
apiversion
integer

The version of the API.

func
string

The name of the method called.

module
string

The name of the module called.

object

Request samples

uapi --user=username DNS mass_edit_zone zone='example.com' serial='202001010100' remove=23 add='{"dname":"example","ttl":14400,"record_type":"A","data":["127.0.0.1"]}'

Response samples

Content type
application/json
{
  • "apiversion": 3,
  • "func": "mass_edit_zone",
  • "module": "DNS",
  • "result": {
    • "data": {
      • "new_serial": 2021031903
      },
    • "errors": null,
    • "messages": null,
    • "metadata": {
      • "transformed": 1
      },
    • "status": 1,
    • "warnings": null
    }
}