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

**Preview DNS records from a nameserver**

Scan one public nameserver for a domain and compare the discovered records with the selected HostUp DNS zone. Get {id} from GET /api/v2/dns-zones data[].id. sourceDomain is optional and defaults to the selected zone's domain. This operation only builds a preview; it does not change the zone. Review each record's annotation before importing records into the zone. Validation failures use errors[] with /nameserver or /sourceDomain pointers and stable field codes.

### 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

- `nameserver` (string, required): Public nameserver hostname or IP address to query directly. Example: `ns1.example.net`
- `sourceDomain` (string, optional): Domain to query at the source nameserver. Omit to use the destination zone's domain. Example: `example.com`

### Request Examples

#### Scan a source nameserver

```bash
curl -X POST "https://cloud.hostup.se/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/smartcopy-scan" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "nameserver": "ns1.example.net",
    "sourceDomain": "example.com"
  }'
```

```json
{
  "nameserver": "ns1.example.net",
  "sourceDomain": "example.com"
}
```

### 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`
- `nameserver` (string, required, nullable): Nullable (may be null when not applicable). Example: `ns1.example.net`
- `existingCount` (integer, required) Example: `8`

### Responses

#### 200 - SmartCopy comparison preview.
```json
{
  "records": [
    {
      "type": "A",
      "name": "www",
      "value": "192.0.2.10",
      "ttl": 3600,
      "annotation": "new"
    },
    {
      "type": "MX",
      "name": "@",
      "value": "mail.example.com",
      "priority": 10,
      "annotation": "conflict",
      "conflictingValue": "old-mail.example.com"
    }
  ],
  "domain": "example.com",
  "nameserver": "ns1.example.net",
  "existingCount": 8
}
```

#### 400 - Invalid request or source lookup. Inspect errors[0].code: missing_nameserver, invalid_nameserver, nameserver_not_public, nameserver_unreachable, dns_scan_failed, or invalid_source_domain.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Validation failed",
  "status": 400,
  "detail": "Enter a public nameserver hostname or IP address.",
  "code": "invalid_request",
  "instance": "/api/v2/dns-zones/zone_01hxa3b4c5d6e7f8g9h0j1k2m3/smartcopy-scan",
  "errors": [
    {
      "pointer": "/nameserver",
      "detail": "Enter a public nameserver hostname or IP address.",
      "code": "nameserver_not_public"
    }
  ]
}
```

#### 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-scan"
}
```

#### 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"
}
```
