---
title: "Update a site's deployment variable"
url: https://docs.corefinity.com/api/reference/deployments/update-site-deployment-variable
type: endpoint
last_updated: 2026-11-13
feature: deployment-variables
related:
  - https://docs.corefinity.com/guides/sites/code-and-deployments/variables-and-secrets.md
  - https://docs.corefinity.com/mcp/tools/corestack_deployments_variable_set.md
---
# Update a site's deployment variable

Creates the variable when the environment does not have it and changes it otherwise, then answers the whole
list with each value masked. A new variable needs a `value`, and making a stored value `shown` in deployment
logs needs the value sent with it.

```http
PUT /api/corestack/sites/{site}/deployments/variables/{name}
```

- Scope: `write`
- Two-factor: required on your account (all)
- Rate limit: 20 a minute
- 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.
- `name` (string, required): The variable's name, without the `CF_` prefix builds see it with: letters, digits and underscores, starting with a letter or underscore, at most 64 characters. Any other name is refused `422` `invalid` on `name`.

## Body

- `log_visibility` (string): Whether the value may appear in deployment logs. `hidden`, the default, masks it there. One of `hidden`, `shown`.
- `value` (string): The value, kept exactly as sent: at most 2,048 characters, with no line breaks, control or invisible formatting characters. Leave out to change only `log_visibility`.

## Request

### curl

```bash
curl -X PUT https://manage.corefinity.com/api/corestack/sites/1042/deployments/variables/API_TOKEN \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "example-value-not-a-real-secret"
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->put('https://manage.corefinity.com/api/corestack/sites/1042/deployments/variables/API_TOKEN', [
        'value' => 'example-value-not-a-real-secret',
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/sites/1042/deployments/variables/API_TOKEN', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    value: 'example-value-not-a-real-secret',
  }),
});

// 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/deployments/variables/API_TOKEN",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "value": "example-value-not-a-real-secret",
    },
)

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

## Responses

### 200 The environment's variables after the change.

```json
{
  "data": [
    {
      "log_visibility": "hidden",
      "masked": "••••••••cret",
      "name": "API_TOKEN",
      "overrides": null,
      "replaces_platform": false,
      "tool_credential": null,
      "updated_at": "2026-11-09T10:42:07Z",
      "updated_by": null,
      "used_in": []
    },
    {
      "log_visibility": "shown",
      "masked": "••••••••.com",
      "name": "API_URL",
      "overrides": null,
      "replaces_platform": false,
      "tool_credential": null,
      "updated_at": "2026-11-09T10:42:07Z",
      "updated_by": null,
      "used_in": []
    }
  ],
  "inherited": []
}
```

### 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 site is managed by another control panel, so it cannot be changed here.

```json
{
  "code": "managed_elsewhere",
  "message": "This site is managed by another control panel",
  "reason": "managed_elsewhere"
}
```

### 422 The request was refused and nothing was stored. `errors` names the field. - `invalid`: a field of the wrong type or one this endpoint does not take, a `value` longer than 2,048 characters, a `log_visibility` that is neither `hidden` nor `shown`, a name that is not letters, digits and underscores or is longer than 64 characters (on `name`), a body with neither `value` nor `log_visibility` (on `value`), or `log_visibility` `shown` for a stored value without the value. - `variable_invalid`: a name that starts with `CF_`, in either case, a new variable sent without a `value`, or a value with a line break, control or invisible formatting character. - `variable_reserved`: a new variable with a name CoreStack sets itself. - `variable_tool_credential`: a new variable with a name a build tool reads its own credentials from, such as `NPM_TOKEN`. - `too_many_variables`: the environment holds as many variables as it can.

```json
{
  "code": "invalid",
  "errors": {
    "name": [
      "The name argument is not in the expected format."
    ]
  },
  "field": "name",
  "message": "Some arguments are not valid.",
  "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 | `managed_elsewhere` | This site is read-only here. Change it in the control panel that manages it. |
| 422 | `invalid` | Fix the field named in `field`; `errors` says why. |
| 422 | `variable_invalid` | Use letters, digits and underscores, starting with a letter or underscore, without the CF_ prefix (CoreStack adds it). |
| 422 | `variable_reserved` | CF_DOMAIN is set by CoreStack. Choose another name. |
| 422 | `too_many_variables` | This environment already has the most variables it can hold. |
| 422 | `variable_tool_credential` | Builds see the variable under another name, so the tool it is meant for never reads it. Add the credentials under Deployments, Private registries, instead. |
| 429 | `rate_limited` | Wait for the seconds in `Retry-After`. |

## The same task elsewhere

- Guide: [Variables](https://docs.corefinity.com/guides/sites/code-and-deployments/variables-and-secrets.md)
- MCP tool: [`corestack_deployments_variable_set`](https://docs.corefinity.com/mcp/tools/corestack_deployments_variable_set.md)
