Access SharePoint site's Recycle Bin with the Graph API

Recycle Bin

The Recycle Bin of the SharePoint site provides a safety place when users delete

  • files
  • versions of files
  • list items
  • libraries
  • lists
  • folders

from a site.

When users delete any of these items from a site, the items are placed in the Recycle Bin.

Access Recycle Bin with the Graph API

Recently, the Graph API introduced a new endpoint that will allow you to access the items inside the Recycle Bin.

The endpoint is currently available only for beta.

To access the Recycle Bin, send the request

GET https://graph.microsoft.com/beta/sites/{site-id}/recyclebin/items

The response contains a collection of recycleBinItem objects

{
    "value": [
        {
            "id": "38a5cd0c-e58e-42b5-b2d4-510227256d13",
            "name": "28_.000",
            "size": 248,
            "deletedDateTime": "2023-08-30T10:37:01Z",
            "deletedFromLocation": "sites/Communication-Site/Lists/Test2",
            "title": "",
            "deletedBy": {
                "user": {
                    "displayName": "Doe John",
                    "email": "john.doe@contoso.com",
                    "id": "10"
                }
            }
        },
        {
            "id": "d39bb856-fb1d-4c56-ab24-ee737353813a",
            "name": "__rectSitelogo__green-tick.png",
            "size": 193385,
            "deletedDateTime": "2023-08-30T11:37:43Z",
            "deletedFromLocation": "sites/Communication-Site/SiteAssets",
            "title": "__rectSitelogo__green-tick.png",
            "deletedBy": {
                "user": {
                    "displayName": "Doe John",
                    "email": "john.doe@contoso.com",
                    "id": "10"
                }
            }
        }
    ]
}

The recycleBinItem resource type has the following properties

  • id - Unique identifier of the delete transaction
  • name - Name of the item
  • size - Size of the item in bytes
  • deletedDateTime - Date and time when the item was deleted
  • deletedFromLocation - Relative URL of the list or folder that originally contained the item
  • title - Title of the item
  • deletedBy - User who deleted the item

The endpoint supports $select, $filter, $orderby, $top, and $count query parameters.

0
Buy Me a Coffee at ko-fi.com
An error has occurred. This application may no longer respond until reloaded. Reload x