---
title: "Preview a main domain change"
url: https://docs.corefinity.com/api/reference/domains/preview-site-main-domain
type: endpoint
last_updated: 2026-11-13
feature: domains
related:
  - https://docs.corefinity.com/guides/sites/go-live/add-a-domain.md
  - https://docs.corefinity.com/mcp/tools/corestack_url_change_preview.md
---
# Preview a main domain change

Answers what changing the main domain would do: the hostnames, their DNS state, how many database rows mention
the old address, and a `preview_token` valid for 15 minutes. Nothing changes.

```http
POST /api/corestack/sites/{site}/url-change/preview
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 6 a minute
- Try it in the console: off. It has not been cleared for the console. Copy the request and run it yourself when you are sure.

## Path parameters

- `site` (integer, required): The id of a site row. A website's production site and each of its environments has its own id. Digits only.

## Body

- `new_primary` (string, required): The new main domain, as a plain hostname.
- `www` (string): Whether the site answers on the `www` form or the `bare` form of the new domain. Left out, it follows `new_primary`. One of `www`, `bare`.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/url-change/preview \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "new_primary": "harbourandfinch.example.net",
    "www": "bare"
  }'
```

### PHP

```php
use Illuminate\Support\Facades\Http;

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/sites/1042/url-change/preview', [
        'new_primary' => 'harbourandfinch.example.net',
        'www' => 'bare',
    ]);

$data = $response->json();
```

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/url-change/preview', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    new_primary: 'harbourandfinch.example.net',
    www: 'bare',
  }),
});

// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);
```

### Python

```python
import os
import requests

res = requests.post(
    "https://manage.corefinity.com/api/corestack/sites/1042/url-change/preview",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "new_primary": "harbourandfinch.example.net",
        "www": "bare",
    },
)

data = res.json() if res.content else None
```

## Responses

### 200 The preview.

```json
{
  "blockers": [],
  "can_proceed": true,
  "checks": {
    "advice": null,
    "dns_plan": {
      "actions": [
        {
          "action": "keep",
          "existing": null,
          "host": "harbourandfinch.example.net",
          "reason": null,
          "record": {
            "content": "203.0.113.10",
            "name": "harbourandfinch.example.net",
            "proxied": true,
            "type": "A"
          }
        }
      ],
      "can_apply": false,
      "requires_confirmation": false,
      "zone": null
    },
    "hosts": [
      {
        "cloudflare_zone": null,
        "dns_answers": [
          {
            "type": "A",
            "value": "203.0.113.10"
          }
        ],
        "dns_checked_at": "2026-11-06T09:16:05Z",
        "dns_detail": null,
        "dns_state": "points_here",
        "dns_state_since": null,
        "expected_ip": "203.0.113.10",
        "host": "harbourandfinch.example.net",
        "noindex": false,
        "ok": true,
        "problems": [],
        "redirects_to": null,
        "role": "primary",
        "tls": {
          "checked_at": null,
          "issuer": null,
          "not_after": null,
          "reason": null,
          "state": "none"
        }
      }
    ],
    "ok": true
  },
  "current_primary": "harbourandfinch.example.com",
  "expires_at": "2026-11-06T09:46:12Z",
  "new_canonical_url": "https://harbourandfinch.example.net",
  "new_primary": "harbourandfinch.example.net",
  "platform": "wordpress",
  "preview_token": "pReViEw-ToKeN-0123456789abcdefghijklmnopqr",
  "replacements": {
    "laravel": null,
    "magento2": null,
    "wordpress": {
      "by_table": [
        {
          "column": "post_content",
          "rows": 734,
          "table": "wp_posts"
        }
      ],
      "duration_ms": 18420,
      "rows": 1876,
      "serialised_safe": true,
      "tables": 9
    }
  },
  "warnings": []
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the scope (`scope_required`, with the `scope` to use), your company requires two-factor authentication and you have not set it up, or your account has no company that can use Managed Clusters, for example because the company was closed (`company_unavailable` or `company_not_enabled`, whichever the route checks first). For Managed Clusters routes; any other route uses `ForbiddenScopeOrTwoFactor`.

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

### 404 The id does not exist or is something you cannot see, or the feature is not on for your company (`feature_off`).

```json
{
  "code": "feature_off",
  "message": "Not found.",
  "reason": "feature_off"
}
```

### 409 `preview_only` (no domain attached yet), `busy` or `restore_running` (another change is running), `maintenance` (the maintenance page is on), `not_running`, `not_available`, `not_connected` (with `point_dns` and no Cloudflare zone), `store_hosts`, `deleted`, `removed`, `provisioning` or `managed_elsewhere`.

```json
{
  "code": "maintenance",
  "message": "Switch the maintenance page off before changing the site's hosts",
  "reason": "maintenance"
}
```

### 422 A field is missing or wrong (`invalid`), the new address is used by another site (`host_taken`), or the site's domains are locked (`domains_locked`).

```json
{
  "code": "host_taken",
  "errors": {
    "new_primary": [
      "This hostname is already used by another site."
    ]
  },
  "message": "This hostname is already used by another site.",
  "reason": "host_taken"
}
```

### 429 Too many requests (`rate_limited`). Wait for the number of seconds in `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many requests. Try again in 60 seconds.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

### 500 Corefinity has switched commands on sites off for the moment, and this endpoint needs one to read the site. It answers a server error here, not `503 switched_off`. Nothing changed: try again later.

```json
{
  "message": "Server Error"
}
```

### 502 A check or a write outside the Control Panel could not run. Try again in a moment.

```json
{
  "message": "The DNS check could not run. Try again in a moment."
}
```

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `company_unavailable` | Your company is unavailable. |
| 403 | `scope_required` | Use a token with the scope named in `scope`. |
| 403 | `two_factor_required` | Turn on two-factor on your account, then send again. |
| 404 | `feature_off` | This feature is not on for your organisation yet. |
| 409 | `maintenance` | The site is in maintenance mode, which blocks this. Switch maintenance mode off first. |
| 409 | `preview_only` | The environment has no domain attached yet. Attach one first. |
| 422 | `host_taken` | This hostname is already used by another site. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 500 |  | Read the message; it says what happened. |
| 502 |  | Read the message; it says what happened. |

## The same task elsewhere

- Guide: [Add a domain](https://docs.corefinity.com/guides/sites/go-live/add-a-domain.md)
- MCP tool: [`corestack_url_change_preview`](https://docs.corefinity.com/mcp/tools/corestack_url_change_preview.md)
