---
title: "Replace the allowed addresses"
url: https://docs.corefinity.com/api/reference/database/replace-site-external-database-sources
type: endpoint
last_updated: 2026-11-13
feature: database
related:
  - https://docs.corefinity.com/guides/sites/database/database-users.md
  - https://docs.corefinity.com/mcp/tools/corestack_external_db_sources_set.md
---
# Replace the allowed addresses

Replaces the list of addresses that may reach the database from outside: send every address to keep, at least
one and at most 10, while access is on. New labels alone are saved at once and answer `200` with
`operation: null`; a changed list answers `202` and applies in about a minute. The documentation ranges the
examples here use are refused: send your own systems' public addresses.

```http
PUT /api/corestack/sites/{site}/external-db/sources
```

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

- `sources` (array of objects, required): The whole list, every address to keep included.
  - `cidr` (string, required): A public IPv4 address, or a block from `/32` to `/28` written from its first address. Private, shared, loopback, link-local, multicast, reserved and documentation ranges are refused.
  - `label` (string or null)

## Request

### curl

```bash
curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/external-db/sources \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "sources": [
      {
        "cidr": "198.51.100.64/29",
        "label": "Order system"
      },
      {
        "cidr": "192.0.2.15/32",
        "label": "Reporting"
      },
      {
        "cidr": "203.0.113.20/32",
        "label": "Warehouse"
      }
    ]
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->put('https://manage.corefinity.com/api/corestack/sites/1042/external-db/sources', [
        'sources' => [
            [
                'cidr' => '198.51.100.64/29',
                'label' => 'Order system',
            ],
            [
                'cidr' => '192.0.2.15/32',
                'label' => 'Reporting',
            ],
            [
                'cidr' => '203.0.113.20/32',
                'label' => 'Warehouse',
            ],
        ],
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/external-db/sources', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    sources: [
      {
        cidr: '198.51.100.64/29',
        label: 'Order system',
      },
      {
        cidr: '192.0.2.15/32',
        label: 'Reporting',
      },
      {
        cidr: '203.0.113.20/32',
        label: 'Warehouse',
      },
    ],
  }),
});

// 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/external-db/sources",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "sources": [
            {
                "cidr": "198.51.100.64/29",
                "label": "Order system",
            },
            {
                "cidr": "192.0.2.15/32",
                "label": "Reporting",
            },
            {
                "cidr": "203.0.113.20/32",
                "label": "Warehouse",
            },
        ],
    },
)

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

## Responses

### 200 Only labels changed. They are saved, nothing was started and `operation` is null.

```json
{
  "operation": null,
  "sources": [
    {
      "added_at": "2026-11-02T15:41:09+00:00",
      "added_by": "Daniel Reyes",
      "cidr": "192.0.2.15/32",
      "label": "Reporting",
      "pending": false
    },
    {
      "added_at": "2026-11-02T15:41:09+00:00",
      "added_by": "Daniel Reyes",
      "cidr": "198.51.100.64/29",
      "label": "Order system (London)",
      "pending": false
    }
  ]
}
```

### 202 The list changed and is being applied. Follow `operation.id` until it completes.

```json
{
  "operation": {
    "applied_at": null,
    "can_retry": false,
    "cluster": {
      "id": 1017,
      "name": "Northwind UK 1"
    },
    "committed_at": null,
    "completed_at": null,
    "created_at": "2026-11-03T09:16:40Z",
    "environment": {
      "env_id": "rs-northwind-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": false,
    "id": 5122,
    "install": null,
    "label": "Saved",
    "notes": [],
    "parent_operation_id": null,
    "requested_by": {
      "id": 2012,
      "name": "Daniel Reyes"
    },
    "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": "executing",
    "status_label": "Saving the change",
    "step": "saved",
    "steps": [
      {
        "key": "saved",
        "label": "Saved",
        "state": "current"
      },
      {
        "key": "applied",
        "label": "Picked up by the platform",
        "state": "todo"
      },
      {
        "key": "live",
        "label": "Allowed addresses live",
        "state": "todo"
      }
    ],
    "subject": null,
    "summary": "Allowed addresses changed (3 on the list)",
    "to_version": null,
    "type": "external_db_change",
    "type_label": "External database access"
  }
}
```

### 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 list cannot be changed now. `reason` says why: `external_db_not_on` (turn access on first), `external_db_unchanged` (the list is already exactly this), `busy`, `deleted`, `provisioning`, `removed` or `managed_elsewhere`.

```json
{
  "code": "busy",
  "message": "A change to external access is already in progress on this environment.",
  "reason": "busy"
}
```

### 422 The list or one of its addresses is refused (`invalid`). `errors` names each one by its position, such as `sources.0.cidr`, and `field` the first.

```json
{
  "code": "invalid",
  "errors": {
    "sources.0.cidr": [
      "198.51.100.64/29 is a documentation range. Use a public IPv4 address, or a block from /32 to /28."
    ],
    "sources.1.cidr": [
      "203.0.113.20/32 is a documentation address. Use a public IPv4 address, or a block from /32 to /28."
    ]
  },
  "field": "sources.0.cidr",
  "message": "198.51.100.64/29 is a documentation range. Use a public IPv4 address, or a block from /32 to /28. (and 1 more error)",
  "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
}
```

## 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 | `external_db_not_on` | External access is off. Turn it on first. |
| 409 | `external_db_unchanged` | The allowed addresses are already exactly these. Nothing to do. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

- Guide: [Database users](https://docs.corefinity.com/guides/sites/database/database-users.md)
- MCP tool: [`corestack_external_db_sources_set`](https://docs.corefinity.com/mcp/tools/corestack_external_db_sources_set.md)
