---
title: "Purge a site's Varnish cache"
url: https://docs.corefinity.com/api/reference/varnish/purge-site-varnish
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_purge.md
---
# Purge a site's Varnish cache

Removes pages from the site's Varnish cache: everything, the pages carrying a Magento cache tag, single addresses, or every address matching a pattern. A site may ask for ten purges an hour; Magento's own purges and deployments are not counted. `host` limits a purge by address or by pattern to one of the site's hostnames; a purge of everything or by tag always covers every hostname. Follow the command in the answer.

```http
POST /api/corestack/sites/{site}/varnish/purge
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 10 a minute; 10 an hour for each environment
- Try it in the console: off. It deletes 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.

## Body


## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/varnish/purge \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "host": null,
    "include_query": false,
    "mode": "urls",
    "urls": [
      "/gravel-bikes",
      "/gravel-bikes?colour=red"
    ]
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/sites/1042/varnish/purge', [
        'host' => null,
        'include_query' => false,
        'mode' => 'urls',
        'urls' => [
            '/gravel-bikes',
            '/gravel-bikes?colour=red',
        ],
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/varnish/purge', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    host: null,
    include_query: false,
    mode: 'urls',
    urls: [
      '/gravel-bikes',
      '/gravel-bikes?colour=red',
    ],
  }),
});

// 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/purge",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "host": None,
        "include_query": False,
        "mode": "urls",
        "urls": [
            "/gravel-bikes",
            "/gravel-bikes?colour=red",
        ],
    },
)

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

## Responses

### 202 The purge was sent. `command.status` says how it went.

```json
{
  "command": {
    "blocked_until_verified": false,
    "duration_ms": 840,
    "error": null,
    "exit_code": 0,
    "finished_at": "2026-11-06T09:16:41Z",
    "id": 905,
    "input": {
      "host": null,
      "mode": "tags",
      "tags": [
        "cat_p_1180",
        "cat_c_27"
      ],
      "target": "varnish",
      "via": "api"
    },
    "kind": "varnish_purge",
    "label": "Varnish purged · by tag",
    "operation_id": null,
    "output_excerpt": "200",
    "queued_at": "2026-11-06T09:16:40Z",
    "requested_by": {
      "id": 2041,
      "name": "Eleanor Finch"
    },
    "result": {
      "confirmed": true,
      "count": 2,
      "hosts": [],
      "mode": "tags",
      "objects": null,
      "requests": 1,
      "seconds": 0,
      "sent": 1,
      "target": "varnish"
    },
    "site": {
      "domain": "harbourandfinch.example.com",
      "id": 1042
    },
    "started_at": "2026-11-06T09:16:40Z",
    "status": "succeeded",
    "status_label": "Done"
  }
}
```

### 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 purge cannot run now. `reason` says why: `varnish_off` (Varnish is off), `varnish_not_offered` (not a Magento 2 site), `deleted` or `provisioning` (the site is deleted, or still being created), `busy`, `command_running`, `restore_running` or `deployment_running` (other work on the site has not finished), `exec_unresolved` or `install_running` (contact support), `removed` or `managed_elsewhere`.

```json
{
  "code": "command_running",
  "message": "Another action is still running on this site. Wait for it to finish.",
  "reason": "command_running"
}
```

### 422 What to purge is missing or wrong. `reason` is `invalid_arguments` (with `field`), or names the list that was refused: `invalid_tags`, `invalid_urls`, `invalid_pattern` or `host_not_owned` (an address on a hostname that is not the site's). `offenders` lists each refused item.

```json
{
  "code": "host_not_owned",
  "errors": {
    "urls.0": [
      "old.harbourandfinch.example.org is not one of this site's hosts."
    ]
  },
  "message": "old.harbourandfinch.example.org is not one of this site's hosts.",
  "offenders": [
    {
      "field": "urls",
      "index": 0,
      "message": "old.harbourandfinch.example.org is not one of this site's hosts.",
      "value": "https://old.harbourandfinch.example.org/x"
    }
  ],
  "reason": "host_not_owned"
}
```

### 429 Too many requests (`rate_limited`): the endpoint's request limit, or the site's ten purges this hour, which the Control Panel and AI assistants spend too. Wait for `Retry-After`, which `retry_after_seconds` repeats; the purge allowance's answer also carries `retry_after` and `available_at`.

```json
{
  "available_at": "2026-11-03T10:16:40Z",
  "code": "rate_limited",
  "message": "Ten purges an hour for this site have been used. The next is available in 60 minutes. Magento's own purges and deployments are not affected.",
  "reason": "rate_limited",
  "retry_after": 3600,
  "retry_after_seconds": 3600
}
```

### 503 Corefinity has switched commands on sites off for the moment (`switched_off`). Try again later.

```json
{
  "code": "switched_off",
  "message": "Site commands are switched off at the moment",
  "reason": "switched_off"
}
```

## 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 | `command_running` | Another action or command is still running on the site. Wait for it to finish, then try again. |
| 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 | `host_not_owned` | A URL names a host that is not one of the site's. Purge only the site's own hosts. |
| 422 | `invalid_arguments` | The arguments do not match the tool's input schema, or the Control Panel refused a field. Fix the fields named in the answer and call again. |
| 422 | `invalid_tags` | A cache tag is not one. Send tags as the site sets them. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 503 | `switched_off` | Corefinity has switched this action off for the moment. Try again later. |

## The same task elsewhere

- Guide: [Varnish](https://docs.corefinity.com/guides/sites/software-and-services/varnish.md)
- MCP tool: [`corestack_varnish_purge`](https://docs.corefinity.com/mcp/tools/corestack_varnish_purge.md)
