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

# Get a secret

> Fetch one secret by name with the Node.js SDK.

`client.secrets().getSecret()` fetches one secret from 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** `GetSecretOptions` *required*

**properties**

**projectId** `string` *required*

The ID of the project.

**environment** `string` *required*

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

**secretName** `string` *required*

The name of the secret.

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

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

**version** `number`

The version of the secret to fetch. Defaults to the latest version.

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

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

**includeImports** `boolean`

Has no effect. The SDK never looks for the secret in the folder's [secret imports](https://infisical.com/docs/documentation/platform/secret-reference.md#secret-imports).

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

Whether to replace each [secret reference](https://infisical.com/docs/documentation/platform/secret-reference.md#secret-referencing) in the value with the value it points to.

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

Whether to return the secret's value.

## Returns

**secret** `Secret`

The secret.

**properties**

**secretKey** `string`

The name of the secret.

**secretValue** `string`

The value of the secret.

**secretValueHidden** `boolean`

`true` if Infisical hid the value, because of `viewSecretValue: false` or because the machine identity can't read the value.

**secretComment** `string`

The secret's comment.

**secretPath** `string`

The path of the folder that the secret is in.

**environment** `string`

The slug of the secret's environment.

**type** `string`

`shared`, or `personal` for a personal override.

**version** `number`

The version number of the secret.

**tags** `object[]`

The secret's tags, each with its `id`, `slug`, `name`, and `color`.

**secretMetadata** `object[]`

The key-value pairs stored with the secret, each with its `key` and `value`.

**id** `string`

The ID of the secret.

**createdAt** `string`

When the secret was created.

**updatedAt** `string`

When the secret was last updated.

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

console.log(secret.secretValue);
```

```typescript In a folder theme={"dark"}
const secret = await client.secrets().getSecret({
  projectId: "<project-id>",
  environment: "dev",
  secretPath: "/backend",
  secretName: "DATABASE_URL",
});
```

```typescript Older version theme={"dark"}
const secret = await client.secrets().getSecret({
  projectId: "<project-id>",
  environment: "dev",
  secretName: "DATABASE_URL",
  version: 3,
});
```

```json Response theme={"dark"}
{
  "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"
}
```


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