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

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

**project\_id** `str`

The ID of the project. Pass `project_id` or `project_slug`. If you pass both, the SDK uses `project_id`.

**project\_slug** `str`

The slug of the project.

**environment\_slug** `str` *required*

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

**secret\_path** `str` *required*

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

**recursive** `bool` (default: False)

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

**include\_imports** `bool` (default: True)

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

**expand\_secret\_references** `bool` (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.

**view\_secret\_value** `bool` (default: True)

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

**tag\_filters** `List[str]`

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

## Returns

**response** `ListSecretsResponse`

**properties**

**secrets** `List[BaseSecret]`

The secrets in the folder. Each secret has the fields that [`get_secret_by_name`](https://infisical.com/docs/sdks/languages/python/secrets/get-secret#returns) returns.

**imports** `List[Import]`

If `include_imports` is `True`, one entry per secret import, with the import's `secretPath`, `environment`, and `secrets`. Each secret in `secrets` is a dictionary.

```python Basic theme={"dark"}
response = client.secrets.list_secrets(
    project_id="<project-id>",
    environment_slug="dev",
    secret_path="/",
)

for secret in response.secrets:
    print(secret.secretKey, secret.secretValue)
```

```python With subfolders theme={"dark"}
response = client.secrets.list_secrets(
    project_id="<project-id>",
    environment_slug="dev",
    secret_path="/backend",
    recursive=True,
)
```

```python By tag theme={"dark"}
response = client.secrets.list_secrets(
    project_id="<project-id>",
    environment_slug="dev",
    secret_path="/",
    tag_filters=["payments"],
)
```

```json Response theme={"dark"}
{
  "secrets": [
    {
      "id": "0b7c4a7e-5f3e-4d8a-9a51-2f6c1c0b3e21",
      "_id": "0b7c4a7e-5f3e-4d8a-9a51-2f6c1c0b3e21",
      "workspace": "5e8d7c6b-4a3f-4e2d-9c1b-0a9f8e7d6c5b",
      "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.