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

# List secrets

> List the secrets in a folder with the Node.js SDK.

`client.secrets().listSecrets()` lists the secrets 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 read secrets, such as **Viewer**.

## Parameters

**options** `ListSecretsOptions` *required*

**properties**

**projectId** `string` *required*

The ID of the project.

**environment** `string` *required*

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

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

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

**recursive** `boolean` (default: false)

Whether to also list the secrets in every subfolder of `secretPath`.

**includeImports** `boolean` (default: false)

Whether to also return the folder's [secret imports](https://infisical.com/docs/documentation/platform/secret-reference.md#secret-imports), in `imports`.

**expandSecretReferences** `boolean` (default: true)

Whether to replace each [secret reference](https://infisical.com/docs/documentation/platform/secret-reference.md#secret-referencing), such as `${dev.DB_HOST}`, with the value it points to.

**viewSecretValue** `boolean` (default: true)

Whether to return the secrets' values. If `false`, each secret's `secretValueHidden` is `true` and its `secretValue` is `<hidden-by-infisical>`.

**tagSlugs** `string[]`

Tag slugs, to list only the secrets that have at least one of these tags.

**attachToProcessEnv** `boolean` (default: false)

Whether to also set each secret as an environment variable in `process.env`, including the imported secrets if `includeImports` is `true`.

## Returns

**result** `ListSecretsResponse`

**properties**

**secrets** `Secret[]`

The secrets in the folder. Each secret has the fields that [`getSecret`](https://infisical.com/docs/sdks/languages/node/secrets/get-secret#returns) returns. If `attachToProcessEnv` and `includeImports` are both `true`, it also holds the imported secrets.

**imports** `object[]`

If `includeImports` is `true`, one entry per secret import, with the import's `secretPath`, `environment`, and `secrets`.

```typescript Basic theme={"dark"}
const { secrets } = await client.secrets().listSecrets({
  projectId: "<project-id>",
  environment: "dev",
});

for (const secret of secrets) {
  console.log(secret.secretKey, secret.secretValue);
}
```

```typescript With subfolders theme={"dark"}
const { secrets } = await client.secrets().listSecrets({
  projectId: "<project-id>",
  environment: "dev",
  secretPath: "/backend",
  recursive: true,
});
```

```typescript Into process.env theme={"dark"}
await client.secrets().listSecrets({
  projectId: "<project-id>",
  environment: "dev",
  attachToProcessEnv: true,
});

console.log(process.env.DATABASE_URL);
```

```json Response theme={"dark"}
{
  "secrets": [
    {
      "id": "0b7c4a7e-5f3e-4d8a-9a51-2f6c1c0b3e21",
      "environment": "dev",
      "secretKey": "DATABASE_URL",
      "secretValue": "postgres://app:<password>@db.internal:5432/app",
      "secretValueHidden": false,
      "secretComment": "",
      "secretPath": "/",
      "type": "shared",
      "version": 4,
      "tags": [],
      "secretMetadata": [],
      "createdAt": "2026-11-02T09:14:27.512Z",
      "updatedAt": "2026-11-30T16:41:03.208Z"
    }
  ],
  "imports": []
}
```


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