Recycle Bin
List, restore, recycle, and permanently delete items in the SharePoint recycle bin.
Lifecycle
graph LR
A[Live item] -->|recycle| B[First-stage recycle bin]
B -->|restore| A
B -->|move to second stage| C[Second-stage recycle bin]
C -->|permanently delete| D[Gone]
B -->|permanently delete| D
Prerequisites
| Requirement |
Description |
Reference |
| Read access to the site |
Required to view the recycle bin |
SharePoint admin roles |
| Site Owner role |
Required to restore, move to second stage, and permanently delete items |
SharePoint admin roles |
Examples
Quick start
from office365.sharepoint.client_context import ClientContext
ctx = ClientContext("https://contoso.sharepoint.com/sites/team").with_client_certificate(
"contoso.onmicrosoft.com", client_id="client_id", thumbprint="thumbprint", cert_path="./cert.pem"
)
# List first-stage recycle bin items
items = ctx.web.recycle_bin.get().execute_query()
for item in items:
print(f" {item.title} (deleted: {item.deleted_date})")
# Restore the most recently deleted item
if len(items):
items[0].restore().execute_query()
API reference