> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a secret

> Change a secret's value or name with the Python SDK.

`client.secrets.update_secret_by_name()` changes a secret's value, name, comment, tags, or other settings. The machine identity needs a [role](https://infisical.com/docs/documentation/platform/access-controls/role-based-access-controls.md#project-level-access-controls) in the project that can change secrets, such as **Member**.

## Parameters

**current\_secret\_name** `str` *required*

The current name of the secret.

**project\_id** `str`

The ID of the project. Pass `project_id` or `project_slug`. If you pass both, the SDK uses `project_id`.

**project\_slug** `str`

The slug of the project.

**environment\_slug** `str` *required*

The slug of the environment, such as `dev`.

**secret\_path** `str` *required*

The path of the folder, such as `/` or `/backend`.

**secret\_value** `str`

The new value of the secret.

**new\_secret\_name** `str`

A new name for the secret.

**secret\_comment** `str`

A new comment for the secret.

**tags\_ids** `List[str]`

The IDs of the secret's tags, which replace its current tags.

**secret\_metadata** `List[Dict[str, Any]]`

Key-value pairs to store with the secret, each a dictionary with `key` and `value`.

**skip\_multiline\_encoding** `bool` (default: False)

Whether to store a multi-line value without encoding its line breaks.

**secret\_reminder\_note** `str`

The note that Infisical sends with each reminder to rotate the secret.

**secret\_reminder\_repeat\_days** `int`

The number of days between reminders, at least 1.

## Returns

**secret** `BaseSecret`

The updated secret, with its `id`, `secretKey`, `secretValue`, `secretValueHidden`, `secretComment`, `environment`, `type`, and `version`. To get its tags and metadata, call [`get_secret_by_name`](https://infisical.com/docs/sdks/languages/python/secrets/get-secret). Its `secretValue` and `secretComment` hold only the values that this call sent.

```python Change the value theme={"dark"}
secret = client.secrets.update_secret_by_name(
    current_secret_name="STRIPE_KEY",
    project_id="<project-id>",
    environment_slug="dev",
    secret_path="/",
    secret_value="<new-stripe-key>",
)
```

```python Rename theme={"dark"}
secret = client.secrets.update_secret_by_name(
    current_secret_name="STRIPE_KEY",
    project_id="<project-id>",
    environment_slug="dev",
    secret_path="/backend",
    new_secret_name="STRIPE_SECRET_KEY",
)
```

```json Response theme={"dark"}
{
  "id": "9d2f1e4c-7b3a-4c6d-8e5f-0a1b2c3d4e5f",
  "_id": "9d2f1e4c-7b3a-4c6d-8e5f-0a1b2c3d4e5f",
  "workspace": "5e8d7c6b-4a3f-4e2d-9c1b-0a9f8e7d6c5b",
  "environment": "dev",
  "secretKey": "STRIPE_KEY",
  "secretValue": "<new-stripe-key>",
  "secretValueHidden": false,
  "secretComment": "",
  "type": "shared",
  "version": 2,
  "createdAt": "2026-12-02T10:21:44.130Z",
  "updatedAt": "2026-12-02T11:05:12.877Z"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.