Update an environment's variable
Creates the variable when the environment does not have it (201), and changes it otherwise (200). Leave value out to keep the stored value, so a rename never needs it; a new variable needs one. The answer carries the mask, never the value.
Path parameters
The id of a CoreStack Enterprise environment. Not the same number as a site row id. At least 1.
The variable's name, without the CF_ prefix builds see it with. A new name is letters, digits and underscores, starting with a letter or underscore, at most 64 characters; a variable the environment already has is found by its stored name as it is, whatever the rules were when it was saved.
Body
A new name for the variable, which keeps its value unless value changes it in the same request: letters, digits and underscores, starting with a letter or underscore, at most 64 characters, and not starting with CF_ in any case. Null, or the name it already has, renames nothing.
Leave out to keep the stored value. An empty string or null clears it. Any other string sets it, exactly as sent: at most 2,048 characters, with no line breaks, control or invisible formatting characters.
Returns
200 The variable after the change.
201 The variable was created.
Fields of the 200 answer
Fields
The mask shown in place of the value. A value of 16 characters or more also shows its last four.
When the variable last changed, in UTC. Format: date-time.
Fields of the 201 answer
Fields
The mask shown in place of the value. A value of 16 characters or more also shows its last four.
When the variable last changed, in UTC. Format: date-time.
If it is refused
| Status | Reason | What to do |
|---|---|---|
401 | none | 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 | none | Check the id. You see only what your account can reach. |
409 | exists | It already exists. Use the existing one. |
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 | invalid | Fix the field named in field; errors says why. |
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. |
Reasons are listed by name in Errors and refusals.
The same task elsewhere
curl -X PUT https://manage.corefinity.com/api/environments/1311/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"
}'use Illuminate\Support\Facades\Http;
$response = Http::withToken(env('COREFINITY_TOKEN'))
->acceptJson()
->put('https://manage.corefinity.com/api/environments/1311/variables/API_TOKEN', [
'value' => 'example-value-not-a-real-secret',
]);
$data = $response->json();const res = await fetch('https://manage.corefinity.com/api/environments/1311/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);import os
import requests
res = requests.put(
"https://manage.corefinity.com/api/environments/1311/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{
"variable": {
"masked": "••••••••cret",
"name": "API_TOKEN",
"updated_at": "2026-11-09T10:42:07Z"
}
}{
"variable": {
"masked": "••••••••cret",
"name": "SEARCH_API_KEY",
"updated_at": "2026-11-09T10:42:07Z"
}
}{
"message": "Unauthenticated."
}{
"code": "company_unavailable",
"message": "Your company is unavailable.",
"reason": "company_unavailable"
}{
"message": "Not found."
}{
"code": "exists",
"message": "This environment already has a variable with that name.",
"reason": "exists"
}{
"code": "variable_invalid",
"errors": {
"name": [
"Use letters, digits and underscores, starting with a letter or underscore, without the CF_ prefix (CoreStack adds it)."
]
},
"message": "Use letters, digits and underscores, starting with a letter or underscore, without the CF_ prefix (CoreStack adds it).",
"reason": "variable_invalid"
}{
"code": "rate_limited",
"message": "Too many requests. Try again in 60 seconds.",
"reason": "rate_limited",
"retry_after_seconds": 60
}Try it is off for this endpointIt has not been cleared for the console. Copy the request and run it yourself when you are sure.