API Queries - Add DNS Record
The add_dns API function creates a new DNS record for a domain. Supported record types are: A, AAAA, CAA, CNAME, MX, NS, SRV, TXT. Additional parameters are required for this function.
Additional Parameters
- domain - Domain name to add the record to. Note: http://www. should not be included.
- type - The DNS record type. Must be one of: A, AAAA, CAA, CNAME, MX, NS, SRV, TXT.
- hostName - The hostname for the record. Use "@" or leave blank for the root domain, or specify a subdomain (e.g. "blog" for blog.example.com).
- value - The record value/content (e.g. an IP address for A records, a hostname for CNAME records).
- ttl - Time to live in seconds.
- priority - Priority value. Required for MX and SRV records (e.g. 10, 20, 30).
- weight - Weight value. Required for SRV records only.
- port - Port number. Required for SRV records only.
- flag - Flag value between 0 and 128. Required for CAA records only.
- tag - Tag value: "issue", "issuewild", or "iodef". Required for CAA records only.
Your API key is required and all values should be correctly URL encoded.
Example
In the below example, we will add an A record for "blog.oranges.com" pointing to "192.168.1.1" with a TTL of 3600 seconds (domain=oranges.com&type=A&hostName=blog&value=192.168.1.1&ttl=3600).
Query
https://www.above.com/registrar/api/query.html?query=add_dns&domain=oranges.com&type=A&hostName=blog&value=192.168.1.1&ttl=3600
Use Registrar API key in place of {BEARER_TOKEN}
Response
<results code="100" />
Example 2
There are various possible errors when adding a DNS record. In this example, we will attempt to add an A record for "blog.oranges.com" with an invalid value of "invalid" (domain=oranges.com&type=A&hostName=blog&value=invalid). As the value is not a valid IPv4 address, the request will fail.
Query
https://www.above.com/registrar/api/query.html?query=add_dns&domain=oranges.com&type=A&hostName=blog&value=invalid
Use Registrar API key in place of {BEARER_TOKEN}
Response
<results code="1003"> <msg>Failed to validate the DNS record details.</msg> </results>
Error Codes
Possible error responses for this function are:
- 509 - Specified domain is not in your account
- 510 - Domain not specified or invalid domain
- 512 - Domain extension must be specified
- 1003 - Failed to validate the DNS record details
- General errors, such as 401 - Invalid API key or 500 - System unavailable.
