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.
Path parameters
The id of a site row. A website's production site and each of its environments has its own id. Digits only. At least 1.
Body
The snippets to change. One left out stays as it is; "" or null empties it.
Fields
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.
6.07.78.09.1nullReturns
200 What the check found. valid is false when a diagnostic is an error.
Fields of the 200 answer
Fields of each item
The policy's rule, such as VN-POL-09; the policy explains each. Left out of a finding of the compiler, which has no rule.
The snippet it is about (recv, backend_response or deliver), or * for the policy's limit on the snippets together. Empty for a finding of the compiler about the VCL as a whole, whose line and column are 0.
What found it: the policy (policy for an error, advice for a warning) or the compiler (compile).
policycompileadviceerrorwarningWhat found it, in words, such as the Varnish version the compile ran on. Left out of a finding of the policy.
The compile. Null when the policy found errors first.
If it is refused
| Status | Reason | What to do |
|---|---|---|
401 | none | 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. |
Reasons are listed by name in Errors and refusals.
The same task elsewhere
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"
}
}'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();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);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{
"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
}{
"message": "Unauthenticated."
}{
"code": "company_unavailable",
"message": "Your company is unavailable.",
"reason": "company_unavailable"
}{
"code": "feature_off",
"message": "Not found.",
"reason": "feature_off"
}{
"code": "managed_elsewhere",
"message": "This site is managed by another control panel",
"reason": "managed_elsewhere"
}{
"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"
}{
"code": "rate_limited",
"message": "Too many requests. Try again in 60 seconds.",
"reason": "rate_limited",
"retry_after_seconds": 60
}{
"code": "upstream_unavailable",
"message": "The environment's files could not be read. Try again in a minute.",
"reason": "upstream_unavailable"
}