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

# Delete a secret

> Delete a secret from a folder with the Python SDK.

`client.secrets.delete_secret_by_name()` deletes a 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 change secrets, such as **Member**.

## Parameters

**secret\_name** `str` *required*

The name of the secret.

**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`.

## Returns

**secret** `BaseSecret`

The deleted secret, with the values it had before the delete.

```python Basic theme={"dark"}
secret = client.secrets.delete_secret_by_name(
    secret_name="STRIPE_SECRET_KEY",
    project_id="<project-id>",
    environment_slug="dev",
    secret_path="/backend",
)
```

```json Response theme={"dark"}
{
  "id": "9d2f1e4c-7b3a-4c6d-8e5f-0a1b2c3d4e5f",
  "_id": "9d2f1e4c-7b3a-4c6d-8e5f-0a1b2c3d4e5f",
  "workspace": "5e8d7c6b-4a3f-4e2d-9c1b-0a9f8e7d6c5b",
  "environment": "dev",
  "secretKey": "STRIPE_SECRET_KEY",
  "secretValue": "<stripe-key>",
  "secretValueHidden": false,
  "secretComment": "",
  "type": "shared",
  "version": 3,
  "createdAt": "2026-12-02T10:21:44.130Z",
  "updatedAt": "2026-12-02T11:05:12.877Z"
}
```


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