This article provides examples of how to create new CNAME records using the UltraDNS REST API.
Examples are provided in raw HTTP, cURL, and Python Requests formats.
When to Use This Article
- You need to create a CNAME record using the UltraDNS REST API.
- You want working examples in HTTP, cURL, or Python Requests.
- You are automating DNS record creation for a zone in UltraDNS.
Examples of How to Create New CNAME's
HTTP
POST /zones/ultrasupport.co./rrsets/cname/cname2-example.ultrasupport.co. HTTP/1.1
Host: api.ultradns.com
Authorization: Bearer REMOVED
Content-Type: application/json
{"ttl":86400,"rdata":[www.cname-destination.com]}
cURL
curl --location 'https://api.ultradns.com/zones/ultrasupport.co./rrsets/cname/cname2-example.ultrasupport.co.' \
--header 'Authorization: Bearer REMOVED' \
--header 'Content-Type: application/json' \
--data '{"ttl":86400,"rdata":[www.cname-destination.com]}'
Python Requests
import requests
import json
url = https://api.ultradns.com/zones/ultrasupport.co./rrsets/cname/cname2-example.ultrasupport.co.
payload = json.dumps({
"ttl": 86400,
"rdata": [
www.cname-destination.com
]
})
headers = {
'Authorization': 'Bearer REMOVED',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Verification
After submitting the request, confirm the record exists by retrieving the rrset through the API or by querying DNS resolution after the change is active.
Important Notes
- The Authorization header must contain a valid bearer token.
- The zone name and owner name must match the record you intend to create.
- Ensure the record data is valid for a CNAME record before submitting the request.