Updating a Zone Tutorial

Applies To:
Route

The purpose of this tutorial is to demonstrate how to perform the following updates to a zone called example.com:

A zone may be updated through the following steps:

  1. Copy your authorization token.
  2. Use the Get Zone endpoint to retrieve the entire zone.
  3. Modify the response of the Get Zone endpoint as needed.
  4. Set the request body of the Update Zone endpoint to the zone data updated in step 2.

Prerequisites

The prerequisites for this tutorial are listed below.

Step 1: Copy Your Authorization Token

Almost all requests to our REST API services require authorization. Authorization is granted by passing a REST API token via the Authorization request header using the following syntax:

TOK: REST-API-Token

Learn more.

Copy your REST API token from the Web Service REST API Token section of the My Settings page.

If the Web Service REST API Token section is not present on the My Settings page, then you are not authorized to access our REST API services. Please contact your CDN administrator to gain access.

Step 2: Retrieve a Zone

The first step is retrieving the zone that will be updated. Zone retrieval may be performed through the Get Zone endpoint.

Update the highlighted text and then perform the following GET request:

The response body for the above request will look similar to the following:

{
	"Comment" : "",
	"DomainName" : "example.com.",
	"FailoverGroups" : [],
	"LoadBalancingGroups" : [],
	"Records" : {
		"A" : [{
				"Name" : "www",
				"Rdata" : "155.11.22.33",
				"TTL" : 3600
			}, {
				"Name" : "www2",
				"Rdata" : "155.11.22.44",
				"TTL" : 3600
			}
		],
		"AAAA" : [],
		"CNAME" : [],
		"MX" : [],
		"NS" : [],
		"SPF" : [],
		"SRV" : [],
		"TXT" : []
	},
	"Status" : 1,
	"Version" : 1409100239,
	"ZoneId" : 1000,
	"ZoneType" : 1
}

Step 3: Modify your Zone

Records may be added and deleted from a zone by inserting and deleting them from the Records object. Notice the following two changes to zone data:

Change Relevant Code

An A record called "www2" has been deleted.

Lines 11 - 15 from the sample code provided above.

A CNAME record called "cdn" has been added.

Lines 14 - 18 from the sample code provided below.

Most zone data can be updated by simply adding, modifying, or deleting the desired field data from the zone. Exceptions to this rule are reserved fields which cannot be modified. These fields are: DomainName, Version, ZoneId, and ZoneType.

{
	"Comment" : "",
	"DomainName" : "example.com.",
	"FailoverGroups" : [],
	"LoadBalancingGroups" : [],
	"Records" : {
		"A" : [{
				"Name" : "www",
				"Rdata" : "155.11.22.33",
				"TTL" : 3600
			}
		],
		"AAAA" : [],
		"CNAME" : [{
				"Name" : "cdn",
				"Rdata" : "wpc.0001.edgecastcdn.net.",
				"TTL" : 3600
			}
		],
		"MX" : [],
		"NS" : [],
		"SPF" : [],
		"SRV" : [],
		"TXT" : []
	},
	"Status" : 1,
	"Version" : 1409100239,
	"ZoneId" : 1000,
	"ZoneType" : 1
}

Step 4: Update your Zone

The final step is to set the above zone data as the request body of the Update Zone endpoint.

Update the highlighted text and then perform the following PUT request:

https://api.edgecast.com/v2/mcc/customers/0001Replace this value with your CDN account number./dns/routezone

Make sure to set the request body to the zone data updated in step 2 (as shown below).

{
	"Comment" : "",
	"DomainName" : "example.com.",
	"FailoverGroups" : [],
	"LoadBalancingGroups" : [],
	"Records" : {
		"A" : [{
				"Name" : "www",
				"Rdata" : "155.11.22.33",
				"TTL" : 3600
			}
		],
		"AAAA" : [],
		"CNAME" : [{
				"Name" : "cdn",
				"Rdata" : "wpc.0001.edgecastcdn.net.",
				"TTL" : 3600
			}
		],
		"MX" : [],
		"NS" : [],
		"SPF" : [],
		"SRV" : [],
		"TXT" : []
	},
	"Status" : 1,
	"Version" : 1409100239,
	"ZoneId" : 1000,
	"ZoneType" : 1
}

The response to the above request provides confirmation that the above zone data has been successfully submitted. This response should be an exact match for the submitted zone data with the exception of the Version parameter which will be incremented to reflect that zone data has been updated.

More Information