## GET /api/v2/shared-hosting/{accountId}/actions/change-main-domain

**Check a main domain change for web hosting**

Check whether the main domain of a web hosting account can be changed and what the change would do. Nothing is changed. Without `domain` the response covers the account: `available` and `reason`, the current `mainDomain`, the other domains on it and the mailboxes on the main domain. Send `domain` to check a new main domain as well. `target` then says whether it can be used, how each mailbox address changes and how its DNS would be set up. The new main domain can come from outside the account or be an addon domain already on it (`promotableDomains`). For an addon domain `target.promotion` describes the folder swap. That only works while the current main domain has no mailboxes or forwarders. The change is not available while the main domain has subdomains of its own. It is also not available on an account that is not active or not on cPanel. A domain registered with Hostup or with a DNS zone at Hostup must be on your own account. Make the change with [`POST /api/v2/shared-hosting/{accountId}/actions/change-main-domain`](/endpoints/webhosting-services/post-v2-shared-hosting-accountid-actions-change-main-domain/).

### Related Endpoints

- `POST /api/v2/shared-hosting/{accountId}/actions/change-main-domain`: Change the main domain of web hosting
- `GET /api/v2/shared-hosting/{accountId}/actions/sso`: Check control panel login for web hosting
- `POST /api/v2/shared-hosting/{accountId}/actions/sso`: Create a control panel login link

### Headers

- `Authorization`: Bearer $HOSTUP_API_KEY
- Scopes: `read:hosting`, `console:services` (Always needed.), `read:dns` (Only when you send `domain`.)

### Parameters

- `accountId` (path, string, required): The web hosting account ID (`acct_…`). Example: `acct_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `domain` (query, string): A domain to check as the new main domain, without `www.`. Example: `example.se`

### Request Example

```bash
curl "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/actions/change-main-domain" \
  -H "Authorization: Bearer $HOSTUP_API_KEY"
```

### Response Schema

- `available` (boolean, required): Whether the main domain of this account can be changed now.
- `reason` (string, required, nullable): Why the change is not available. Null when `available` is true. Example: `null`
- `mainDomain` (string, required, nullable): The account's main domain now. Example: `example.com`
- `otherDomains` (array<string>, required): The other domains on the account: addon domains, aliases and subdomains. They stay on the account through the change.
- `promotableDomains` (array<string>, required): Addon domains that can become the main domain. Send one as `domain` to see `target.promotion`. Example: `[]`
- `emailAccounts` (array<any>, required, nullable): Mailboxes on the main domain. They get addresses on the new main domain. Null when they could not be read.
- `actions` (object, required)
- `actions.canKeepPreviousDomain` (object, required): Whether POST can keep the old main domain with `keepPreviousDomain: true`. Keeping it uses one addon domain on the plan.
- `actions.canKeepPreviousDomain.allowed` (boolean, required) Example: `true`
- `actions.canKeepPreviousDomain.reason` (string, required, nullable) Example: `null`
- `actions.canKeepPreviousDomain.code` (string, optional, nullable): A machine-readable code for why the action is blocked. Example: `pending_order`
- `target` (object, required, nullable): The check of the `domain` you sent. Null without `domain`.

### Responses

#### 200 - The account's main domain state. With `domain`, also the check of that domain.
```json
{
  "available": true,
  "reason": null,
  "mainDomain": "example.com",
  "otherDomains": [],
  "promotableDomains": [],
  "emailAccounts": [
    "info@example.com"
  ],
  "actions": {
    "canKeepPreviousDomain": {
      "allowed": true,
      "reason": null
    }
  },
  "target": {
    "domain": "shop.example.com",
    "available": true,
    "reason": null,
    "emailAccountChanges": [
      {
        "current": "info@example.com",
        "afterChange": "info@example.se"
      }
    ],
    "dnsSetup": {
      "usesHostupNameservers": true,
      "managedRecordsRead": true,
      "nameservers": [
        "primary.ns.hostup.se",
        "secondary.ns.hostup.se"
      ],
      "hasThirdPartyWebsiteRecords": false,
      "hasThirdPartyMailRecords": false,
      "requiresChoice": false,
      "recommendedPreference": "full",
      "records": {
        "website": [],
        "mail": []
      },
      "options": []
    },
    "promotion": null
  }
}
```

#### 400 - `domain` is not a full domain name or starts with `www.`.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "`domain` must be a full domain name such as \"example.com\".",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/actions/change-main-domain",
  "code": "invalid_request",
  "errors": [
    {
      "pointer": "/query/domain",
      "detail": "`domain` must be a full domain name such as \"example.com\".",
      "code": "invalid_request"
    }
  ]
}
```

#### 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 - Conflict. `code` is `account_not_eligible_cpanel`.
```json
{
  "type": "https://developer.hostup.se/errors/account_not_eligible_cpanel",
  "title": "Control panel action unavailable",
  "status": 409,
  "detail": "This hosting account runs on a legacy control panel that does not support this action.",
  "code": "account_not_eligible_cpanel",
  "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": "Rate limit exceeded. Please try again later.",
  "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"
}
```

#### 502 - The account's domains could not be read right now. Try again later.
```json
{
  "type": "https://developer.hostup.se/errors/upstream_failed",
  "title": "Upstream request failed",
  "status": 502,
  "detail": "The hosting account's domains could not be loaded.",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/actions/change-main-domain",
  "code": "upstream_failed"
}
```
