# Trash Commands

### Overview

List or manage deleted records in the trash. Deleted records remain in the trash until purged.

### Commands

The following functionalities are available when it comes to managing trash through CLI and SDK

* [Trash List ](#trash-list-command)
* [Trash Restore](#trash-restore-command)&#x20;
* [Trash Get ](#trash-get-command)
* [Trash Unshare](#trash-unshare-command)&#x20;
* [Trash Purge](#trash-purge-command)&#x20;

### Trash List Command

This command lists the records and folders in the trash of vault. The trashed records are loaded in memory and can be fetched as deleted, orphaned and shared folders&#x20;

<details>

<summary>DotNet CLI</summary>

**Command**: `trash`

**Example:**

```bash
My Vault> trash list
  #  Folder UID              Record UID              Name                             Record Type  Deleted At             Status
---  ----------------------  ----------------------  -------------------------------  -----------  ---------------------  ------
  1                          0thOtx4abVGBaNKcycX04Q  defws                            address                             Share 
  2  JSz1s5lZ_KUNwbCnvQZRPw                          testrtg                                       08/10/2025 5:07:04 AM  Folder
```

</details>

<details>

<summary>DotNet SDK</summary>

**Functions:**

```csharp
var deletedRecords = TrashManagement.GetDeletedRecords();
var orphanedRecords = TrashManagement.GetOrphanedRecords();
var sharedFolders = TrashManagement.GetSharedFolders();
```

These functions together will give all trashed data.

</details>

<details>

<summary>Power Commander</summary>

**Command**: `Get-KeeperTrashList -Verbose`

**Example**

```powershell
PS> Get-KeeperTrashList -Verbose                                      
VERBOSE: Starting trash list operation with pattern: ''

Folder UID             Record UID             Name                                                     Record Type   Deleted At            Status
----------             ----------             ----                                                     -----------   ----------            ------
                       0thOtx4abVGBaNKcycX04Q defws                                                    address                             Share
mdigPPSMrgKA_HIoz4q0ww B9hlKf_0Qitj_MX75JlZ-g test_share_folder_folder_record1234567898765432123456789 login         23/09/2025 7:13:21 AM Share
jWfCYHdhU0sx4-MKi6i6cQ                        tes_share_folder_folder_folder                           Shared Folder                       Folder
PDNS1vASSHMWOhdkBv9Vzg                        test_share_folder_folder@delete                          Shared Folder                       Folder
mdigPPSMrgKA_HIoz4q0ww                        test_share_folder_folder@delete                          Shared Folder                       Folder
JSz1s5lZ_KUNwbCnvQZRPw                        testrtg                                                  Shared Folder                       Folder
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `trash list`

**Flags:**

`-v`           `--verbose`                  Show detailed verbose output

`--format`                                      Format of output - Table, JSON or SCV

`--output`                                      Path to resulting output file (ignored for "table" format)

`pattern`                                        Search criteria while listing trash

**Example:**

```sh
My Vault> trash list
  #  Folder UID              Record UID              Name                           Record Type          Deleted At           Status
---  ----------------------  ----------------------  -----------------------------  -------------------  -------------------  --------
  1                          record_uid                                                                  2025-05-23 17:46:00  Record
```

</details>

<details>

<summary>Python SDK</summary>

**Function:** `_ensure_deleted_records_loaded`

```python
trash_management.TrashManagement._ensure_deleted_records_loaded(vault)
deleted_records = TrashManagement.get_deleted_records()
orpahned_records = TrashManagement.get_orphaned_records()
deleted_shared_folders = TrashManagement.get_shared_folders()
```

</details>

### Trash Restore Command

Use this command to restore any records present in the trash of vault.

<details>

<summary>DotNet CLI</summary>

**Command**: `trash restore <recorduid>`&#x20;

**Example:**

```
My Vault> trash restore 0thOtx4abVGBaNKcycX04Q
Successfully initiated restoration of 1 record(s)
```

</details>

<details>

<summary>DotNet SDK</summary>

**Command**: `RestoreTrashRecords`

```csharp
public static async Task RestoreTrashRecords(VaultOnline vault, List<string> records)
```

```
await TrashManagement.RestoreTrashRecords(context.Vault, records);
```

</details>

<details>

<summary>Power Commander</summary>

**Command**: `Restore-KeeperTrashRecords`

**Example:**

```powershell
PS> Restore-KeeperTrashRecords -Records 0thOtx4abVGBaNKcycX04Q      
Successfully initiated restoration of 1 record(s)
Use 'Get-KeeperTrashList' to verify the restoration
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `trash restore`

**Parameter:**

`records`                    List of record UIDs to be restored

**Flags**:

`--force`                    Skip confirmation messages

`-h, --help`                  show this help message and exit

**Example:**

```sh
My Vault> trash restore <record_uid>
Do you want to restore 1 record(s)? [y/n]: y
```

</details>

<details>

<summary>Python SDK</summary>

**Function:**  `restore_trash_records`

```python
trash_management.restore_trash_records(vault, record_uids)
record_uids - list of uids
vault - vault instance
```

</details>

### Trash Get Command

Use this command to fetch a trashed record and display its information

<details>

<summary>DotNet CLI</summary>

**Command**: `trash get <recorduid>`

**Example:**

```
My Vault> trash get 0thOtx4abVGBaNKcycX04Q
                Title: defws
                 Type: address
              address: fdvefcq ₹ewrwfwv₹, esvbwqe, ₹webvwe bevwewds, DZ
   Direct User Shares: user2@email.com (Read Only) 
```

</details>

<details>

<summary>DotNet SDK</summary>

**Command**: Not Applicable

</details>

<details>

<summary>Power Commander</summary>

**Command**: `Get-KeeperTrashedRecordDetails`

```powershell
PS> Get-KeeperTrashedRecordDetails

cmdlet Get-KeeperTrashedRecordDetails at command pipeline position 1
Supply values for the following parameters:
RecordUid: 0thOtx4abVGBaNKcycX04Q
                Title: defws
                 Type: address
              address: fdvefcq, ₹ewrwfwv₹, esvbwqe, ₹webvwe, bevwewds, DZ
```

</details>

<details>

<summary>Python CLI</summary>

**Command**:  `trash get`&#x20;

**Parameter**:

`record`                            Record UID

**Example:**

```sh
My Vault> trash get <record_uid>
                Title: test_record
                 Type: login
                login: username@keepersecurity.com
             password: password
                  url: keepersecurity.com
```

</details>

<details>

<summary>Python SDK</summary>

**Function:** `get_trash_record`

```python
trash_management.get_trash_record(vault, record_uid)
```

</details>

### Trash Unshare Command

Use this command to remove or unshare a trashed record from the vaults of other users to avoid creating orphaned accounts. Trashed records will exist in the vaults of users with whom they are shared.

<details>

<summary>DotNet CLI</summary>

**Command**: `trash unshare <recorduid>`

**Example:**

```bash
My Vault> trash unshare B9hlKf_0Qitj_MX75JlZ-g
There are no records to unshare
```

</details>

<details>

<summary>DotNet SDK</summary>

**Command**: Not applicable

</details>

<details>

<summary>Power Commander</summary>

**Command**: `Remove-TrashedKeeperRecordShares`

**Example:**

```powershell
Remove-TrashedKeeperRecordShares -Records "NyTgDxKnMRhcgpR_BGkFkw"
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `trash unshare`

**Parameter**:

`records`                            Record UID

**Flags:**

\--force                          Skip confirmation prompts

-h, --help                       show this help message and exit

**Example:**

```sh
My Vault> trash unshare <record_uid>
Do you want to remove shares from 1 record(s)? [y/n]: y
My Vault>
```

</details>

<details>

<summary>Python SDK</summary>

Not Applicable

</details>

### Trash Purge Command

This command is used to clean or clear out (permanently delete) all records and shared folder from the trash

<details>

<summary>DotNet CLI</summary>

**Command**: `trash purge`

**Example:**

```
My Vault> trash purge
Are you sure you want to permanently delete all records in trash? This action cannot be undone. (yes/No): s
Purge operation cancelled
```

</details>

<details>

<summary>DotNet SDK</summary>

**Command**: Coming Soon

</details>

<details>

<summary>Power Commander</summary>

**Command**: `Clear-KeeperTrash`

**Example:**

```powershell
PS> clear-KeeperTrash   
Are you sure you want to permanently delete all records in trash? This action cannot be undone. (yes/No): yes
Successfully purged all records from trash
```

</details>

<details>

<summary>Python CLI</summary>

**Command:** `trash purge`

**Flags:**

`--force`                     Skip conformation prompts

`-h, --help`                Show this help message and exit

**Example:**

```
My Vault> trash purge
Do you want to empty your Trash Bin? [y/n]: y
My Vault>
```

</details>

<details>

<summary>Python SDK</summary>

**Function:** `purge_trash`

```python
trash_management(vault)
```

</details>
