> ## 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.

# Create a dynamic secret

> Create a dynamic secret with the Python SDK.

`client.dynamic_secrets.create()` creates a [dynamic secret](https://infisical.com/docs/documentation/platform/dynamic-secrets/overview) in a folder in an environment of a project.

To find the project slug, open the project, go to **Administration** > **Settings**, and copy the **Project slug**.

## Parameters

**name** `str` *required*

The name of the dynamic secret.

**provider\_type** `Union[DynamicSecretProviders, str]` *required*

The system that Infisical creates credentials in, such as `DynamicSecretProviders.SQL_DATABASE`. See [Providers](#providers).

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

The provider's settings. The [Create dynamic secret](https://infisical.com/docs/api-reference/endpoints/dynamic-secrets/create.md) endpoint lists the settings of each provider.

**default\_ttl** `str` *required*

How long a lease lasts if the lease doesn't set its own TTL, such as `1h`.

**max\_ttl** `str` *required*

The longest that a lease can last, including renewals, such as `24h`.

**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 to create the dynamic secret in.

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

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

## Returns

**dynamic\_secret** `DynamicSecret`

The new dynamic secret, with its `id`, `name`, `type`, and TTLs.

## Providers

| Provider | `DynamicSecretProviders` value |
| - | - |
| AWS ElastiCache | `AWS_ELASTICACHE` |
| AWS IAM | `AWS_IAM` |
| Azure Entra ID | `AZURE_ENTRA_ID` |
| Azure SQL Database | `AZURE_SQL_DATABASE` |
| Cassandra | `CASSANDRA` |
| Couchbase | `COUCHBASE` |
| Elasticsearch | `ELASTICSEARCH` |
| GCP IAM | `GCP_IAM` |
| GitHub | `GITHUB` |
| Kubernetes | `KUBERNETES` |
| LDAP | `LDAP` |
| MongoDB Atlas | `MONGO_ATLAS` |
| MongoDB | `MONGODB` |
| RabbitMQ | `RABBITMQ` |
| Redis | `REDIS` |
| SAP ASE | `SAP_ASE` |
| SAP HANA | `SAP_HANA` |
| Snowflake | `SNOWFLAKE` |
| SQL database | `SQL_DATABASE` |
| TOTP | `TOTP` |
| Vertica | `VERTICA` |

```python PostgreSQL theme={"dark"}
from infisical_sdk import DynamicSecretProviders

dynamic_secret = client.dynamic_secrets.create(
    name="postgres-readonly",
    provider_type=DynamicSecretProviders.SQL_DATABASE,
    inputs={
        "client": "postgres",
        "host": "<postgres-host>",
        "port": 5432,
        "database": "app",
        "username": "admin",
        "password": "<admin-password>",
        "creationStatement": "CREATE USER \"{{username}}\" WITH PASSWORD '{{password}}';",
        "revocationStatement": "DROP USER \"{{username}}\";",
    },
    default_ttl="1h",
    max_ttl="24h",
    project_slug="<project-slug>",
    environment_slug="dev",
)
```

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


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