Domains and DNS
DNS
Read and change the DNS records of a domain, tune its SOA and run diagnostics.
Everything here works on one domain at a time. The paths start with /v2/cdn/dns/{domain_public_id}/, where the id is the public id of the domain, taken from the domains list.
The examples on this page use these shell variables:
export DIAMWALL_API_KEY="your key"export DNS="https://api.diamwall.com/v2/cdn/dns/your-domain-public-id"Records
Section titled “Records”What a record is made of
Section titled “What a record is made of”this record servesshop.example.com
The value changes shape with the type. Numbers are sent as numbers, never as strings, and a field the type does not have is refused.
type |
value |
|---|---|
a, aaaa |
A string: an IPv4 or IPv6 address |
cname, ns, ptr |
A string: a hostname |
alias |
A string: a relative name, with no wildcard |
txt, spf |
A string: the text, not empty, at most 16 KiB |
mx |
An object with destination and priority |
srv |
An object with target, port, priority and weight |
caa |
An object with flag, tag and value |
tlsa |
An object with usage, selector, matching_type and certificate |
ds |
An object with key_tag, algorithm, digest_type and digest |
https, svcb |
An object with priority and target, and optionally alpn, no_default_alpn, port, ipv4hint and ipv6hint |
Writes need the latest revision
Section titled “Writes need the latest revision”Two people editing the same zone must not overwrite each other. So every create, edit and delete has to prove it saw the latest state of the records.
- Read
GET .../records/The answer carries an ETag header: the revision of the whole set of records.
- Send it back
If-Match: <that ETag>Put it on the create, edit or delete, exactly as it came.
- Check the answer
- 2xx
- Written. Keep the new ETag for the next write.
- 412
- The records changed since your read. Read again and retry.
- 428
- The If-Match header is missing.
List the records
Section titled “List the records”curl "$DNS/records/?limit=50" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY"{ "revision": "sha256:c8dda7bd8cfc...", "data": { "items": [ { "id": "6064981d2b888b2e7074", "name": "@", "type": "a", "value": "203.0.113.10", "proxied": true, "ttl": 300 } ], "page": { "limit": 50, "next_cursor": "eyJyIjoic2hhMjU2...", "total": 23 } }}limitgoes from 1 to 100. Without it a page holds 50 records.- To read the next page, send
data.page.next_cursorback ascursor, until it isnull. data.page.totalis the number of records in the whole zone.- If a record changes between two pages, the next page answers
409 CURSOR_STALE. Start again from the first page.
Add a record
Section titled “Add a record”Read the records first to get the ETag, then send it in If-Match:
ETAG=$(curl -s -o /dev/null -D - "$DNS/records/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ | tr -d '\r' | awk 'tolower($1) == "etag:" { print $2 }')curl -X POST "$DNS/records/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "If-Match: $ETAG" \ -d '{ "name": "shop", "type": "a", "value": "203.0.113.20", "proxied": true, "ttl": 300 }'curl -X POST "$DNS/records/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "If-Match: $ETAG" \ -d '{ "name": "@", "type": "mx", "value": { "destination": "mail.example.com.", "priority": 10 }, "ttl": 3600 }'curl -X POST "$DNS/records/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "If-Match: $ETAG" \ -d '{ "name": "_dmarc", "type": "txt", "value": "v=DMARC1; p=none" }'The answer is 201 with the new record under data, and a new ETag header to use on your next write.
Change a record
Section titled “Change a record”Send only the fields that change. A field you leave out keeps its value, and value is always sent whole.
curl -X PATCH "$DNS/records/6064981d2b888b2e7074/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "If-Match: $ETAG" \ -d '{ "ttl": 600 }'An empty body answers 400 NO_CHANGES.
Delete a record
Section titled “Delete a record”curl -X DELETE "$DNS/records/6064981d2b888b2e7074/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "If-Match: $ETAG"The zone always keeps at least one valid ns record at @. An edit or delete that would remove the last one answers 409 DNS_APEX_NS_REQUIRED and writes nothing.
The SOA record of the zone has nine fields: contact, mname, serial and six timings (ttl, soa_ttl, refresh, retry, expire, negttl).
curl "$DNS/settings/soa/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY"Each field comes back as { "state": "resolved", "value": ... }. A state of unknown means the CDN could not tell. Treat it as unavailable, never as 0 or false.
There are three ways to change the SOA:
| You want to | Call | Header it needs |
|---|---|---|
| Apply a ready-made set of timings | POST .../actions/soa-apply-profile/ |
Idempotency-Key |
| Set individual timings | PATCH .../settings/soa/ |
If-Match |
| Make secondary name servers fetch the zone again | POST .../actions/soa-bump-serial/ |
Idempotency-Key |
Apply a profile
Section titled “Apply a profile”The profiles are low-latency, balanced, high-cache and migration. GET .../references/soa-profiles/ lists the timings each one applies. A profile never changes contact, mname or serial.
curl -X POST "$DNS/actions/soa-apply-profile/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: soa-profile-2026-11-22-a1" \ -d '{ "profile": "balanced" }'Set individual timings
Section titled “Set individual timings”Read settings/soa/ to get its ETag, then send at least one of the six timings:
curl -X PATCH "$DNS/settings/soa/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "If-Match: $SOA_ETAG" \ -d '{ "refresh": 3600, "negttl": 120 }'The allowed range of each timing is in the reference entry for this endpoint.
Raise the serial
Section titled “Raise the serial”The body is exactly {}. A serial that was raised does not come back down, so do not repeat the request to make sure. The answer tells you what happened.
curl -X POST "$DNS/actions/soa-bump-serial/" \ -H "Authorization: Api-Key $DIAMWALL_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: soa-serial-2026-11-22-b7" \ -d '{}'Diagnostics
Section titled “Diagnostics”| Diagnostic | What it answers | Cost |
|---|---|---|
GET .../diagnostics/dns-nameservers/ |
The name servers the domain is delegated to, in data.nameservers |
8 credits |
GET .../diagnostics/dns-all/ |
A lookup of the domain itself and of 39 common subdomains | 120 credits |
Zone settings
Section titled “Zone settings”GET .../settings/dns/ is read-only. It answers three things about the zone as a whole:
dnssec_enabled: whether DNSSEC is on.records: the published zone, as a map from name to record type.proxied_records: the names known to be proxied. The list may be incomplete.
Limits and permissions
Section titled “Limits and permissions”- Credits. Each domain has a budget of 3000 credits a minute, shared by everyone who calls the API for that domain. A DNS call costs 8 credits. Creating a record costs 16 on the Pro and Business plans, because the plan’s record limit is read first.
dns-allcosts 120. - Out of credits. The call answers
429 TOO_MANY_REQUESTS, with the wait indetails.retry_after_seconds. - Record limit. A create beyond the plan’s limit answers
400 PLAN_LIMIT_EXCEEDED, withdetails.limitanddetails.current. - Permissions. Reads need
dns.viewon the domain. Writes needdns.create,dns.editordns.delete.
Errors you are likely to see
Section titled “Errors you are likely to see”| Status | Code | What happened |
|---|---|---|
400 |
INVALID_REQUEST |
A field is wrong. The answer names it in fields. |
400 |
NO_CHANGES |
An edit was sent with nothing to change. |
400 |
PLAN_LIMIT_EXCEEDED |
The zone is at the record limit of its plan. |
404 |
RESOURCE_ITEM_NOT_FOUND |
No record has that id. |
409 |
CURSOR_STALE |
The records changed while you were paging. Start from the first page. |
409 |
RESOURCE_CONFLICT |
There is already a proxied record at that name. |
409 |
DNS_APEX_NS_REQUIRED |
The write would remove the last name server of the domain. |
412 |
REVISION_MISMATCH |
The records changed since your read. Read again and retry. |
428 |
The If-Match header is missing. |
|
429 |
TOO_MANY_REQUESTS |
The domain is out of credits for now. |
The errors that come from the key itself, such as API_KEY_IP_NOT_ALLOWED, are on the Errors page.
All DNS endpoints
Section titled “All DNS endpoints”Each row opens the endpoint in the API reference, with every parameter, rule and response.
Loading the endpoints...