---
title: "Check custom VCL without saving"
url: https://docs.corefinity.com/api/reference/varnish/check-site-varnish-vcl
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_validate.md
---
# Check custom VCL without saving

Checks the snippets sent in `hooks` against the policy and, when they pass, compiles them with the site's Varnish version, or with `varnish_version`. Nothing is saved.

```http
POST /api/corestack/sites/{site}/varnish/vcl/validate
```

- Scope: `read`
- Two-factor: required on your account (all)
- Rate limit: 120 a minute
- Try it in the console: on

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

- `hooks` (object, required): The snippets to change. One left out stays as it is; `""` or null empties it.
  - `backend_response` (string or null)
  - `deliver` (string or null)
  - `recv` (string or null)
- `varnish_version` (string or null): A Varnish version to compile with instead of the site's, such as `8.0`. One that is not available yet is refused `version_unsupported`. One of `6.0`, `7.7`, `8.0`, `9.1`, `null`.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/varnish/vcl/validate \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "hooks": {
      "recv": "if (req.url ~ \"^/stock-checker/\") {\n    return (pass);\n}\n"
    }
  }'
```

### 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/validate', [
        'hooks' => [
            'recv' => 'if (req.url ~ "^/stock-checker/") {
    return (pass);
}
',
        ],
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/varnish/vcl/validate', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    hooks: {
      recv: 'if (req.url ~ "^/stock-checker/") {\n    return (pass);\n}\n',
    },
  }),
});

// 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/validate",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "hooks": {
            "recv": "if (req.url ~ \"^/stock-checker/\") {\n    return (pass);\n}\n",
        },
    },
)

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

## Responses

### 200 What the check found. `valid` is false when a diagnostic is an error.

```json
{
  "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"
    }
  ],
  "test": null,
  "valid": false
}
```

### 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 site is not a Magento 2 site (`varnish_not_offered`), Varnish has never been set up on it (`varnish_off`: switch it on first), or it is managed by another control panel (`managed_elsewhere`).

```json
{
  "code": "managed_elsewhere",
  "message": "This site is managed by another control panel",
  "reason": "managed_elsewhere"
}
```

### 422 A field is missing or wrong (`invalid`, with `field` and `errors`), or `varnish_version` is not a version Varnish is offered in, or one that is not available yet (`version_unsupported`).

```json
{
  "code": "invalid",
  "errors": {
    "hooks": [
      "hooks is an object of recv, backend_response and deliver, each text or null."
    ]
  },
  "field": "hooks",
  "message": "hooks is an object of recv, backend_response and deliver, each text or null.",
  "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
}
```

### 503 The site's files could not be read, so nothing was checked (`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. |
| 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 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 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`. |
| 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_validate`](https://docs.corefinity.com/mcp/tools/corestack_varnish_vcl_validate.md)
