---
title: "Update a registry secret"
url: https://docs.corefinity.com/api/reference/deployments/update-environment-registry-secret
type: endpoint
last_updated: 2026-11-13
feature: registry-secrets
related:
  - https://docs.corefinity.com/guides/sites/code-and-deployments/registry-secrets.md
---
# Update a registry secret

Changes the fields you send and keeps the rest. A new token replaces the saved one. Anything that changes what
the registry is asked with (the registry, the sign-in type, the username or the token) clears `verified_at`; a
new label keeps it.

```http
PUT /api/corestack/environments/{environment}/deploy-secrets/{secret}
```

- 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

- `environment` (integer, required): The id of a CoreStack Enterprise environment. Not the same number as a site row id.
- `secret` (integer, required): The id of a registry secret of this environment, as the list answers it. Digits only.

## Body

- `auth_type` (string): How the registry signs in. One of `http-basic`, `bearer`, `github-oauth`, `gitlab-token`.
- `label` (string)
- `registry` (string)
- `secret` (string)
- `username` (string)

## Request

### curl

```bash
curl -X PUT https://manage.corefinity.com/api/corestack/environments/1311/deploy-secrets/318 \
  -H "Authorization: Bearer $COREFINITY_TOKEN" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "Harbour & Finch packages"
  }'
```

### PHP

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

$response = Http::withToken(env('COREFINITY_TOKEN'))
    ->acceptJson()
    ->put('https://manage.corefinity.com/api/corestack/environments/1311/deploy-secrets/318', [
        'label' => 'Harbour & Finch packages',
    ]);

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

### Node

```javascript
const res = await fetch('https://manage.corefinity.com/api/corestack/environments/1311/deploy-secrets/318', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
    Accept: 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    label: 'Harbour & Finch packages',
  }),
});

// 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/environments/1311/deploy-secrets/318",
    headers={
        "Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
        "Accept": "application/json",
    },
    json={
        "label": "Harbour & Finch packages",
    },
)

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

## Responses

### 200 The credential after the change.

```json
{
  "data": {
    "auth_type": "bearer",
    "id": 318,
    "kind": "composer",
    "label": "Harbour & Finch packages",
    "last4": "oken",
    "last_used_at": null,
    "registry": "repo.example.com",
    "scope": "",
    "verified_at": null
  }
}
```

### 401 No token, or a token that is not valid.

```json
{
  "message": "Unauthenticated."
}
```

### 403 The token lacks the `write` scope (`scope_required`), your company requires two-factor authentication and you have not set it up, or your role lacks the Edit Environment Deployment Pipeline permission (`forbidden`, with `permission`).

```json
{
  "code": "company_unavailable",
  "message": "Your company is unavailable.",
  "reason": "company_unavailable"
}
```

### 404 The id does not exist, or it is something you cannot see. Both answer the same body.

```json
{
  "message": "Not found."
}
```

### 409 The environment already has a credential for this registry (`exists`). `id` is the saved one. Change that one instead.

```json
{
  "code": "exists",
  "id": 318,
  "message": "A registry for this host is already saved. Edit it instead.",
  "reason": "exists"
}
```

### 422 The request was refused and nothing was saved. `errors` names the field. - `secret_invalid`: a field is missing or is a value the rules refuse (the label, the registry's host, the sign-in type, the username for `http-basic`, the token), the registry's address is not public or does not resolve, the environment holds as many credentials as it can, or its credentials would be too large together. - `invalid`: the body is not a JSON object (on `request`), a change names nothing to change, or the environment belongs to a CoreStack or CoreCluster site (on `environment`).

```json
{
  "code": "secret_invalid",
  "errors": {
    "auth_type": [
      "Choose how the registry signs in: http-basic, bearer, github-oauth or gitlab-token."
    ]
  },
  "message": "Choose how the registry signs in: http-basic, bearer, github-oauth or gitlab-token.",
  "reason": "secret_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 | `forbidden` | The person is not allowed to do this. |
| 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 |  | Check the id. You see only what your account can reach. |
| 409 | `exists` | It already exists. Use the existing one. |
| 422 | `secret_invalid` | Choose how the registry signs in: http-basic, bearer, github-oauth or gitlab-token. |
| 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: [Private registries](https://docs.corefinity.com/guides/sites/code-and-deployments/registry-secrets.md)
