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

**Preview DNS records from a zone file**

Parse a pasted DNS zone file and compare its importable records with the selected HostUp DNS zone. Get {id} from GET /api/v2/dns-zones data[].id. The zone file is limited to 200,000 characters. Invalid or unsupported rows are skipped; the request fails when no valid records remain. This operation only builds a preview and does not change the zone. Validation failures use errors[] with the /zoneFile pointer and a stable field code.

### Related Endpoints

- `GET /api/v2/dns-zones/{id}`: Get DNS records
- `GET /api/v2/dns-zones/{id}/records`: List DNS zone records
- `POST /api/v2/dns-zones/{id}/records`: Create DNS record

### Headers

- `Accept`: application/json
- `Authorization`: Bearer YOUR_API_KEY
- Required API scope: `write:dns`
- `Content-Type`: application/json

### Parameters

- `id` (path, string, required): Public DNS zone ID from GET /api/v2/dns-zones. Do not invent this value; use the exact ID returned by the referenced API response. Example: `zone_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Body

- `zoneFile` (string, required): DNS zone-file text to parse. Example: `$ORIGIN example.com.
@ 3600 IN A 192.0.2.10
www 3600 IN CNAME @`

### Request Examples

#### Parse a small zone file

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

```json
{
  "zoneFile": "$ORIGIN example.com.\n@ 3600 IN A 192.0.2.10\nwww 3600 IN CNAME @"
}
```

### Response Schema

- `records` (array<object>, required)
- `records[].type` (string, required) Example: `A`
  Allowed values: A, AAAA, CNAME, ALIAS, MX, TXT, CAA, SRV, NS, TLSA
- `records[].name` (string, required): Record name relative to the destination zone. `@` is the zone root. Example: `www`
- `records[].value` (string, required) Example: `192.0.2.10`
- `records[].ttl` (number, optional) Example: `3600`
- `records[].priority` (number, optional) Example: `10`
- `records[].weight` (number, optional) Example: `5`
- `records[].port` (number, optional) Example: `5060`
- `records[].isCloudflare` (boolean, optional): True when the source record has proxy-specific behavior that needs review. Example: `false`
- `records[].cloudflareWarning` (string, optional): Customer-facing warning about source proxy behavior, when applicable.
- `records[].recordSubtype` (string, optional) Example: `SPF`
  Allowed values: SPF, DMARC, DKIM, DOMAINKEY, MS365
- `records[].annotation` (string, required): How the discovered record compares with the destination zone. Example: `new`
  Allowed values: new, duplicate, conflict
- `records[].conflictingValue` (string, optional): Existing destination value when `annotation` is `conflict`.
- `domain` (string, required, nullable): Nullable (may be null when not applicable). Example: `example.com`
- `existingCount` (integer, required) Example: `8`

### Responses

#### 200 - SmartCopy zone-file comparison preview.
```json
{
  "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
}
```

#### 400 - Missing, oversized, or unparseable zone file. Inspect errors[0].code: missing_zone_file, zone_file_too_large, or zone_file_no_records.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Validation failed",
  "status": 400,
  "detail": "No DNS records could be read from the pasted zone file. Check the format and try again.",
  "code": "invalid_request",
  "instance": "/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/smartcopy-zonefile",
  "errors": [
    {
      "pointer": "/zoneFile",
      "detail": "No DNS records could be read from the pasted zone file. Check the format and try again.",
      "code": "zone_file_no_records"
    }
  ]
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - Forbidden. The caller lacks a required scope or does not own the resource.
```json
{
  "type": "https://developer.hostup.se/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "The caller lacks a required scope or does not own the resource.",
  "code": "forbidden",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 404 - The selected DNS zone does not exist or is not accessible to the caller.
```json
{
  "type": "https://developer.hostup.se/errors/dns_zone_not_found",
  "title": "DNS zone not found",
  "status": 404,
  "detail": "The requested DNS zone could not be found.",
  "code": "dns_zone_not_found",
  "instance": "/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/smartcopy-zonefile"
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Too many requests. Retry after the limit resets.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```
