> ## 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 Node.js SDK.

`client.dynamicSecrets().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

**options** `CreateDynamicSecretOptions` *required*

**properties**

**projectSlug** `string` *required*

The slug of the project.

**environmentSlug** `string` *required*

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

**name** `string` *required*

The name of the dynamic secret.

**defaultTTL** `string` *required*

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

**maxTTL** `string` *required*

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

**provider** `TDynamicSecretProvider` *required*

The system that Infisical creates credentials in. Set `type` to a value of the `DynamicSecretProviders` enum, such as `DynamicSecretProviders.SqlDatabase`, and `inputs` to that 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.

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

The path of the folder to create the dynamic secret in.

**metadata** `\{ key: string; value: string \}[]`

Key-value pairs to store with the dynamic secret, such as `[{ key: "team", value: "payments" }]`.

## Returns

**dynamicSecret** `DynamicSecret`

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

```typescript Redis theme={"dark"}
import { DynamicSecretProviders } from "@infisical/sdk";

const dynamicSecret = await client.dynamicSecrets().create({
  projectSlug: "<project-slug>",
  environmentSlug: "dev",
  name: "redis-cache",
  defaultTTL: "1h",
  maxTTL: "24h",
  provider: {
    type: DynamicSecretProviders.Redis,
    inputs: {
      host: "<redis-host>",
      port: 6379,
      username: "default",
      password: "<redis-password>",
      creationStatement: "ACL SETUSER {{username}} on >{{password}} ~* &* +@all",
      revocationStatement: "ACL DELUSER {{username}}",
    },
  },
});
```

```json Response theme={"dark"}
{
  "id": "4d5e6f7a-8b9c-4d0e-1f2a-3b4c5d6e7f8a",
  "name": "redis-cache",
  "type": "redis",
  "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.