Skip to content
Dashboard

Domains and DNS

View as Markdown

DNS

Read and change the DNS records of a domain, tune its SOA and run diagnostics.

203.0.113.20203.0.113.21@wwwapi*

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"

this record servesshop.example.com

nameshopRelative to the domain. @ is the domain itself, * a wildcard.
typeaOne of 15 types, in lower case.
value203.0.113.20Its form depends on the type. Always sent whole.
proxiedoptionaltrueOnly on a and cname. Left out, the CDN decides.
ttloptional300Seconds, 60 to 86400.

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

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.

  1. ReadGET .../records/

    The answer carries an ETag header: the revision of the whole set of records.

  2. Send it backIf-Match: <that ETag>

    Put it on the create, edit or delete, exactly as it came.

  3. 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.
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 }
}
}
  • limit goes from 1 to 100. Without it a page holds 50 records.
  • To read the next page, send data.page.next_cursor back as cursor, until it is null.
  • data.page.total is 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.

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
}'

The answer is 201 with the new record under data, and a new ETag header to use on your next write.

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.

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

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" }'

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.

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 '{}'
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

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.
  • 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-all costs 120.
  • Out of credits. The call answers 429 TOO_MANY_REQUESTS, with the wait in details.retry_after_seconds.
  • Record limit. A create beyond the plan’s limit answers 400 PLAN_LIMIT_EXCEEDED, with details.limit and details.current.
  • Permissions. Reads need dns.view on the domain. Writes need dns.create, dns.edit or dns.delete.
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.

Each row opens the endpoint in the API reference, with every parameter, rule and response.

Loading the endpoints...