List deletedItems (directory objects)
Namespace: microsoft.graph
Important
APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Retrieve a list of recently deleted directory objects. Currently, this functionality is only supported for the application, group, and user resources.
Currently, deleted items functionality is only supported for the application, servicePrincipal, group, and user resources.
Note: Deleted security groups are deleted permanently and can't be retrieved through this API.
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
For applications and service principals:
| Permission type | Permissions (from least to most privileged) |
|---|---|
| Delegated (work or school account) | Application.Read.All, Application.ReadWrite.All, Directory.Read.All, Directory.ReadWrite.All |
| Delegated (personal Microsoft account) | Not supported. |
| Application | Application.Read.All, Application.ReadWrite.All, Directory.Read.All |
For users:
| Permission type | Permissions (from least to most privileged) |
|---|---|
| Delegated (work or school account) | User.Read.All, User.ReadWrite.All, Directory.Read.All, Directory.ReadWrite.All |
| Delegated (personal Microsoft account) | Not supported. |
| Application | User.Read.All, User.ReadWrite.All, Directory.Read.All, Directory.ReadWrite.All |
For groups:
| Permission type | Permissions (from least to most privileged) |
|---|---|
| Delegated (work or school account) | Group.Read.All, Group.ReadWrite.All, Directory.Read.All |
| Delegated (personal Microsoft account) | Not supported. |
| Application | Group.Read.All, Group.ReadWrite.All, Directory.Read.All |
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
This API currently supports retrieving object types of applications (microsoft.graph.application), servicePrincipals (microsoft.graph.serviceprincipal), groups (microsoft.graph.group), or users (microsoft.graph.user) from deleted items. 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. Some queries are supported only when you use the ConsistencyLevel header set to eventual and $count. For example:
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.
Examples using the $orderBy OData query parameter
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 true 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 <code> Required |
| Accept | application/json |
Request body
Do not 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/beta/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/beta/$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/beta/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/beta/$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"
}
]
}
Feedback
Submit and view feedback for