Black Friday: add funds and get 2x credit, up to $50 free ($25 → $50, $50 → $100). Use it for anything: domains, hosting, email. Code: BLACKFRIDAY2026 Get 2x credit →

Developers → DNS as code

DNS as code

Keep your zone in one YAML or JSON file next to your code. Review DNS changes in pull requests, see exactly what will change before it does, and apply it in one step.

Works with any zone on NameOcean DNS, included free with every NameOcean domain, and with octoDNS, DNSControl and external-dns.

Start from your zone

nameocean
$ nameocean dns export example.com > dns.yaml
$ $EDITOR dns.yaml
$ nameocean dns plan -f dns.yaml
+  CNAME  blog  example.netlify.app
~  A      @     203.0.113.10  ttl 1h → 5m
-  A      old   203.0.113.9
example.com: 1 to add, 1 to change, 1 to delete, 6 unchanged.
$ nameocean dns apply -f dns.yaml
Apply these changes? [y/N] y
Applied: 1 added, 1 changed, 1 deleted. example.com is at serial 214.

The file

dns.yaml
# yaml-language-server: $schema=https://nameocean.net/schemas/dns-zone.json
zone: example.com
records:
  - name: "@"
    type: A
    value: 203.0.113.10
    ttl: 5m
  - name: www
    type: CNAME
    value: "@"
  - name: "@"
    type: MX
    value: mail.example.com
    priority: 10
  - name: "@"
    type: TXT
    value: "v=spf1 mx -all"
  - name: _sip._tcp
    type: SRV
    value: sip.example.com
    priority: 10
    weight: 5
    port: 5060
  - name: old
    type: REDIRECT
    value: https://example.com/new
  • name is @ for the zone itself or a name relative to it (www, _dmarc); a fully qualified name with the trailing dot works too.
  • type is A, AAAA, CNAME, MX, TXT, SRV, PTR, CAA, NS, DS or REDIRECT (an HTTP redirect to the URL in value). CAA takes a tag (issue, issuewild or iodef) and optional flags (0 or 128); value is the CA domain, for example letsencrypt.org, or ; to forbid issuing.
  • ttl is 5m, 15m, 30m, 1h or 1d; without it a record gets the file's ttl, or 1h. MX takes priority (default 10), SRV priority, weight and port, REDIRECT save_path (default true).
  • The same document works as JSON. The JSON Schema gives you completion and checks in VS Code and other editors.

How a plan is made

The file is the whole zone: a record that is in the zone but not in the file is deleted. Pass --keep-unlisted (prune=false in the API) to only add and change.

A, AAAA, MX, TXT, SRV, CAA and NS records are matched by name and value (priority for MX; priority, weight and port for SRV; tag for CAA), since one name can carry several of them. DS records are matched by name, key_tag, algorithm and digest_type. CNAME, PTR and REDIRECT records are matched by name. A different ttl is a change; everything else is an add or a delete.

Apply runs in one transaction: deletes first, then changes, then new records, so a CNAME can replace an A record in the same file. If one record is refused, nothing is changed. If someone changes the zone between the plan and the apply, the apply is refused and you plan again.

Records NameOcean keeps for itself, the address behind an HTTP redirect and the ACME challenges for SSL, are never exported, planned or deleted.

Subdomains and other record types

Hand a subdomain to other nameservers with NS records: name is the subdomain (never @, the zone's own nameservers are NameOcean's), value is the nameserver, one record per nameserver. A delegated name can hold no other records of its own; put them in the delegated zone. If that zone uses DNSSEC, add its DS record: value is the hex digest, with key_tag, algorithm and digest_type. Add the NS records first.

CAA records say which certificate authorities may issue for a name: tag is issue, issuewild or iodef, value is the CA domain (or ; to forbid issuing). Keep letsencrypt.org in an issue record, or NameOcean's free SSL cannot be issued for the domain.

BIND zone files

To move a zone to or from another DNS provider, export it as a BIND file, or read one in. The SOA and the zone's own NS records are NameOcean's: an export has them as a header and an import skips them. What NameOcean does not take over (DNSSEC records, types it does not serve) is skipped and listed in the answer under skipped; a ttl that is not allowed moves to the nearest one (notes). A file without $TTL reads as 1h.

bash
$ nameocean dns export example.com -o example.com.zone
$ nameocean dns plan -f old-provider.zone --zone example.com
$ nameocean dns apply -f old-provider.zone --zone example.com

History and undo

Every record change is kept: who made it (the dashboard, an API key, an app), when, and the record before and after. History starts on 15 November 2026. You can undo one change: a created record is deleted, a deleted one comes back, a changed one gets its old values. It is refused when the record changed after that entry, so undo the newer change first.

bash
$ nameocean dns history example.com
$ nameocean dns revert example.com 42

GitHub Actions

Create an API key with dns:write (or only dns:read for a job that plans) and save it as the NAMEOCEAN_API_KEY secret.

.github/workflows/dns.yml
name: dns
on:
  pull_request: {paths: [dns.yaml]}
  push: {branches: [main], paths: [dns.yaml]}
jobs:
  dns:
    runs-on: ubuntu-latest
    env:
      NAMEOCEAN_API_KEY: ${{ secrets.NAMEOCEAN_API_KEY }}
    steps:
      - uses: actions/checkout@v4
      - run: curl -fsSL https://nameocean.net/install.sh | sh
      - run: nameocean dns plan -f dns.yaml
      - if: github.event_name == 'push'
        run: nameocean dns apply -f dns.yaml --yes

dns plan --detailed-exitcode exits 2 when there are changes, for jobs that should only report drift.

With octoDNS

If you already use octoDNS, add the NameOcean provider. Each sync is one apply, so it is just as atomic and serial-checked.

config.yaml
$ pip install octodns octodns-nameocean

providers:
  nameocean:
    class: octodns_nameocean.NameOceanProvider
    token: env/NAMEOCEAN_API_KEY

With DNSControl

DNSControl supports NameOcean from v5.11.0 (provider documentation). Each push uploads the whole zone in one request, which NameOcean applies in a single transaction with the same serial check, so a zone changed in the meantime is refused instead of overwritten.

creds.json · dnsconfig.js
{
  "nameocean": { "TYPE": "NAMEOCEAN", "token": "$NAMEOCEAN_API_KEY" }
}

var DSP_NAMEOCEAN = NewDnsProvider("nameocean");
D("example.com", NewRegistrar("none"), DnsProvider(DSP_NAMEOCEAN),
    A("@", "192.0.2.1"),
    CNAME("www", "@")
);

$ dnscontrol preview && dnscontrol push

With external-dns (Kubernetes)

external-dns keeps records in sync with your Services and Ingresses. Run our webhook provider as its sidecar, with the API key in a Secret:

values.yaml
$ kubectl create secret generic nameocean-api-key --from-literal=api-key=no_live_…

provider:
  name: webhook
  webhook:
    image:
      repository: ghcr.io/nameocean/external-dns-nameocean-webhook
      tag: 0.1.0
    env:
      - name: NAMEOCEAN_API_KEY
        valueFrom:
          secretKeyRef: {name: nameocean-api-key, key: api-key}
domainFilters: ["example.com"]
txtOwnerId: my-cluster

Install it with helm upgrade --install external-dns external-dns/external-dns -f values.yaml. TTLs are rounded to the ones NameOcean accepts (5m, 15m, 30m, 1h, 1d), and records external-dns did not create are left alone.

With the REST API

GET /dns/{zone}/export?output=yamlThe zone as a file (JSON without output=yaml); the X-Zone-Serial header is its serial
POST /dns/{zone}/planWhat apply would do; changes nothing and needs only dns:read
GET /dns/{zone}/export?output=bindThe zone as a BIND file
POST /dns/{zone}/plan?input=bindThe same for a BIND file in the request body (also apply)
GET /dns/{zone}/historyWho changed which record, when; ?limit=50&cursor=
POST /dns/{zone}/history/{id}/revertUndo one change; 409 cannot_revert if the record changed since
POST /dns/{zone}/apply?serial=NMake the zone match the file; 409 zone_changed if it is not at the plan's serial any more
curl
$ curl -X POST https://nameocean.net/api/v1/dns/example.com/plan \
    -H "Authorization: Bearer $NAMEOCEAN_API_KEY" \
    -H "Content-Type: application/yaml" --data-binary @dns.yaml

Send YAML with Content-Type: application/yaml or the same document as JSON. A file the server cannot accept answers 400 invalid_zone_file with an errors list naming each record and field. All of it is in the API reference.

From your AI

Over MCP an assistant can export a zone, plan a change to many records at once with plan_dns_zone and, after showing you the plan, apply it with apply_dns_zone.