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)
| Field | Required | Notes |
|---|---|---|
name | yes | @ for the apex, a label (www), or the full name (www.example.com). |
type | yes | A, AAAA, CNAME, MX, TXT, NS, CAA, SRV, PTR |
value | yes | The record data. See the per-type table below. |
ttl | no | Seconds, 60 to 86400. Default 3600. |
priority | MX, SRV | MX preference (default 10), or SRV priority. |
weight, port | SRV | SRV weight and port. value is the target host. |
isproxy | no | true sends traffic for an A, AAAA or CNAME record through the CDNShark CDN instead of straight to value, which becomes the origin. |
| Type | Example value |
|---|---|
| A / AAAA | 203.0.113.10 / 2001:db8::10 |
| CNAME | target.example.net |
| MX | mail.example.com (with "priority": 10) |
| TXT | v=spf1 include:_spf.example.net ~all (long DKIM keys are fine) |
| CAA | 0 issue "letsencrypt.org" |
| SRV | sip.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.
| Field | Required | Notes |
|---|---|---|
name, type | yes | As above. |
old_value | yes | The record's current value. |
value | yes | The new value. |
ttl | no | New 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).