---
title: "Restore a VCL revision"
url: https://docs.corefinity.com/api/reference/varnish/restore-site-varnish-vcl-revision
type: endpoint
last_updated: 2026-11-13
feature: varnish
related:
  - https://docs.corefinity.com/guides/sites/software-and-services/varnish.md
  - https://docs.corefinity.com/mcp/tools/corestack_varnish_vcl_revert.md
---
# Restore a VCL revision

Saves a revision's snippets again, as a new revision, and loads it like any save. It takes no body.

```http
POST /api/corestack/sites/{site}/varnish/vcl/revisions/{number}/revert
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 20 a minute; 20 a minute for each environment
- 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.
- `number` (integer, required): A revision's `number`, from the list. The first is 0.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/varnish/vcl/revisions/0/revert \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json"
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/sites/1042/varnish/vcl/revisions/0/revert');

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/varnish/vcl/revisions/0/revert', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
  },
});

// 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/varnish/vcl/revisions/0/revert",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
)

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

## Responses

### 200 Nothing to follow: the VCL is what the site already has (`revision` and `operation` null), or Varnish is off, so the VCL was saved and loads when Varnish is switched on (`varnish_off: true`).

```json
{
  "operation": null,
  "revision": null
}
```

### 202 The VCL was saved and is being loaded, which takes about a minute. Follow `operation`: its `vcl.outcome` says whether Varnish loaded it.

```json
{
  "operation": {
    "applied_at": null,
    "can_retry": false,
    "cluster": {
      "id": 1017,
      "name": "Northwind UK 1"
    },
    "committed_at": "2026-11-06T09:16:40Z",
    "completed_at": null,
    "created_at": "2026-11-06T09:16: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": 5125,
    "install": null,
    "label": "Loaded by Varnish",
    "notes": [],
    "parent_operation_id": null,
    "requested_by": {
      "id": 2041,
      "name": "Eleanor Finch"
    },
    "reset_target": null,
    "result": null,
    "result_state": "none",
    "retried_by_operation_id": null,
    "retries_operation_id": null,
    "retry_requires": null,
    "revealed": null,
    "scope": "site",
    "site": {
      "domain": "harbourandfinch.example.com",
      "id": 1042
    },
    "status": "committed",
    "status_label": "Waiting for the platform",
    "step": "loaded",
    "steps": [
      {
        "key": "policy",
        "label": "Checked against the policy",
        "state": "done"
      },
      {
        "key": "compiled",
        "label": "Compiled",
        "state": "done"
      },
      {
        "key": "loaded",
        "label": "Loaded by Varnish",
        "state": "current"
      },
      {
        "key": "checked",
        "label": "Checked",
        "state": "todo"
      }
    ],
    "subject": null,
    "summary": "Varnish VCL",
    "to_version": null,
    "type": "varnish_vcl_change",
    "type_label": "Varnish VCL"
  },
  "revision": {
    "number": 2,
    "status": "saving"
  },
  "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 site does not exist or is something you cannot change, the site has no revision with that number (`not_found`), or the feature is not on for your company (`feature_off`).

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

### 409 The revert was refused because of the site's state. `reason` says why: `varnish_off` (Varnish has never been set up on the site: switch it on first), `varnish_not_offered` (not a Magento 2 site), `busy`, `restore_running` or `cluster_paused` (other work has not finished, or changes to the site's cluster are paused), `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 The VCL breaks the policy (`vcl_invalid`) or does not compile on the site's Varnish version (`vcl_compile_failed`), each with `diagnostics`, or Corefinity manages the site's VCL (`vcl_locked`). Nothing was saved.

```json
{
  "code": "vcl_invalid",
  "diagnostics": [
    {
      "code": "VN-POL-09",
      "column": 5,
      "hook": "recv",
      "kind": "policy",
      "line": 1,
      "message": "vcl_recv runs after the front's access control (HTTP authentication, the allow-list, maintenance), which judged the original URL and host: a snippet may not change req.url, the Host header or another routing header (X-Original-URL, X-Rewrite-URL, X-HTTP-Method-Override, X-HTTP-Method, X-Method-Override). Redirect with return (synth(301, \"...\")) instead.",
      "severity": "error"
    }
  ],
  "message": "This VCL cannot be saved: fix the errors shown.",
  "reason": "vcl_invalid"
}
```

### 429 Too many requests (`rate_limited`): the endpoint's request limit, or the 20 VCL saves and reverts a minute this environment takes from the API and AI assistants together. Wait for `Retry-After`, which `retry_after_seconds` repeats; the save allowance's answer also carries `retry_after`.

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

### 503 The site's files could not be read, so nothing was saved (`upstream_unavailable`). Try again in a minute.

```json
{
  "code": "upstream_unavailable",
  "message": "The environment's files could not be read. Try again in a minute.",
  "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. |
| 404 | `not_found` | That revision does not exist. |
| 409 | `busy` | Another operation is running on the site. Wait for it to finish. |
| 409 | `managed_elsewhere` | This site is read-only here. Change it in the control panel that manages it. |
| 409 | `varnish_not_offered` | Varnish is available for Magento 2 sites only. Nothing to change here. |
| 409 | `varnish_off` | Varnish is off on the environment. Switch it on first. |
| 422 | `vcl_invalid` | The VCL breaks a rule of the platform. Nothing was saved. Fix what the message names. |
| 422 | `vcl_locked` | Corefinity manages this environment's VCL. Contact support to change it. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 503 | `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)
- MCP tool: [`corestack_varnish_vcl_revert`](https://docs.corefinity.com/mcp/tools/corestack_varnish_vcl_revert.md)
