Muokkaa

Jaa


List deletedItems (directory objects)

Namespace: microsoft.graph

Retrieve a list of recently deleted directory objects. Currently, deleted items functionality is only supported for the application, servicePrincipal, group, administrative unit, and user resources.

Note: Deleted security groups are deleted permanently and can't be retrieved through this API.

This API is available in the following national cloud deployments.

Global service US Government L4 US Government L5 (DOD) China operated by 21Vianet

Permissions

The following table shows the least privileged permission or permissions required to call this API on each supported resource type. Follow best practices to request least privileged permissions. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

Supported resource Delegated (work or school account) Delegated (personal Microsoft account) Application
administrativeUnit AdministrativeUnit.Read.All Not supported. AdministrativeUnit.Read.All
application Application.Read.All Not supported. Application.Read.All
group Group.Read.All Not supported. Group.Read.All
servicePrincipal Application.Read.All Not supported. Application.Read.All
user User.Read.All Not supported. User.Read.All

Important

When an application queries a relationship that returns a directoryObject type collection, if it doesn't have permission to read a certain resource type, members of that type are returned but with limited information. For example, only the @odata.type property for the object type and the id is returned, while other properties are indicated as null. With this behavior, applications can request the least privileged permissions they need, rather than rely on the set of Directory.* permissions. For details, see Limited information returned for inaccessible member objects.

HTTP request

GET /directory/deleteditems/microsoft.graph.application
GET /directory/deleteditems/microsoft.graph.servicePrincipal
GET /directory/deletedItems/microsoft.graph.group
GET /directory/deletedItems/microsoft.graph.user
GET /directory/deletedItems/microsoft.graph.administrativeUnit

The OData cast type is a required part of the URI and calling GET /directory/deleteditems without a type is not supported.

Optional query parameters

This method supports the query parameters that are supported by the resource that is specified by the OData cast. That is, $count, $expand, $filter, $orderby, $search, $select, and $top query parameters. This API returns 100 objects by default and supports returning up to 999 objects per page using $top.

Some queries are supported only when you use the ConsistencyLevel header set to eventual and $count. For example:

GET https://graph.microsoft.com/beta/directory/deletedItems/microsoft.graph.group?&$count=true&$orderby=deletedDateTime desc&$select=id,displayName,deletedDateTime
ConsistencyLevel: eventual

This example requires the ConsistencyLevel header because the $orderby and $count query parameters are used in the query.

$orderby OData query parameter examples

The $orderby OData query parameter is supported on the deletedDateTime, displayName, and userPrincipalName properties of the deleted object types. On the deletedDateTime property, the query requires adding the advanced query parameters (ConsistencyLevel header set to eventual and $count=true query string).

OData cast Properties supporting $orderby Example
microsoft.graph.user deletedDateTime, displayName, userPrincipalName /directory/deletedItems/microsoft.graph.user?$orderby=userPrincipalName
microsoft.graph.group deletedDateTime, displayName /directory/deletedItems/microsoft.graph.group?$orderby=deletedDateTime asc&$count=true
microsoft.graph.application deletedDateTime, displayName /directory/deletedItems/microsoft.graph.application?$orderby=displayName
microsoft.graph.device deletedDateTime, displayName /directory/deletedItems/microsoft.graph.device?$orderby=deletedDateTime&$count=true

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Accept application/json

Request body

Don't supply a request body for this method.

Response

If successful, this method returns a 200 OK response code and collection of directoryObject objects in the response body.

Examples

Example 1: Retrieve deleted groups

Request

GET https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.group

Response

Note: The response object shown here might be shortened for readability.

HTTP/1.1 200 OK
Content-type: application/json

{
  "@odata.context":"https://graph.microsoft.com/v1.0/$metadata#groups",
  "value": [
    {
      "id":"46cc6179-19d0-473e-97ad-6ff84347bbbb",
      "displayName":"SampleGroup",
      "groupTypes":["Unified"],
      "mail":"example@contoso.com",
      "mailEnabled":true,
      "mailNickname":"Example",
      "securityEnabled":false,
      "visibility":"Public"
    }
  ]
}

Example 2: Retrieve the count of deleted user objects and order the results by the deletedDateTime property

Request

GET https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.group?$count=true&$orderby=deletedDateTime asc&$select=id,DisplayName,deletedDateTime
ConsistencyLevel: eventual

Response

Note: The response object shown here might be shortened for readability.

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups(id,displayName,deletedDateTime)",
    "@odata.count": 2,
    "value": [
        {
            "id": "c31799b8-0683-4d70-9e91-e032c89d3035",
            "displayName": "Role assignable group",
            "deletedDateTime": "2021-10-26T16:56:36Z"
        },
        {
            "id": "74e45ce0-a52a-4766-976c-7201b0f99370",
            "displayName": "Role assignable group",
            "deletedDateTime": "2021-10-26T16:58:37Z"
        }
    ]
}