# Replace a secret's value or note, or a sign-in's site.

`PATCH /o/{org}/secrets/{secret}`

Only its creator or an org admin. A sign-in's value is `username`, `password` and an optional `totp_secret`, replaced together; any other secret's is `value`. A sign-in's `targets` (its one https site) can change on its own, keeping the stored username and password, but only by the person who added it, signed in as themselves. Any other field but `description` is refused with `SECRET_FIELD_IMMUTABLE`. A body that is not a JSON object is `400 INVALID_BODY`.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `org` | path | string | yes | The org's slug or id. A caller with no role in the org gets `404`. |
| `secret` | path | string | yes |  |

## Request body

- `value` (string, optional)
- `username` (string, optional)
- `password` (string, optional)
- `totp_secret` (string, optional)
- `targets` (array of string, optional): A sign-in's new site, such as https://login.example.com.
- `description` (string, optional)

## Example request

```bash
curl -X PATCH "https://api.phoenix.so/o/$RUSH_ORG/secrets/$SECRET" \
  -H "Authorization: Bearer $RUSH_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
```

```typescript
const org = process.env.RUSH_ORG;
const secret = process.env.SECRET;

const res = await fetch(`https://api.phoenix.so/o/${org}/secrets/${secret}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.RUSH_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({}),
});

console.log(res.status, await res.json());
```

```python
import os

import requests

org = os.environ["RUSH_ORG"]
secret = os.environ["SECRET"]

res = requests.patch(
    f"https://api.phoenix.so/o/{org}/secrets/{secret}",
    headers={"Authorization": f"Bearer {os.environ['RUSH_TOKEN']}"},
    json={},
)

print(res.status_code, res.json())
```

## Responses

### 200

Updated.

- `data` (Secret, required): A secret without its value.
  - `id` (string, required)
  - `name` (string, required)
  - `kind` (string, required, one of `env`, `header`, `login`)
  - `source` (string, required, one of `rush`, `onepassword`): Where the value lives; a 1Password secret holds only its reference.
  - `description` (string, required)
  - `project_id` (string, required)
  - `targets` (array of string, required): Hosts (header) or one origin (login); empty for env.
  - `header_name` (string | null, optional)
  - `header_format` (string | null, optional)
  - `has_totp` (boolean, required)
  - `created_by` (string | null, required): Null once the member who added it has deleted their account; the secret stays with the Project.
  - `created_at` (string, required)
  - `value_updated_at` (string, required)
  - `last_used_at` (string | null, optional)

### 400

A body that is not a JSON object (`INVALID_BODY`).

### 401

No bearer, an unknown, revoked or expired one, or an API key on a route keys cannot call.

### 403

Not its creator or an org admin, or a new site from anyone but the person who added the sign-in.

### 404

`SECRET_NOT_FOUND`: no such secret the caller can see.

### 409

`SECRET_CHANGED`: a site-only move found the value replaced since it was read; read it again.

### 422

`SECRET_FIELD_IMMUTABLE`, `SECRET_VALUE_INVALID` or `SECRET_DESCRIPTION_INVALID`.

### 429

The account is over its request budget, 1,800 a minute shared by the person's API keys and console on every API host (`RATE_LIMITED`). The error names the limit. Wait `Retry-After` seconds.

## Example response (200)

```json
{
  "data": {
    "id": "2b7e4c90-1d3a-4f58-8e6b-9c0a5d2f7e13",
    "name": "stripe-api",
    "kind": "header",
    "source": "rush",
    "description": "Stripe test-mode key for checkout tests.",
    "project_id": "7d2e9a14-5b3c-4f60-8e21-9a0b1c2d3e4f",
    "targets": ["api.stripe.com"],
    "header_name": "Authorization",
    "header_format": "Bearer {value}",
    "has_totp": false,
    "created_by": "4e8a1f3c-6b2d-4c97-a05e-8d3f2b1c9a76",
    "created_at": "2026-09-28T17:40:12.000Z",
    "value_updated_at": "2026-10-07T09:14:55.000Z",
    "last_used_at": "2026-10-06T15:02:14.000Z"
  }
}
```
