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

> Create a secret in a folder with the Node.js SDK.

`client.secrets().createSecret()` creates a secret in a folder in an environment of a project. 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**.

If the folder has an [approval policy](https://infisical.com/docs/documentation/platform/pr-workflows.md), Infisical opens a change request instead of creating the secret, and returns the change request in `approval`.

## Parameters

**secretName** `string` *required*

The name of the secret.

**options** `CreateSecretOptions` *required*

**properties**

**projectId** `string` *required*

The ID of the project.

**environment** `string` *required*

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

**secretValue** `string` *required*

The value of the secret.

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

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

**secretComment** `string`

A comment that Infisical shows with the secret.

**tagIds** `string[]`

The IDs of the tags to add to the secret.

**type** `SecretType` (default: SecretType.Shared)

`SecretType.Shared`, or `SecretType.Personal` to create a [personal override](https://infisical.com/docs/documentation/platform/secrets-mgmt/project.md#personal-overrides).

**skipMultilineEncoding** `boolean`

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

**secretReminderNote** `string`

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

**secretReminderRepeatDays** `number`

The number of days between reminders, at least 1.

## Returns

**result** `CreateSecretResponse`

**properties**

**secret** `Secret`

The new secret, with its `id`, `secretKey`, `secretValue`, `secretComment`, `environment`, `type`, and `version`. To get its tags, call [`getSecret`](https://infisical.com/docs/sdks/languages/node/secrets/get-secret).

**approval** `object`

The change request, if the folder has an approval policy. `secret` is then `undefined`. The TypeScript types of the SDK don't include `approval`.

```typescript Basic theme={"dark"}
const { secret } = await client.secrets().createSecret("STRIPE_KEY", {
  projectId: "<project-id>",
  environment: "dev",
  secretValue: "<stripe-key>",
});
```

```typescript With a comment and tags theme={"dark"}
const { secret } = await client.secrets().createSecret("STRIPE_KEY", {
  projectId: "<project-id>",
  environment: "dev",
  secretPath: "/backend",
  secretValue: "<stripe-key>",
  secretComment: "Test mode key",
  tagIds: ["<tag-id>"],
});
```

```typescript With a rotation reminder theme={"dark"}
const { secret } = await client.secrets().createSecret("STRIPE_KEY", {
  projectId: "<project-id>",
  environment: "prod",
  secretValue: "<stripe-key>",
  secretReminderNote: "Roll the key in the Stripe dashboard",
  secretReminderRepeatDays: 90,
});
```

```json Response theme={"dark"}
{
  "secret": {
    "id": "9d2f1e4c-7b3a-4c6d-8e5f-0a1b2c3d4e5f",
    "environment": "dev",
    "secretKey": "STRIPE_KEY",
    "secretValue": "<stripe-key>",
    "secretComment": "",
    "type": "shared",
    "version": 1,
    "secretReminderNote": null,
    "secretReminderRepeatDays": null,
    "skipMultilineEncoding": false,
    "createdAt": "2026-12-02T10:21:44.130Z",
    "updatedAt": "2026-12-02T10:21:44.130Z"
  }
}
```


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