---
title: "Purge a site's Cloudflare cache"
url: https://docs.corefinity.com/api/reference/domains/purge-site-cloudflare-cache
type: endpoint
last_updated: 2026-11-13
feature: cloudflare
related:
  - https://docs.corefinity.com/guides/sites/go-live/cloudflare-for-a-site.md
  - https://docs.corefinity.com/mcp/tools/corestack_site_cloudflare_purge.md
---
# Purge a site's Cloudflare cache

Purges the whole zone, or up to 30 addresses on the site's own domains. The purge is sent to Cloudflare before
the answer: the command in the answer says whether it `succeeded` or `failed`, and stays readable at
`GET /corestack/commands/{command}`. When Varnish is on for the site its cache is purged first, unless
`varnish_first` is false.

```http
POST /api/corestack/sites/{site}/cloudflare/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

- `everything` (boolean)
- `urls` (array of strings): Addresses starting `http://` or `https://` on one of the site's own domains.
- `varnish_first` (boolean): Whether to purge the site's Varnish cache first, when Varnish is on. Left out, it does.

## Request

### curl

```bash
curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/cloudflare/purge \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "everything": true
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->post('https://manage.corefinity.com/api/corestack/sites/1042/cloudflare/purge', [
        'everything' => true,
    ]);

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

### Node

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

// 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/cloudflare/purge",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "everything": True,
    },
)

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

## Responses

### 202 The purge was sent. `command.status` is `succeeded`, with what was purged in `result`, or `failed`, with Cloudflare's refusal in `error`.

```json
{
  "command": {
    "blocked_until_verified": false,
    "duration_ms": 547,
    "error": "Cloudflare did not answer. Try again in a minute.",
    "exit_code": null,
    "finished_at": "2026-11-06T08:07:03Z",
    "id": 2036,
    "input": {
      "everything": true
    },
    "kind": "cloudflare_purge",
    "label": "Purge Cloudflare cache",
    "operation_id": null,
    "output_excerpt": null,
    "queued_at": "2026-11-06T08:07:02Z",
    "requested_by": {
      "id": 5021,
      "name": "Eleanor Finch"
    },
    "result": null,
    "site": {
      "domain": "harbourandfinch.example.com",
      "id": 1042
    },
    "started_at": "2026-11-06T08:07:02Z",
    "status": "failed",
    "status_label": "Failed"
  }
}
```

### 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 `not_connected`, `no_zone`, `deleted`, `provisioning`, `managed_elsewhere`, or the site cannot take the purge now: `busy` (another change is running), `command_running` (another command is running), `restore_running`, `deployment_running`, `removed` or `exec_unresolved`.

```json
{
  "code": "no_zone",
  "message": "This site's domain is not in a connected Cloudflare zone",
  "reason": "no_zone"
}
```

### 422 Send either `everything` or `urls`, never both; every address must be on one of the site's domains. Also answered when the token may not purge the cache.

```json
{
  "code": "invalid",
  "errors": {
    "urls": [
      "Purge everything, or give 1–30 URLs on this site's addresses"
    ]
  },
  "field": "urls",
  "message": "Purge everything, or give 1–30 URLs on this site's addresses",
  "reason": "invalid"
}
```

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

```json
{
  "code": "rate_limited",
  "message": "Too many purges for this site. Try again in a few minutes.",
  "reason": "rate_limited",
  "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 | `no_zone` | The site's domain is not in a connected Cloudflare zone, or Cloudflare is off for the site. Connect the Cloudflare account that holds the zone. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 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: [Cloudflare for a site](https://docs.corefinity.com/guides/sites/go-live/cloudflare-for-a-site.md)
- MCP tool: [`corestack_site_cloudflare_purge`](https://docs.corefinity.com/mcp/tools/corestack_site_cloudflare_purge.md)
