---
title: "Update a site's Varnish switch"
url: https://docs.corefinity.com/api/reference/varnish/update-site-varnish
type: endpoint
last_updated: 2026-11-13
feature: varnish
related:
  - https://docs.corefinity.com/guides/sites/software-and-services/varnish.md
---
# Update a site's Varnish switch

Switches Varnish on or off for a Magento 2 site. Switching on without `version` keeps the version the site had last while that version is still allowed for the site, and takes the site's default version (`default_version`) otherwise. The switch takes a few minutes: follow the operation in the answer. With `apply` set to `tonight` or `window`, the switch waits for the site's maintenance window.

```http
PUT /api/corestack/sites/{site}/varnish
```

- 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 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

- `apply` (string): When the change is applied. Here `window` is always taken, and means the same as `tonight`. When a change that needs a maintenance window is applied. `now` applies it at once. `tonight` queues it for the site's next window. `window` means the same as `tonight`. An endpoint that takes `window` only while maintenance windows are on for your company says so, and refuses it `422` on `apply` otherwise. One of `now`, `tonight`, `window`. Defaults to `now`.
- `enabled` (boolean, required)
- `version` (string or null): The version to switch on with, such as `8.0`.

## Request

### curl

```bash
curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/varnish \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": false
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->put('https://manage.corefinity.com/api/corestack/sites/1042/varnish', [
        'enabled' => false,
    ]);

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

### Node

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

// 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.put(
    "https://manage.corefinity.com/api/corestack/sites/1042/varnish",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "enabled": False,
    },
)

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

## Responses

### 202 The change started (`operation`), or waits for the site's window (`queued: true`). Follow a started change with the operation.

```json
{
  "item_id": 77,
  "operation": null,
  "queued": true,
  "window_date": "2026-11-07"
}
```

### 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 The change was refused because of the site's state. `reason` says why: `unchanged` (Varnish is already in that state), `busy`, `restore_running`, `deployment_running`, `command_running` or `snapshot_running` (other work on the site has not finished), `cluster_paused` (changes to the site's cluster are paused), `change_pending` (with `apply`: a change already waits for the window), `image_not_offered` (that version cannot be used at the moment), `memory_split` (Corefinity has divided the site's memory by hand: ask support), `unmanageable` (the site's platform files cannot take the switch: contact support), `conflict` (another change landed first: try again), `removed` or `managed_elsewhere`.

```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`, with `field` and `errors`), or the change was refused for a reason of its own: `varnish_not_offered` (the site is not a Magento 2 site, is smaller than Medium, 8 GB, or needs a platform update before it can use Varnish: the message says which), `varnish_too_small` (the cache would be below 512 MiB), `version_unsupported` (that version is not offered for the site) or `feature_off` when `apply` asks for a window and changes cannot wait for one at the moment.

```json
{
  "code": "feature_off",
  "errors": {
    "apply": [
      "Queuing changes for the maintenance window is switched off at the moment"
    ]
  },
  "message": "Queuing changes for the maintenance window is switched off at the moment",
  "reason": "feature_off"
}
```

### 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 The site's settings could not be read, so nothing was changed (`upstream_unavailable`). Try again shortly.

```json
{
  "code": "upstream_unavailable",
  "message": "The site's settings could not be read; try again shortly.",
  "reason": "upstream_unavailable"
}
```

## 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 | `busy` | Another operation is running on the site. Wait for it to finish. |
| 409 | `image_not_offered` | The version this change needs is not available right now. Nothing was changed. |
| 409 | `managed_elsewhere` | This site is read-only here. Change it in the control panel that manages it. |
| 409 | `memory_split` | Corefinity staff have divided the environment's memory between its services by hand, and this change would undo that. Ask support to make the change. |
| 409 | `unchanged` | Nothing would change. Nothing to do. |
| 422 | `feature_off` | This feature is not on for your organisation yet. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 422 | `varnish_not_offered` | Varnish is available for Magento 2 sites only. Nothing to change here. |
| 422 | `varnish_too_small` | Varnish needs more memory than the package's cache share gives it. Choose a larger package, or switch RabbitMQ off. |
| 422 | `version_unsupported` | That Varnish version is not offered, or not available yet. Choose another version. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 502 | `upstream_unavailable` | A service the action depends on did not answer. Try again later. |

## The same task elsewhere

- Guide: [Varnish](https://docs.corefinity.com/guides/sites/software-and-services/varnish.md)
