---
title: "Update a site's main domain"
url: https://docs.corefinity.com/api/reference/domains/update-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_apply.md
---
# Update a site's main domain

Starts the change that a preview described. Send the preview's `preview_token` and, in `confirm_domain`, the
site's current main domain typed exactly.

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

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 5 a minute
- Long-running: answers with an operation to poll
- Try it in the console: off. It overwrites data that cannot be brought back. 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

- `confirm_domain` (string, required): The site's current main domain, typed exactly.
- `confirm_replacements` (boolean): True to let `point_dns` replace DNS records that already exist. Defaults to `false`.
- `new_primary` (string, required)
- `point_dns` (boolean): True to point DNS through your connected Cloudflare account as part of the change. Defaults to `false`.
- `preview_token` (string, required): The `preview_token` of a preview of the same `new_primary` and `www`, at most 15 minutes old.
- `www` (string) One of `www`, `bare`.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/url-change \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "confirm_domain": "harbourandfinch.example.com",
    "new_primary": "harbourandfinch.example.net",
    "preview_token": "pReViEw-ToKeN-0123456789abcdefghijklmnopqr",
    "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', [
        'confirm_domain' => 'harbourandfinch.example.com',
        'new_primary' => 'harbourandfinch.example.net',
        'preview_token' => 'pReViEw-ToKeN-0123456789abcdefghijklmnopqr',
        'www' => 'bare',
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/url-change', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    confirm_domain: 'harbourandfinch.example.com',
    new_primary: 'harbourandfinch.example.net',
    preview_token: 'pReViEw-ToKeN-0123456789abcdefghijklmnopqr',
    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",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "confirm_domain": "harbourandfinch.example.com",
        "new_primary": "harbourandfinch.example.net",
        "preview_token": "pReViEw-ToKeN-0123456789abcdefghijklmnopqr",
        "www": "bare",
    },
)

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

## Responses

### 201 The change started. Follow it by `id`.

```json
{
  "applied_at": null,
  "can_retry": false,
  "cluster": {
    "id": 1017,
    "name": "Northwind UK 1"
  },
  "committed_at": null,
  "completed_at": null,
  "created_at": "2026-11-06T09:33:40Z",
  "environment": {
    "env_id": "rs-harbourandfinch-example-com",
    "hostname": "harbourandfinch-example-com.northwind.cfstack.example.net",
    "id": 1042,
    "name": "Production",
    "role": "production",
    "role_label": "Production",
    "slug": "production"
  },
  "error": null,
  "failure_reason": null,
  "from_version": null,
  "hot": false,
  "id": 77173,
  "label": "New address added",
  "notes": [],
  "parent_operation_id": null,
  "requested_by": {
    "id": 5021,
    "name": "Eleanor Finch"
  },
  "result": null,
  "result_state": "none",
  "retried_by_operation_id": null,
  "retries_operation_id": null,
  "retry_requires": null,
  "scope": "site",
  "site": {
    "domain": "harbourandfinch.example.com",
    "id": 1042
  },
  "status": "pending",
  "status_label": "Saving change",
  "step": "committed",
  "steps": [
    {
      "key": "committed",
      "label": "New address added",
      "state": "current"
    },
    {
      "key": "rewritten",
      "label": "Site URL updated",
      "state": "todo"
    },
    {
      "key": "finalising",
      "label": "Redirect saved",
      "state": "todo"
    },
    {
      "key": "finalised",
      "label": "Old address redirects",
      "state": "todo"
    }
  ],
  "summary": "harbourandfinch.example.com → harbourandfinch.example.net",
  "to_version": null,
  "type": "url_change",
  "type_label": "Primary URL"
}
```

### 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 `confirm_mismatch` (the current main domain was not typed exactly), `preview_token` (no preview for this plan, or one older than 15 minutes), `invalid` (a field is missing or wrong), `host_taken` or `domains_locked`.

```json
{
  "code": "confirm_mismatch",
  "errors": {
    "confirm_domain": [
      "Type the current domain to confirm"
    ]
  },
  "field": "confirm_domain",
  "message": "Type the current domain to confirm",
  "reason": "confirm_mismatch"
}
```

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

### 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 | `confirm_mismatch` | Send the confirmation exactly as the field named in `field` asks for it. |
| 422 | `preview_token` | Run the preview again. It is older than 15 minutes. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 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_apply`](https://docs.corefinity.com/mcp/tools/corestack_url_change_apply.md)
