API: DNS
The DNS API is used to manage zones, which are served by the VSHN DNS infrastructure.
Please make sure to read the API Basics document before starting.
The current implementation can’t catch all possible illegal zone modifications. If you perform an incorrect operation, the CI job deploying the zone may fail. More input validation may be added in the future. |
- Base URL
Fields: Record
Name | Type | Required | Description | Example Values |
---|---|---|---|---|
name |
String |
yes, except update |
Canonical DNS name with a trailing '.' |
|
ttl |
String |
no |
This record’s TTL. |
|
cls |
String |
no |
This record’s class. Only allowed value is "IN" |
|
type |
String |
yes, except update |
This record’s type. All types per bind zone file spec, plus "ALIAS" |
|
data |
String[] |
yes |
Data of this record. |
|
dataComments |
String[] |
no |
Comments for data of this record. Must have same length as data array, padded with null. |
|
comment |
String |
no |
Comment for the entire record |
|
Methods
GET /
List all zones you have access to.
$ curl -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/
example.com
example.net
example-test.co.uk
GET /{zoneId}
Get the full zone in bind format.
$ curl -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com
$ORIGIN example.com.
$TTL 3600
@ IN SOA (
ns1.example.com.
dnsadmin.example.com.
1 ; SERIALAUTOUPDATE
3600
600
1209600
3600
)
;
; Nameserver
;
@ IN NS ns1.example.com.
@ IN NS ns2.example.net.
@ IN ALIAS lb1.example.com.
www IN CNAME lb1.example.com.
lb1 IN A 1.2.3.4
GET /{zoneId}/
Get a list of record types contained in the zone.
$ curl -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/
A
ALIAS
CNAME
NS
SOA
GET /{zoneId}/{type}/
Get a list of record names of the given type.
$ curl -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/CNAME/
www.example.com.
GET /{zoneId}/{type}/{name}
Get the specified records in JSON format. This returns a list of records, because there can be more than one record per type/name combination (although in most cases there will be only one).
$ curl -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/CNAME/www.example.com.
[ {
"name" : "www.example.com.",
"cls" : "IN",
"type" : "A",
"data" : [ "1.2.3.4" ]
} ]
GET /{zoneId}/{type}/{name}/
Get the list of records that match this type and name.
$ curl -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/NS/example.com./
0
1
2
GET /{zoneId}/{type}/{name}/{nr}
Get a single record.
$ curl -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/NS/example.com./1
{
"name" : "example.com.",
"cls" : "IN",
"type" : "NS",
"data" : [ "ns1.example.com." ]
}
POST /{zoneId}/
Create new record. Send data as JSON in the request body. The portal will automatically put the new record in a suitable origin, or create a new origin if required.
$ curl -X POST -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/ -d '{"name":"www2.example.com.", "type":"A", "data":["5.6.7.8"]}'
PUT /{zoneId}/{type}/{name}/{nr}
Update an existing record. Send data as JSON in the request body. You can’t change the type or name of a record; these values will be taken from the URL, and they will be ignored if they’re present in the request body.
$ curl -X PUT -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/A/www2.example.com./0 -d '{"data":["11.22.33.44"]}'
DELETE /{zoneId}/{type}/{name}/{nr}
Delete an existing record.
$ curl -X DELETE -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/A/www2.example.com./0
DELETE /{zoneId}/_/{name}
Clean up a host name. This removes:
-
All records of the given name, regardless of type
-
CNAMEs pointing to that name
This is useful when decommissioning a server. More features may be added in the future.
$ curl -X DELETE -H "X-AccessToken: [...]" https://control.vshn.net/api/dns/1/example.com/_/www2.example.com.