## POST /api/v2/domains/nameservers/validate

**Validate nameservers**

Validate nameserver hostnames before a domain order, transfer, or nameserver update. This is a public utility endpoint and does not require an API key. Provide `domain` when validating in-bailiwick child nameservers so the registry glue-host check can run; for example, `ns1.example.com` for `example.com` can fail with `GLUE_HOST_NOT_REGISTERED` until glue is registered.

### Related Endpoints

- `POST /api/v2/domains/nameservers/lookup`: Look up current nameservers
- `POST /api/v2/domains/{id}/nameservers`: Update domain nameservers
- `POST /api/v2/domains/{id}/glue-records`: Create or update a glue record

### Headers

- `Accept`: application/json
- No authorization header required.
- `Content-Type`: application/json

### Request Body

- `nameservers` (array<string>, required) Example: `["primary.ns.hostup.se","secondary.ns.hostup.se"]`
- `domain` (string, optional): Optional domain name for registry glue validation. Example: `example.com`

### Request Examples

#### Validate HostUp managed nameservers

```bash
curl -X POST "https://cloud.hostup.se/api/v2/domains/nameservers/validate" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "nameservers": [
      "primary.ns.hostup.se",
      "secondary.ns.hostup.se"
    ],
    "domain": "example.com"
  }'
```

```json
{
  "nameservers": [
    "primary.ns.hostup.se",
    "secondary.ns.hostup.se"
  ],
  "domain": "example.com"
}
```

#### Validate child nameservers that may need glue

```bash
curl -X POST "https://cloud.hostup.se/api/v2/domains/nameservers/validate" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "nameservers": [
      "ns1.example.com",
      "ns2.example.com"
    ],
    "domain": "example.com"
  }'
```

```json
{
  "nameservers": [
    "ns1.example.com",
    "ns2.example.com"
  ],
  "domain": "example.com"
}
```

### Response Schema

- `results` (array<object>, optional)
- `results[].ns` (string, required) Example: `primary.ns.hostup.se`
- `results[].isValid` (boolean, required) Example: `true`
- `results[].errorCode` (string,null, required) Example: `null`
  Allowed values: EMPTY_VALUE, INVALID_FORMAT, NOT_FOUND, DNS_RESOLUTION_FAILED, GLUE_HOST_NOT_REGISTERED, 
- `results[].errorMessage` (string,null, required) Example: `null`

### Responses

#### 200 - Per-nameserver validation results.
```json
{
  "results": [
    {
      "ns": "primary.ns.hostup.se",
      "isValid": true,
      "errorCode": null,
      "errorMessage": null
    },
    {
      "ns": "secondary.ns.hostup.se",
      "isValid": true,
      "errorCode": null,
      "errorMessage": null
    }
  ]
}
```

#### 400 - Invalid request. The response body is an RFC 7807 Problem Details document.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "The request body failed validation.",
  "code": "invalid_request",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z",
  "errors": [
    {
      "pointer": "/items/0/domainName",
      "detail": "`domainName` is required.",
      "code": "invalid_request"
    }
  ]
}
```

#### 404 - Not found. The resource does not exist or is not owned by the caller.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

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