---
title: "Update an environment"
url: https://docs.corefinity.com/api/reference/environments/update-site-environment
type: endpoint
last_updated: 2026-11-13
feature: environments
related:
  - https://docs.corefinity.com/guides/sites/environments-and-copies/create-an-environment.md
  - https://docs.corefinity.com/mcp/tools/corestack_environment_update.md
---
# Update an environment

Changes the environment whose row `{site}` names. Send only what changes. The request body's variants say
what each kind of change takes and who may make it.

```http
PATCH /api/corestack/sites/{site}/environment
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 10 a minute
- Long-running: answers with an operation to poll
- Try it in the console: off. It can add to your bill. 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


## Request

### curl

```bash
curl -X PATCH https://manage.corefinity.com/api/corestack/sites/1042/environment \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "apply": "now",
    "uat_size": "medium"
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->patch('https://manage.corefinity.com/api/corestack/sites/1042/environment', [
        'apply' => 'now',
        'uat_size' => 'medium',
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/environment', {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    apply: 'now',
    uat_size: 'medium',
  }),
});

// 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.patch(
    "https://manage.corefinity.com/api/corestack/sites/1042/environment",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "apply": "now",
        "uat_size": "medium",
    },
)

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

## Responses

### 200 The settings were saved at once. `operation` is null.

```json
{
  "operation": null,
  "site": {
    "access_summary": {
      "apply_state": "never",
      "company_keys": 0,
      "keys": 0,
      "users": 0
    },
    "actions": {
      "apply_pending_now": {
        "available": false,
        "reason": "Scheduled maintenance is switched off at the moment"
      },
      "attach_domain": {
        "available": true,
        "reason": null
      },
      "change_url": {
        "available": false,
        "reason": "Domains are switched off at the moment"
      },
      "clone": {
        "available": true,
        "reason": null
      },
      "create_environment": {
        "available": true,
        "reason": null
      },
      "delete": {
        "available": true,
        "reason": null
      },
      "go_live": {
        "available": true,
        "reason": null
      },
      "maintenance": {
        "available": true,
        "reason": null
      },
      "push_to_live": {
        "available": true,
        "reason": null
      },
      "restore_deleted": {
        "available": false,
        "reason": "Environments are removed at once. Recreate it from the final snapshot."
      },
      "terminal": {
        "available": false,
        "reason": "The terminal is available once the site is running"
      }
    },
    "adoption": "adopted",
    "cloudflare": {
      "connected": false,
      "zone": null
    },
    "cluster": {
      "id": 1017,
      "name": "Northwind UK 1"
    },
    "commands": [],
    "compute_family": "general",
    "counts": {
      "crons": 1
    },
    "crons_enabled": false,
    "database": {
      "host": "127.0.0.1",
      "name": "wordpress",
      "password_revealable": true,
      "port": 3306,
      "username": "application",
      "via": "SSH tunnel"
    },
    "deleted": null,
    "deploy_mode": "manual",
    "deploy_mode_label": "Manual",
    "deployments_summary": {
      "last": null,
      "mode": "manual"
    },
    "domain": "harbourandfinch.example.com",
    "domains_summary": {
      "aliases": 0,
      "dns": "unknown",
      "noindex": true,
      "primary": null,
      "tls": "none",
      "www": null
    },
    "email_summary": {
      "sending_domain": null,
      "state": "preview"
    },
    "environment": {
      "env_id": "rs-northwind-harbourandfinch-example-com--staging",
      "hostname": "harbourandfinch-example-com-staging.northwind.cfstack.example.net",
      "id": 1043,
      "name": "QA",
      "role": "staging",
      "role_label": "Staging",
      "slug": "staging"
    },
    "environments": [
      {
        "env_id": "rs-northwind-harbourandfinch-example-com",
        "hostname": "harbourandfinch-example-com.northwind.cfstack.example.net",
        "id": 1042,
        "name": "Production",
        "role": "production",
        "role_label": "Production",
        "slug": "production"
      },
      {
        "env_id": "rs-northwind-harbourandfinch-example-com--staging",
        "hostname": "harbourandfinch-example-com-staging.northwind.cfstack.example.net",
        "id": 1043,
        "name": "QA",
        "role": "staging",
        "role_label": "Staging",
        "slug": "staging"
      }
    ],
    "final_snapshot_note": "Snapshots are off for this cluster, so no final copy is taken: it cannot be brought back afterwards.",
    "health": "unknown",
    "hosting": {
      "cluster_kind": "customer",
      "label": "CoreCluster Northwind UK 1"
    },
    "http_auth_summary": {
      "apply_state": "applied",
      "enabled": true,
      "rules": 0,
      "users": 0
    },
    "id": 1043,
    "kind": "corecluster",
    "lifecycle": "active",
    "limits": {
      "cpu_millicores": 2000,
      "disk_bytes": 10737418240,
      "memory_bytes": 4294967296
    },
    "logs": null,
    "maintenance": {
      "bypass_corefinity": 1,
      "bypass_ips": [],
      "enabled": false,
      "since": null
    },
    "mariadb": {
      "version": "11.4"
    },
    "mode": "staging",
    "mode_label": "No domain",
    "operation": null,
    "operations": [],
    "package": null,
    "pending_changes": {
      "count": 0,
      "outcome_at": null,
      "state": null,
      "window_starts_at": null
    },
    "php": {
      "version": "8.3"
    },
    "platform": {
      "key": "wordpress",
      "label": "WordPress"
    },
    "platform_url": "https://harbourandfinch-example-com-staging.northwind.cfstack.example.net",
    "preview": {
      "label": "Platform address",
      "protected": true,
      "url": "https://harbourandfinch-example-com-staging.northwind.cfstack.example.net"
    },
    "primary_url": null,
    "production_hosts": [],
    "provisioning": null,
    "removed": false,
    "restore": null,
    "settings": {
      "auto_deploy": false,
      "http_auth_enabled": true,
      "scheduled_snapshots": false
    },
    "site": {
      "domain": "harbourandfinch.example.com",
      "id": 1042
    },
    "site_id": "rs-northwind-harbourandfinch-example-com--staging",
    "snapshots": {
      "count": 0,
      "effective_frequency": "off",
      "effective_label": "Off",
      "latest": null,
      "latest_ready_at": null,
      "next_scheduled_at": null,
      "overridden": false,
      "stored_gb": 0
    },
    "ssh": {
      "command": "ssh -p 20032 web@ssh-northwind.example.net",
      "host": "ssh-northwind.example.net",
      "key_management": false,
      "keys": [],
      "port": 20032,
      "sftp_command": "sftp -P 20032 web@ssh-northwind.example.net",
      "tunnel_command": "ssh -N -L 3306:127.0.0.1:3306 -p 20032 web@ssh-northwind.example.net",
      "user": "web",
      "users": 0
    },
    "tier": "S",
    "uat_size": null,
    "usage": {
      "cpu_millicores": null,
      "disk_used_bytes": null,
      "memory_bytes": null,
      "observed_at": null,
      "source": null
    }
  }
}
```

### 201 A change was started or queued. `operation` is the operation that applies it, to follow until it completes, or null when the change waits for the maintenance window.

```json
{
  "item": null,
  "operation": {
    "applied_at": null,
    "can_retry": false,
    "cluster": {
      "id": 1017,
      "name": "Northwind UK 1"
    },
    "committed_at": "2026-11-10T09:00:00+00:00",
    "completed_at": null,
    "created_at": "2026-11-10T09:00:00+00:00",
    "environment": {
      "env_id": "rs-northwind-journal-harbourandfinch-example-com--staging",
      "hostname": "journal-harbourandfinch-example-com-staging.northwind.cfstack.example.net",
      "id": 1052,
      "name": "Staging",
      "role": "staging",
      "role_label": "Staging",
      "slug": "staging"
    },
    "error": null,
    "failure_reason": null,
    "from_version": null,
    "hot": false,
    "id": 5121,
    "notes": [],
    "parent_operation_id": null,
    "requested_by": {
      "id": 2041,
      "name": "Eleanor Finch"
    },
    "result": null,
    "result_state": "none",
    "retried_by_operation_id": null,
    "retries_operation_id": null,
    "retry_requires": null,
    "scope": "site",
    "site": {
      "domain": "journal.harbourandfinch.example.com",
      "id": 1052
    },
    "status": "committed",
    "status_label": "In progress",
    "steps": [
      {
        "key": "checked",
        "label": "Checked",
        "state": "done"
      },
      {
        "key": "committed",
        "label": "Committed",
        "state": "done"
      },
      {
        "key": "applied",
        "label": "Applied",
        "state": "current"
      }
    ],
    "subject": null,
    "summary": "Resize environment",
    "to_version": null,
    "type": "uat_resize",
    "type_label": "Resize environment"
  },
  "pending": {
    "batch": null,
    "can_apply_now": {
      "available": false,
      "reason": "nothing_pending"
    },
    "environment": {
      "id": 1052,
      "name": "Staging",
      "role": "staging",
      "slug": "staging"
    },
    "items": [],
    "site": {
      "domain": "journal.harbourandfinch.example.com",
      "id": 1051
    },
    "tier": null,
    "window": {
      "date": "2026-11-10",
      "ends_at": "2026-11-11T07:00:00Z",
      "label": "Tonight 21:00–07:00 (Europe/London)",
      "starts_at": "2026-11-10T21:00:00Z"
    }
  },
  "queued": false,
  "quote": {
    "applies": "now",
    "currency": "GBP",
    "effective_from": "2026-11-10T09:00:00Z",
    "expires_at": "2026-11-10T09:15:00Z",
    "id": "4a3f0c1e-2b7d-4c55-9e1f-0f6b3c2d1a90",
    "lines": [
      {
        "after": {
          "amount": "75.00",
          "currency": "GBP"
        },
        "before": {
          "amount": "0.00",
          "currency": "GBP"
        },
        "delta": {
          "amount": "75.00",
          "currency": "GBP"
        },
        "key": "uat",
        "label": "Staging environment: small → medium"
      }
    ],
    "monthly_after": {
      "amount": "75.00",
      "currency": "GBP"
    },
    "monthly_before": {
      "amount": "0.00",
      "currency": "GBP"
    },
    "monthly_delta": {
      "amount": "75.00",
      "currency": "GBP"
    },
    "prorata": {
      "amount": {
        "amount": "51.56",
        "currency": "GBP"
      },
      "from": "2026-11-10T09:00:00Z",
      "hours": 495,
      "to": "2026-12-01T00:00:00Z"
    },
    "tax": {
      "amount": {
        "amount": "15.00",
        "currency": "GBP"
      },
      "kind": "standard",
      "note": "UK VAT 20 %",
      "rate_percent": 20
    },
    "trial": null
  },
  "site": {
    "access_summary": {
      "apply_state": "never",
      "company_keys": 0,
      "keys": 0,
      "users": 0
    },
    "actions": {
      "apply_pending_now": {
        "available": false,
        "reason": "Nothing is waiting for tonight."
      },
      "attach_domain": {
        "available": true,
        "reason": null
      },
      "change_url": {
        "available": false,
        "reason": "Domains are switched off at the moment"
      },
      "clone": {
        "available": true,
        "reason": null
      },
      "create_environment": {
        "available": true,
        "reason": null
      },
      "delete": {
        "available": true,
        "reason": null
      },
      "go_live": {
        "available": true,
        "reason": null
      },
      "maintenance": {
        "available": true,
        "reason": null
      },
      "push_to_live": {
        "available": true,
        "reason": null
      },
      "restore_deleted": {
        "available": false,
        "reason": "Environments are removed at once. Recreate it from the final snapshot."
      },
      "terminal": {
        "available": false,
        "reason": "The terminal is available once the site is running"
      }
    },
    "adoption": "adopted",
    "cloudflare": {
      "connected": false,
      "zone": null
    },
    "cluster": {
      "id": 1017,
      "name": "Northwind UK 1"
    },
    "commands": [],
    "compute_family": "general",
    "counts": {
      "crons": 1
    },
    "crons_enabled": false,
    "database": {
      "host": "127.0.0.1",
      "name": "wordpress",
      "password_revealable": true,
      "port": 3306,
      "username": "application",
      "via": "SSH tunnel"
    },
    "deleted": null,
    "deploy_mode": "manual",
    "deploy_mode_label": "Manual",
    "deployments_summary": {
      "last": null,
      "mode": "manual"
    },
    "domain": "journal.harbourandfinch.example.com",
    "domains_summary": {
      "aliases": 0,
      "dns": "unknown",
      "noindex": true,
      "primary": null,
      "tls": "none",
      "www": null
    },
    "email_summary": {
      "sending_domain": null,
      "state": "preview"
    },
    "environment": {
      "env_id": "rs-northwind-journal-harbourandfinch-example-com--staging",
      "hostname": "journal-harbourandfinch-example-com-staging.northwind.cfstack.example.net",
      "id": 1052,
      "name": "Staging",
      "role": "staging",
      "role_label": "Staging",
      "slug": "staging"
    },
    "environments": [
      {
        "env_id": "rs-northwind-journal-harbourandfinch-example-com",
        "hostname": "journal-harbourandfinch-example-com.northwind.cfstack.example.net",
        "id": 1051,
        "name": "Production",
        "role": "production",
        "role_label": "Production",
        "slug": "production"
      },
      {
        "env_id": "rs-northwind-journal-harbourandfinch-example-com--staging",
        "hostname": "journal-harbourandfinch-example-com-staging.northwind.cfstack.example.net",
        "id": 1052,
        "name": "Staging",
        "role": "staging",
        "role_label": "Staging",
        "slug": "staging"
      }
    ],
    "final_snapshot_note": "Snapshots are off for this cluster, so no final copy is taken: it cannot be brought back afterwards.",
    "health": "applying",
    "hosting": {
      "cluster_kind": "customer",
      "label": "CoreCluster Northwind UK 1"
    },
    "http_auth_summary": {
      "apply_state": "applied",
      "enabled": true,
      "rules": 0,
      "users": 0
    },
    "id": 1052,
    "kind": "corestack",
    "lifecycle": "active",
    "limits": {
      "cpu_millicores": 2000,
      "disk_bytes": 10737418240,
      "memory_bytes": 4294967296
    },
    "logs": null,
    "maintenance": {
      "bypass_corefinity": 1,
      "bypass_ips": [],
      "enabled": false,
      "since": null
    },
    "mariadb": {
      "version": "11.4"
    },
    "mode": "staging",
    "mode_label": "No domain",
    "operation": {
      "id": 5121,
      "scope": "site",
      "status": "committed",
      "status_label": "Waiting for the platform",
      "summary": "Resize environment",
      "to_version": null,
      "type": "uat_resize",
      "type_label": "Resize environment"
    },
    "operations": [],
    "package": null,
    "pending_changes": {
      "count": 0,
      "outcome_at": null,
      "state": null,
      "window_starts_at": null
    },
    "php": {
      "version": "8.3"
    },
    "platform": {
      "key": "wordpress",
      "label": "WordPress"
    },
    "platform_url": "https://journal-harbourandfinch-example-com-staging.northwind.cfstack.example.net",
    "preview": {
      "label": "Platform address",
      "protected": true,
      "url": "https://journal-harbourandfinch-example-com-staging.northwind.cfstack.example.net"
    },
    "primary_url": null,
    "production_hosts": [],
    "provisioning": null,
    "removed": false,
    "restore": null,
    "settings": {
      "auto_deploy": false,
      "http_auth_enabled": true,
      "scheduled_snapshots": false
    },
    "site": {
      "domain": "journal.harbourandfinch.example.com",
      "id": 1051
    },
    "site_id": "rs-northwind-journal-harbourandfinch-example-com--staging",
    "snapshots": {
      "count": 0,
      "effective_frequency": "off",
      "effective_label": "Off",
      "latest": null,
      "latest_ready_at": null,
      "next_scheduled_at": null,
      "overridden": false,
      "stored_gb": 0
    },
    "ssh": {
      "command": "ssh -p 20002 web@ssh-northwind.example.net",
      "host": "ssh-northwind.example.net",
      "key_management": false,
      "keys": [],
      "port": 20002,
      "sftp_command": "sftp -P 20002 web@ssh-northwind.example.net",
      "tunnel_command": "ssh -N -L 3306:127.0.0.1:3306 -p 20002 web@ssh-northwind.example.net",
      "user": "web",
      "users": 0
    },
    "tier": "small",
    "uat_size": null,
    "usage": {
      "cpu_millicores": null,
      "disk_used_bytes": null,
      "memory_bytes": null,
      "observed_at": null,
      "source": null
    }
  }
}
```

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

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

### 403 The token lacks the `write` scope (`scope_required`), two-factor authentication is required and not set up, or you may not make this change: `forbidden`, with the `permission` you lack where a permission decides it, or a reason of its own that the message explains.

```json
{
  "code": "forbidden",
  "message": "Billing for this site is Harbour & Finch's.",
  "reason": "forbidden"
}
```

### 404 The id does not exist or is something you cannot change, or the feature is not on for your company (`feature_off`): environments, or the feature a field of the request belongs to.

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

### 409 The change cannot be made now. `reason` says why: `managed_elsewhere`, `deleted`, `provisioning`, `busy` (another change is running) or a reason of the change's own, which the message explains.

```json
{
  "code": "busy",
  "message": "Another change to this site is in progress. Wait for it to finish.",
  "reason": "busy"
}
```

### 422 A field is missing or wrong (`invalid`): `field` names the first one and `errors` lists every one. A field of a feature that is switched off is refused here with `feature_off` on that field. Nothing in the request is applied.

```json
{
  "code": "invalid",
  "errors": {
    "name": [
      "Give the environment a name"
    ]
  },
  "field": "name",
  "message": "Give the environment a name",
  "reason": "invalid"
}
```

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

## If it is refused

| Status | Reason | What to do |
|---|---|---|
| 401 |  | Send a valid token as `Authorization: Bearer <token>`. |
| 403 | `forbidden` | The person is not allowed to do this. |
| 403 | `billing_forbidden` | Billing is for the organisation's owner and billing contacts. Ask one of them to do this. |
| 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 | `busy` | Another operation is running on the site. Wait for it to finish. |
| 409 | `contract_missing` | There is no billing contract to price this against. Ask support to set up billing, or make the change without a quote where that is offered. |
| 409 | `included_size` | The included staging environment cannot be smaller than its included size. Choose that size or a larger one. |
| 409 | `managed_elsewhere` | This site is read-only here. Change it in the control panel that manages it. |
| 409 | `no_payment_method` | There is no payment method on the account. Add a card or a Direct Debit mandate first. |
| 409 | `stale` | What you read has changed since you read it. Read it again, then send the change with its new version or quote. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

- Guide: [Create an environment](https://docs.corefinity.com/guides/sites/environments-and-copies/create-an-environment.md)
- MCP tool: [`corestack_environment_update`](https://docs.corefinity.com/mcp/tools/corestack_environment_update.md)
