---
title: "Update a site's backup-file rule"
url: https://docs.corefinity.com/api/reference/site-settings/update-site-backup-guard
type: endpoint
last_updated: 2026-11-13
feature: nginx-rules
related:
  - https://docs.corefinity.com/guides/sites/site-settings/web-server-rules.md
  - https://docs.corefinity.com/mcp/tools/corestack_nginx_backup_guard_set.md
---
# Update a site's backup-file rule

Switches the rule on or off. The change applies at once, so it cannot be scheduled: follow the operation
in the answer. Sending the state the site already has answers `200` with `operation: null`.

```http
PUT /api/corestack/sites/{site}/nginx-rules/backup-guard
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 60 a minute; 20 a minute for each environment
- Long-running: answers with an operation to poll
- Try it in the console: off. It has not been cleared for the console. 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

- `apply` (string): Only `now`, the default. The change always applies at once. One of `now`.
- `enabled` (boolean, required): True to block backup files, false to stop.

## Request

### curl

```bash
curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules/backup-guard \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": false
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->put('https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules/backup-guard', [
        'enabled' => false,
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules/backup-guard', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    enabled: false,
  }),
});

// 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.put(
    "https://manage.corefinity.com/api/corestack/sites/1042/nginx-rules/backup-guard",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "enabled": False,
    },
)

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

## Responses

### 200 The site already has that state. Nothing was started and `operation` is null.

```json
{
  "backup_guard": {
    "applied": true,
    "attention_extensions": [
      "zip",
      "tar.gz",
      "tgz"
    ],
    "available": true,
    "enabled": true,
    "extensions": [
      "sql",
      "sql.gz"
    ],
    "lines": [
      "set $cf_backup_guard_body \"\";",
      "if ($uri ~* \"\\.(?:sql|sql\\.gz)$\") { return 404 $cf_backup_guard_body; }"
    ],
    "pending": false,
    "platform_enforced": false,
    "switched_off_at": null,
    "uncertain": false
  },
  "operation": null
}
```

### 201 The change was saved and started. Follow `operation`.

```json
{
  "backup_guard": {
    "applied": true,
    "attention_extensions": [
      "zip",
      "tar.gz",
      "tgz"
    ],
    "available": true,
    "enabled": false,
    "extensions": [
      "sql",
      "sql.gz"
    ],
    "lines": [
      "set $cf_backup_guard_body \"\";",
      "if ($uri ~* \"\\.(?:sql|sql\\.gz)$\") { return 404 $cf_backup_guard_body; }"
    ],
    "pending": true,
    "platform_enforced": false,
    "switched_off_at": "2026-11-06T09:16:40Z",
    "uncertain": false
  },
  "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": true,
    "id": 5120,
    "install": null,
    "label": "Picked up by the platform",
    "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": "applied",
    "steps": [
      {
        "key": "saved",
        "label": "Saved",
        "state": "done"
      },
      {
        "key": "applied",
        "label": "Picked up by the platform",
        "state": "current"
      },
      {
        "key": "live",
        "label": "Live",
        "state": "todo"
      }
    ],
    "subject": null,
    "summary": "Backup file blocking",
    "to_version": null,
    "type": "nginx_backup_guard_change",
    "type_label": "Backup file blocking"
  }
}
```

### 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), or your company requires two-factor authentication and you have not set it up. For routes outside Managed Clusters.

```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 switch was refused because of the site's state. `reason` says why: `wrong_platform` (the site's platform always blocks these files, so the rule cannot be switched off), `files_missing` (the site's Nginx files are not ready yet), `busy` (another change is running), `restore_running`, `command_running`, `deployment_running`, `stale` (the rule was changed by someone else at the same moment: read it again), `conflict` (another change to the platform landed first: send the request again), `cluster_paused`, `cluster_not_ready`, `cluster_deleting` or `managed_elsewhere`. A site whose files the Control Panel cannot write answers a sentence only, with no `reason`.

```json
{
  "code": "busy",
  "message": "Another change to this site is in progress. Wait for it to finish.",
  "reason": "busy"
}
```

### 422 `enabled` is missing or not true or false, or the body names another field (`invalid`, with `field`); `apply` is anything but `now` (`apply_not_supported`); the rule is not offered for the site yet (`not_available`); or Corefinity has locked the site's Nginx rules (`nginx_rules_locked`).

```json
{
  "code": "apply_not_supported",
  "field": "apply",
  "message": "This change applies at once, so it cannot be scheduled.",
  "reason": "apply_not_supported"
}
```

### 429 Too many requests (`rate_limited`): the API's general limit, or the 20 saves a minute this environment takes from the API, the Control Panel and AI assistants together. Wait for `Retry-After`, which `retry_after_seconds` repeats.

```json
{
  "code": "rate_limited",
  "message": "Too many attempts on this environment. Try again shortly.",
  "reason": "rate_limited",
  "retry_after_seconds": 60
}
```

### 502 The platform did not answer, or did not save the change. Nothing was switched: send the request again in a minute. The answer is a sentence only, with no `reason`.

```json
{
  "message": "The platform returned an error (HTTP 503). Try again shortly."
}
```

## 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 | `busy` | Another operation is running on the site. Wait for it to finish. |
| 409 | `conflict` | The action conflicts with the object's present state. Read the message. |
| 409 | `files_missing` | The files the Control Panel manages for this are missing or not ready yet. Read the message: try again in a few minutes, keep the Control Panel's version, or contact support. |
| 409 | `managed_elsewhere` | This site is read-only here. Change it in the control panel that manages it. |
| 409 | `restore_running` | A restore is running on the site. Wait for it to finish, then try again. |
| 409 | `wrong_platform` | This is not available for the site's platform. Use it on a site of the platform it is for. |
| 422 | `apply_not_supported` | This change applies at once, so it cannot be scheduled. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 422 | `nginx_rules_locked` | Corefinity has locked this environment's nginx rules. Contact support to change them. |
| 422 | `not_available` | The tool does not apply to this object. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |
| 502 |  | Read the message; it says what happened. |

## The same task elsewhere

- Guide: [Web server rules](https://docs.corefinity.com/guides/sites/site-settings/web-server-rules.md)
- MCP tool: [`corestack_nginx_backup_guard_set`](https://docs.corefinity.com/mcp/tools/corestack_nginx_backup_guard_set.md)
