Skip to content

Preview DNS records from a zone file

POST /api/v2/dns-zones/{id}/smartcopy-zonefile

Reads the records in a pasted DNS zone file and compares them with this zone. Nothing in the zone changes. The zone file can be up to 200,000 characters. Rows that are invalid or of an unsupported type are skipped. When no valid record is left, the request fails.

Each record has an annotation: new, duplicate or conflict. Import the records you want with POST /api/v2/dns-zones/{id}/smartcopy. Errors on the input come back as 400 with a pointer to /zoneFile and a code in errors[0].code. An API key limited to certain DNS records gets 403. It needs access to the whole zone.

Authentication: An API key with the scope write:dns. About keys and scopes

Request

Path parameters

idstringrequired
The DNS zone ID (zone_…).

Body

zoneFilestringrequired
The zone file as text, up to 200,000 characters.

Example

POST /api/v2/dns-zones/{id}/smartcopy-zonefile
curl -X POST "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/smartcopy-zonefile" \
-H "Authorization: Bearer $HOSTUP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"zoneFile": "$ORIGIN example.com.\n@ 3600 IN A 192.0.2.10\nwww 3600 IN CNAME @"
}'

Responses

200 The comparison.

Response 200
{
"records": [
{
"type": "A",
"name": "@",
"value": "192.0.2.10",
"ttl": 3600,
"annotation": "new"
},
{
"type": "CNAME",
"name": "www",
"value": "example.com",
"ttl": 3600,
"annotation": "duplicate"
}
],
"domain": "example.com",
"existingCount": 8
}
Response fields
recordsarray of object
Records read from the zone file, each with its annotation.
typestring
One of A, AAAA, CNAME, ALIAS, MX, TXT, CAA, SRV, NS, TLSA.
namestring
Record name relative to the destination zone. @ is the zone root.
valuestring
ttlnumber
prioritynumber
weightnumber
portnumber
isCloudflareboolean
True when the source record has proxy behavior that needs a check.
cloudflareWarningstring
A warning about the proxy behavior of the source record, to show when it applies.
recordSubtypestring
One of SPF, DMARC, DKIM, DOMAINKEY, MS365.
annotationstring
How the record compares with the destination zone. One of new, duplicate, conflict.
conflictingValuestring
The value in the destination zone when annotation is conflict.
parkingPageboolean
True when the address only serves the previous provider’s parking page. Such records are listed. Don’t preselect them for copying. Absent otherwise.
domainstring or null
The zone the relative names were read against.
existingCountinteger
Records in the zone when the comparison ran. At least 0.

Errors

Errors are Problem Details with a stable code. Branch on the code, not on the text.

400The zone file is missing, too large or has no readable records. errors[0].code is missing_zone_file, zone_file_too_large or zone_file_no_records.
401Unauthorized. Authentication is required.
403Forbidden. The caller lacks a required scope or does not own the resource.
404No DNS zone with this ID on the account.
429Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
500Internal error. Retry later or contact support if the issue persists.