> ## 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 dynamic secret

> Change a dynamic secret's settings with the Python SDK.

`client.dynamic_secrets.update()` changes a [dynamic secret's](https://infisical.com/docs/documentation/platform/dynamic-secrets/overview) name, TTLs, provider settings, or metadata. The settings that you don't pass stay as they are.

## Parameters

**name** `str` *required*

The current name of the dynamic secret.

**project\_slug** `str` *required*

The slug of the project.

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

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

**path** `str` (default: /)

The path of the folder that the dynamic secret is in.

**new\_name** `str`

A new name for the dynamic secret.

**default\_ttl** `str`

The new default TTL of leases, such as `2h`.

**max\_ttl** `str`

The new max TTL of leases, such as `48h`.

**inputs** `Dict[str, Any]`

The provider settings to change, such as `{"port": 5433}`.

**metadata** `List[Dict[str, str]]`

The new metadata, each a dictionary with `key` and `value`.

**username\_template** `str`

The template for the usernames that Infisical creates, such as `dev-{{identity.name}}`.

## Returns

**dynamic\_secret** `DynamicSecret`

The updated dynamic secret.

```python Change the TTLs theme={"dark"}
dynamic_secret = client.dynamic_secrets.update(
    name="postgres-readonly",
    project_slug="<project-slug>",
    environment_slug="dev",
    default_ttl="2h",
    max_ttl="48h",
)
```

```python Rename theme={"dark"}
dynamic_secret = client.dynamic_secrets.update(
    name="postgres-readonly",
    project_slug="<project-slug>",
    environment_slug="dev",
    new_name="postgres-reporting",
)
```

```json Response theme={"dark"}
{
  "id": "4d5e6f7a-8b9c-4d0e-1f2a-3b4c5d6e7f8a",
  "name": "postgres-readonly",
  "type": "sql-database",
  "defaultTTL": "2h",
  "maxTTL": "48h",
  "folderId": "3a1f6c2e-9b4d-4e7a-8c5f-2d1e0b9a8c7f",
  "version": 2,
  "status": null,
  "statusDetails": null,
  "metadata": [],
  "createdAt": "2026-11-20T08:15:42.000Z",
  "updatedAt": "2026-12-02T11:44:09.531Z"
}
```


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