CDNShark Documentation

Customer API

← Back to Documentation

DNS API

Read and change the DNS records of your domains' zones. Changes are live on CDNShark's nameservers within seconds. Needs an active paid service.

List zones

GET /api/dns (dns:read) returns {"data": [{"id", "name", "type", "disabled", "dnssec_status", "created_at"}]}.

List records

GET /api/dns/{zone} (dns:read), for example /api/dns/example.com. Returns {"data": [record, ...]}. Record names are relative to the zone: @ is the apex, www is www.example.com.

Add a record

POST /api/dns/{zone}/records (dns:write)

FieldRequiredNotes
nameyes@ for the apex, a label (www), or the full name (www.example.com).
typeyesA, AAAA, CNAME, MX, TXT, NS, CAA, SRV, PTR
valueyesThe record data. See the per-type table below.
ttlnoSeconds, 60 to 86400. Default 3600.
priorityMX, SRVMX preference (default 10), or SRV priority.
weight, portSRVSRV weight and port. value is the target host.
isproxynotrue sends traffic for an A, AAAA or CNAME record through the CDNShark CDN instead of straight to value, which becomes the origin.
TypeExample value
A / AAAA203.0.113.10 / 2001:db8::10
CNAMEtarget.example.net
MXmail.example.com (with "priority": 10)
TXTv=spf1 include:_spf.example.net ~all (long DKIM keys are fine)
CAA0 issue "letsencrypt.org"
SRVsip.example.com (with priority, weight, port)
curl -X POST https://cdnshark.com/api/dns/example.com/records \
  -H "Authorization: Bearer YOUR_TOKEN" -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"name": "www", "type": "A", "value": "203.0.113.10", "ttl": 300}'

Returns 201:

{
  "message": "A record added successfully!",
  "record": { "zone": "example.com", "name": "www", "type": "A", "value": "203.0.113.10", "ttl": 300 }
}

If the DNS server refuses the change, you get 422 with its reason in message.

Change a record

PUT /api/dns/{zone}/records (dns:write). Identify the record by name, type and its current value, then give the new value.

FieldRequiredNotes
name, typeyesAs above.
old_valueyesThe record's current value.
valueyesThe new value.
ttlnoNew TTL.
curl -X PUT https://cdnshark.com/api/dns/example.com/records \
  -H "Authorization: Bearer YOUR_TOKEN" -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"name": "www", "type": "A", "old_value": "203.0.113.10", "value": "203.0.113.20"}'

Returns 200 with message and record. The older field names ip_old and ip_new still work.

Delete a record

DELETE /api/dns/{zone}/records (dns:write) with name, type and value in the body. Returns 200 {"message": "..."}. Records CDNShark relies on (for example nameserver records) are protected and cannot be deleted (422).