# DNS Zone File Tools & Delegation Check API

> Validate BIND zone files, convert BIND ↔ JSON ↔ CSV (Cloudflare, Route 53), diff a zone against live DNS and check NS delegation and DNSSEC.

- Endpoint: `GET | POST https://apibox.io.vn/v1/dns-zone`
- Category: Network & Validation
- HTML docs: https://apibox.io.vn/docs/dns-zone/ (Vietnamese: https://apibox.io.vn/vi/docs/dns-zone/)
- Online tool: https://apibox.io.vn/tools/dns-zone/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

`validate` / `parse` read a BIND zone file ($ORIGIN, $TTL, parentheses, relative names, TTL units like 1h / 2w; $INCLUDE and $GENERATE are refused) and check it: SOA and apex NS, CNAME next to other data or at the apex, MX / NS / SRV pointing to a CNAME or an IP, in-zone NS without glue, targets without addresses, RRsets with different TTLs, duplicates, SOA timers (RFC 1912), TXT strings over 255 bytes, several SPF records, SPF over 10 DNS lookups, `+all`, DMARC syntax, CAA tags, private IPs, out-of-zone names, very low / high TTLs. `parse` also returns the records as JSON.

`convert` turns BIND, JSON (also Cloudflare API exports with priority fields and Route 53 record sets) or CSV into `json`, `bind` (relative names), `csv`, `cloudflare` (BIND import file without SOA / apex NS) or `route53` (ChangeResourceRecordSets batch). `diff` queries every name / type of the zone over DNS-over-HTTPS (1.1.1.1, up to 100 RRsets) and shows what matches, differs or is missing live — useful before moving DNS to another provider.

`delegation` (send `domain`) compares the registry nameservers (RDAP) with the zone NS set, resolves every nameserver, flags lame or single nameservers and nameservers in one /24 (RFC 2182), shows the SOA and checks DNSSEC: DS ↔ DNSKEY key tags and digests are recomputed locally, and the validation status comes from a validating resolver. Workers can only use DNS over HTTPS, so glue at the registry, per-nameserver SOA serials and zone transfers cannot be checked.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `action` | body|query | string | no | `parse` | `parse`, `validate`, `convert`, `diff` or `delegation` (alias `mode`; `delegation` when only `domain` is sent). |
| `zone` | body | string | no |  | Zone file (BIND), JSON records or CSV (or file / raw body; max 2 MB, 20,000 records). |
| `domain` | body|query | string | no |  | Zone origin for relative names, or the domain for `delegation`. |
| `from` | body|query | string | no | `auto` | `auto`, `bind`, `json` or `csv`. |
| `to` | body|query | string | no | `json` | convert: `json`, `bind`, `csv`, `cloudflare` or `route53`. |
| `relative` | body|query | boolean | no | `true` | convert to bind: relative names. |
| `max_queries` | body|query | number | no | `60` | diff: RRsets queried (1-100). |

## Example request

```bash
curl -X POST "https://apibox.io.vn/v1/dns-zone" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action":"validate","zone":"$ORIGIN example.com.\n$TTL 3600\n@    IN SOA ns1.example.com. hostmaster.example.com. 2026111601 7200 900 1209600 300\n     IN NS  ns1.example.com.\n     IN NS  ns2.example.net.\n     IN MX  10 mail\n@    IN TXT \"v=spf1 mx include:_spf.google.com ~all\"\nns1  IN A   203.0.113.53\nmail IN CNAME mx.provider.net.\nwww  IN CNAME @\nwww  IN TXT \"verify=1\"\n"}'
```

## Example response

```json
{
  "valid": false,
  "origin": "example.com.",
  "records": 9,
  "types": {
    "SOA": 1,
    "NS": 2,
    "MX": 1,
    "TXT": 2,
    "A": 1,
    "CNAME": 2
  },
  "errors": 2,
  "warnings": 0,
  "info": 1,
  "findings": [
    {
      "rule": "mx-to-cname",
      "severity": "error",
      "message": "MX example.com. points to mail.example.com., which is a CNAME (RFC 2181 10.3)",
      "line": 6,
      "name": "example.com."
    },
    {
      "rule": "cname-coexist",
      "severity": "error",
      "message": "www.example.com. has a CNAME and other data (TXT): not allowed (RFC 1034 3.6.2, RFC 2181 10.1)",
      "line": 10,
      "name": "www.example.com."
    },
    {
      "rule": "spf-lookups",
      "severity": "info",
      "message": "SPF at example.com.: 2 lookups counted here, plus whatever _spf.google.com uses (check with /v1/email-auth)",
      "line": 7,
      "name": "example.com."
    }
  ]
}
```

## Use cases

- Check a zone file exported from a Vietnamese registrar before importing it into Cloudflare
- Convert a zone to a Route 53 change batch or a CSV for review
- Compare the planned zone with the live DNS before switching nameservers
- Verify NS delegation and the DNSSEC DS record after a registrar change

## FAQ

### Which zone formats are accepted?

BIND / RFC 1035 master files, JSON arrays of {name, ttl, type, data} (Cloudflare API export and Route 53 record sets too) and CSV with name, type and data / value / content columns.

### Can it check SOA serials on each nameserver?

No. Cloudflare Workers cannot send UDP / TCP port 53 queries; only DNS-over-HTTPS through a public resolver is available.

### Does it try a zone transfer (AXFR)?

No, never: zone transfers of third-party domains are reconnaissance. Send your own zone file instead.
