Skip to content

Latest commit

 

History

History
306 lines (244 loc) · 13.5 KB

File metadata and controls

306 lines (244 loc) · 13.5 KB
title Restore deleted item (directory object)
ms.date 11/17/2025
description Restore a recently deleted application, group, service principal, or user from deleted items.
author FaithOmbongi
ms.localizationpriority medium
ms.subservice entra-directory-management
doc_type apiPageType

Restore deleted item (directory object)

Namespace: microsoft.graph

[!INCLUDE beta-disclaimer]

Restore a recently deleted directory object from deleted items. The following types are supported:

If an item is accidentally deleted, you can fully restore the item. Additionally, restoring an application doesn't automatically restore the associated service principal automatically. You must call this API to explicitly restore the deleted service principal.

A recently deleted item remains available for up to 30 days. After 30 days, the item is permanently deleted.

[!INCLUDE national-cloud-support]

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.ReadWrite.All Not supported. AdministrativeUnit.ReadWrite.All
application Application.ReadWrite.All Not supported. Application.ReadWrite.OwnedBy
agentIdentity AgentIdentity.DeleteRestore.All Not supported. AgentIdentity.DeleteRestore.All
agentIdentityBlueprint AgentIdentityBlueprint.DeleteRestore.All Not supported. AgentIdentityBlueprint.DeleteRestore.All
agentIdentityBlueprintPrincipal AgentIdentityBlueprintPrincipal.DeleteRestore.All Not supported. AgentIdentityBlueprintPrincipal.DeleteRestore.All
agentUser AgentIdUser.ReadWrite.IdentityParentedBy Not supported. AgentIdUser.ReadWrite.IdentityParentedBy
certificateBasedAuthPki PublicKeyInfrastructure.Read.All Not supported. PublicKeyInfrastructure.Read.All
certificateAuthorityDetail PublicKeyInfrastructure.Read.All Not supported. PublicKeyInfrastructure.Read.All
externalUserProfile ExternalUserProfile.ReadWrite.All Not supported ExternalUserProfile.ReadWrite.All
group Group.ReadWrite.All Not supported. Group.ReadWrite.All
pendingExternalUserProfile PendingExternalUserProfile.ReadWrite.All Not supported PendingExternalUserProfile.ReadWrite.All
servicePrincipal Application.ReadWrite.All Not supported. Application.ReadWrite.OwnedBy
user User.DeleteRestore.All Not supported. User.DeleteRestore.All

[!INCLUDE rbac-directory-deleted-items-apis]

HTTP request

POST /directory/deletedItems/{id}/restore

Request headers

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

Request body

In the request body, supply a JSON representation of the parameters.

The following table lists the parameters that are required when you call this action.

Parameter Type Description
autoReconcileProxyConflict Boolean Optional parameter. Indicates whether Microsoft Entra ID should remove any conflicting proxy addresses while restoring a soft-deleted user whose one or more proxy addresses are currently used for an active user. Used only for restoring soft-deleted user. The default value for this paramater is false.
newUserPrincipalName String The new userPrincipalName to add to the restored user. Optional.

Response

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

Examples

Example 1: Restore a deleted directory object

Request

POST https://graph.microsoft.com/beta/directory/deletedItems/46cc6179-19d0-473e-97ad-6ff84347bbbb/restore

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


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#directoryObjects/$entity",
  "@odata.type":"#microsoft.graph.group",
  "id":"46cc6179-19d0-473e-97ad-6ff84347bbbb",
  "displayName":"SampleGroup",
  "groupTypes":["Unified"],
  "mail":"example@contoso.com",
  "mailEnabled":true,
  "mailNickname":"Example",
  "securityEnabled":false,
  "visibility":"Public"
}

Example 2: Restore a deleted user and remove conflicting proxy addresses

Request

POST https://graph.microsoft.com/beta/directory/deletedItems/78bf875b-9343-4edc-9130-0d3958113563/restore
Content-Type: application/json

{
  "autoReconcileProxyConflict": true
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


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#users/$entity",
    "@odata.type": "#microsoft.graph.user",
    "id": "78bf875b-9343-4edc-9130-0d3958113563",
    "businessPhones": [],
    "displayName": "SampleUser",
    "givenName": "Sample",
    "jobTitle": "Product Marketing Manager",
    "mail": "sampleuser@contoso.com",
    "mobilePhone": "+1 425 555 0109",
    "officeLocation": "18/2111",
    "preferredLanguage": "en-US",
    "surname": "Vance",
    "userPrincipalName": "sampleuser@contoso.com"
}

Example 3: Restore a deleted user and assign them a new userPrincipalName

Request

POST https://graph.microsoft.com/beta/directory/deletedItems/78bf875b-9343-4edc-9130-0d3958113563/restore
Content-Type: application/json

{
  "newUserPrincipalName": "johndoe@contoso.com"
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


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#directoryObjects/$entity",
    "@odata.type": "#microsoft.graph.user",
    "id": "78bf875b-9343-4edc-9130-0d3958113563",
    "businessPhones": [],
    "displayName": "SampleUser",
    "givenName": "Sample",
    "mobilePhone": "+1 425 555 0109",
    "officeLocation": "18/2111",
    "preferredLanguage": "en-US",
    "surname": "Vance",
    "userPrincipalName": "johndoe@contoso.com"
}