MOKLAV DNS API v1.0

Manage DNS zones hosted on ns1/ns2.moklav.com. Authenticate with `Authorization: Bearer <API key>` (create keys in Account > API keys). Keys are limited to the domains chosen when they were created, and read-only keys cannot change records.

Base URL: https://dns.moklav.com/api/v1 · OpenAPI spec: openapi.json (import into Postman / Insomnia / Swagger)

curl -H "Authorization: Bearer mk_..." https://dns.moklav.com/api/v1/zones
curl -X POST -H "Authorization: Bearer mk_..." -H "Content-Type: application/json" \
  -d '{"name":"www","type":"A","content":"192.0.2.10","ttl":300}' https://dns.moklav.com/api/v1/zones/example.com/records

Endpoints

MethodPathDescription
GET/zonesList zones this key can access
GET/zones/{zone}Get zone details and records
GET/zones/{zone}/recordsList records (optionally filter by name/type)
POST/zones/{zone}/recordsAdd one record (appends to an existing RRset)
DELETE/zones/{zone}/recordsDelete a record value or a whole RRset
PUT/zones/{zone}/rrsetReplace a whole RRset (all values for name+type)
GET/zones/{zone}/dnssecDNSSEC status and DS records for the registrar
GET/zones/{zone}/exportExport zone as BIND zone file text
POST/acme/presentACME DNS-01: add a TXT challenge (acme.sh / certbot hook)
POST/acme/cleanupACME DNS-01: remove a TXT challenge

Let's Encrypt DNS-01 (wildcards)

acme.sh: download dns_moklav.sh into ~/.acme.sh/dnsapi/, then

export MOKLAV_API_KEY="mk_..."
acme.sh --issue --dns dns_moklav -d example.com -d '*.example.com'

certbot: download certbot-moklav-hook.sh, then

export MOKLAV_API_KEY="mk_..."
certbot certonly --manual --preferred-challenges dns \
  --manual-auth-hook "./certbot-moklav-hook.sh auth" --manual-cleanup-hook "./certbot-moklav-hook.sh cleanup" \
  -d example.com -d '*.example.com'

Dynamic DNS (DynDNS2)

Create a token in your domain's Dynamic DNS tab. Works with routers (MikroTik, OpenWrt ddns-scripts, pfSense "Custom"), ddclient and curl:

https://dns.moklav.com/nic/update?hostname=home.example.com&myip=1.2.3.4   (HTTP basic auth: any username, password = token)
# ddclient: protocol=dyndns2, server=dns.moklav.com, login=ddns, password=TOKEN