## POST /api/v2/shared-hosting/{accountId}/domains/dns-setup

**Apply hosting DNS setup for a domain**

Apply the customer's DNS setup choice for a domain attached to the shared-hosting account, writing Hostup's own zone for that domain: `full` points website and email at the hosting, `website-only` and `email-only` change one side and leave the other untouched, and `none` changes no records but records the decision so the platform stops asking. Get `{accountId}` from `GET /api/v2/shared-hosting` `data[].id`. Read `GET /api/v2/shared-hosting/{accountId}/domains/dns-setup` first and send its `revision` back; a mismatch means the records changed meanwhile and returns 409 `dns_changed`. Email setup also publishes the hosting's DKIM key. Blockers are reported as 409 Problem Details: `dns_forwarding_active` when domain email forwarding is on (disable it in the domain's email settings first), `dns_redirect_active` when a client-area redirect owns the website records, `dns_plan_conflict` when the records need review in the DNS editor, `dns_busy` when another change is running, `dns_not_enabled` when the account's platform does not offer the action. The choice can be applied while the nameservers still point elsewhere; nothing is live until they move. The same route serves the DNS setup link sent by email (`Authorization: DnsSetup <token>`).

### Related Endpoints

- `GET /api/v2/shared-hosting/{accountId}/domains/dns-setup`: Read hosting DNS setup state for a domain
- `GET /api/v2/shared-hosting/{accountId}/domains`: List hosting domains
- `POST /api/v2/shared-hosting/{accountId}/domains`: Add hosting domain

### Headers

- `Accept`: application/json
- `Authorization`: Bearer YOUR_API_KEY
- Required API scopes: `write:hosting`, `write:dns`, `console:services`
- `Content-Type`: application/json

### Parameters

- `accountId` (path, string, required): Public shared-hosting account ID from `GET /api/v2/shared-hosting` `data[].id`. Do not invent this value; use the exact ID returned by the referenced API response. Example: `acct_01hxa3b4c5d6e7f8g9h0j1k2m3`

### Request Body

- `domain` (string, required): Full domain name attached to the hosting account. Example: `example.com`
- `preference` (string, required): `full` = website and email to the hosting, `website-only`, `email-only`, or `none` to keep current DNS and only record the choice. Example: `full`
  Allowed values: full, email-only, website-only, none
- `revision` (string, optional): The `revision` from the latest `GET`. Required for every preference except `none`. Example: `5f8c1d2e9a7b4c3d6e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d`

### Request Examples

#### Website and email to the hosting

```bash
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/domains/dns-setup" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "example.com",
    "preference": "full",
    "revision": "5f8c1d2e9a7b4c3d6e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d"
  }'
```

```json
{
  "domain": "example.com",
  "preference": "full",
  "revision": "5f8c1d2e9a7b4c3d6e1f0a9b8c7d6e5f4a3b2c1d0e9f8a7b6c5d4e3f2a1b0c9d"
}
```

#### Keep existing DNS, just record the choice

```bash
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/domains/dns-setup" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "example.com",
    "preference": "none"
  }'
```

```json
{
  "domain": "example.com",
  "preference": "none"
}
```

### Response Schema

- `success` (boolean, required) Example: `true`
  Allowed values: true
- `domain` (string, required) Example: `example.com`
- `preference` (string, required) Example: `full`
  Allowed values: full, email-only, website-only, none
- `status` (string, required) Example: `done`
  Allowed values: done, pending

### Responses

#### 200 - Choice recorded; records written when the preference changes DNS.
```json
{
  "success": true,
  "domain": "example.com",
  "preference": "full",
  "status": "done"
}
```

#### 400 - `domain` or `preference` is missing or invalid.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "DNS setup",
  "status": 400,
  "detail": "A domain and a valid DNS setup choice are required.",
  "code": "invalid_request",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/domains/dns-setup"
}
```

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

#### 409 - The setup cannot be applied as requested; the `code` names the blocker.
```json
{
  "type": "https://developer.hostup.se/errors/dns_changed",
  "title": "DNS setup",
  "status": 409,
  "detail": "The DNS settings changed. Review the refreshed settings before saving.",
  "code": "dns_changed",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/domains/dns-setup"
}
```

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

#### 503 - The zone could not be read, so nothing was applied.
```json
{
  "type": "https://developer.hostup.se/errors/dns_read_unavailable",
  "title": "DNS setup",
  "status": 503,
  "detail": "The DNS settings could not be checked. Please try again.",
  "code": "dns_read_unavailable",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/domains/dns-setup"
}
```
