Skip to content

DNS Records

DNS records live inside a zone and map names to values. The b'nerd DNS API supports all standard record types and exposes both a native API and a PowerDNS-compatible proxy for tools like external-dns.

Endpoints

Method Path Description
GET /dns/zones/{zone_id}/records List records in a zone
POST /dns/zones/{zone_id}/records Create a record
PATCH /dns/zones/{zone_id}/records/{name}/{type} Update a record
DELETE /dns/zones/{zone_id}/records/{name}/{type} Delete a record

List records

GET /dns/zones/{zone_id}/records?organization_id=<uuid>
Authorization: Bearer <token>

Returns all records in the zone as an array.

Create a record

POST /dns/zones/{zone_id}/records?organization_id=<uuid>
Authorization: Bearer <token>
Content-Type: application/json

{
  "name": "www",
  "type": "A",
  "ttl": 300,
  "content": "203.0.113.10"
}

Returns 201 Created with an empty data object (PowerDNS answers a record change without a body); read the record back with GET /dns/zones/{zone_id}/records.

A record set is the name plus the type, and it can hold several values (for example two A records for the same name). Creating adds to the set; values already in it stay, with their disabled flag. To add several values in one request, send records instead of content:

{ "name": "www", "type": "A", "records": [{ "content": "203.0.113.10" }, { "content": "203.0.113.11" }] }
  • Send content or records (up to 100 entries). With neither, or with an entry that has no content, the request is refused with 422 validation_failed. If you send both, content wins and records is ignored.
  • A value that is already in the set is refused with 409 record_exists; nothing is written. The same code is returned if records lists a value twice.
  • A record set has one ttl. It is an integer from 1 to 2147483647; anything else is a 422. Send ttl to set it for the whole set. If you omit it, an existing set keeps its ttl and a new set gets 3600.
  • Name and type match an existing set regardless of case. A name without the zone suffix is completed with it; a blank name or @ is the zone apex.
  • New values are always enabled; disabled cannot be set here.
  • A content or previous_content that is not a non-empty string (an array, a number) is a 422.
  • The ttl may also be a string of digits ("300"); anything else that is not an integer from 1 to 2147483647 is a 422.
  • The name of a new set is stored in lower case.

CLI equivalent

bnerd dns records create <zone-id> --name www --type A --ttl 300 --content 203.0.113.10

Common record types

Type content format Example
A IPv4 address 203.0.113.10
AAAA IPv6 address 2001:db8::1
CNAME Fully qualified domain name target.example.com.
MX Priority + FQDN 10 mail.example.com.
TXT Quoted string "v=spf1 include:_spf.example.com ~all"
NS Nameserver FQDN ns1.bnerd.cloud.
SRV Priority weight port target 10 20 443 sip.example.com.
CAA Flags tag value 0 issue "letsencrypt.org"

Trailing dots

For record types where content is a domain name (CNAME, MX, NS, SRV), use a fully qualified domain name with a trailing dot to prevent the zone name being appended automatically.

Update a record

PATCH /dns/zones/{zone_id}/records/www/A?organization_id=<uuid>
Authorization: Bearer <token>
Content-Type: application/json

{
  "ttl": 60,
  "content": "203.0.113.20"
}

Returns 200 OK with an empty data object. Read the record back with GET /dns/zones/{zone_id}/records.

The record set is named by the path; a name or type in the body is ignored, so an update cannot rename a record. An update never creates a record: if the zone or the name and type does not exist, you get 404. There are two forms:

  • content replaces one value and keeps every other value with its disabled flag; the replaced value keeps its own disabled flag too. If the set has several values, name the one to replace with previous_content (exactly as GET returns it):

    { "previous_content": "203.0.113.10", "content": "203.0.113.20" }
    

    Without previous_content on a set with several values, the request is refused with 409 record_value_ambiguous. If previous_content is not in the set, you get 404. If the new value is already in the set, you get 409 record_exists. On a single-value set previous_content is optional. - records states the whole new set (up to 100 entries): values you do not list are removed, and values already in the set keep their disabled flag. A value listed twice is refused with 409 record_exists.

If you send both, content wins. With neither, the request is refused with 422 validation_failed.

ttl is the ttl of the whole set. If you omit it, the set keeps its current ttl; it is never reset to a default. A ttl that is not an integer from 1 to 2147483647 is a 422.

CLI equivalent

bnerd dns records update <zone-id> www A --content 203.0.113.20 --ttl 60

Delete a record

DELETE /dns/zones/{zone_id}/records/www/A?organization_id=<uuid>
Authorization: Bearer <token>

Returns 204 No Content. Without content this removes the whole record set of that name and type, every value. It is idempotent: a name and type that does not exist also returns 204.

To remove one value from a set, pass it as the content query parameter, exactly as GET returns it (URL-encoded):

DELETE /dns/zones/{zone_id}/records/www/A?organization_id=<uuid>&content=203.0.113.10
Authorization: Bearer <token>

The other values keep their disabled flags and the set keeps its ttl; removing the last value removes the set. A zone that does not exist is always a 404. With content, a name and type or a value that does not exist is a 404 too, and an empty content is a 422 validation_failed. Nothing is written in these cases.

A value such as a TXT record has to be URL-encoded in the query string. To remove "v=spf1 -all" (quotes included, as GET returns it):

DELETE /dns/zones/{zone_id}/records/@/TXT?organization_id=<uuid>&content=%22v%3Dspf1%20-all%22
Authorization: Bearer <token>

Errors

Status code When
409 record_exists The value is already in the set (create, or update to a value the set already has).
409 record_value_ambiguous Update with content on a set with several values and no previous_content.
422 validation_failed Neither content nor records, an entry without content, an invalid ttl, an empty content on delete, or PowerDNS rejected the record.
404 not_found The zone, the name and type, or the previous_content value does not exist.

TTL guidance

Use case Recommended TTL
Production stable records 3600 (1 hour) or higher
Records you may need to change soon 300 (5 minutes)
During a migration or failover 60 (1 minute)

Lower TTL values increase DNS query load; raise them back after changes propagate.