Skip to the stories
Microsoft 365 & SharePoint

Microsoft Entra ID Adds Soft Delete and Restore for Custom Roles

By Vasil Michev 946 views

Custom Entra ID roles can now be restored after deletion or permanently removed through Microsoft Graph. Check assignments and PIM synchronization during changes.

Microsoft Entra ID Adds Soft Delete and Restore for Custom Roles

Deleting a custom Microsoft Entra ID directory role now has a recovery path: Microsoft has added soft deletion, restoration and permanent deletion for custom role definitions through Microsoft Graph. The change gives administrators a way to undo a role removal, while also making it important to check the effect on existing assignments and Privileged Identity Management (PIM) synchronization.

The feature applies to custom roles represented by unifiedRoleDefinition objects for the Entra ID provider. Built-in roles cannot be deleted and aren’t included. The Entra admin center can show custom roles and initiate their soft deletion, but listing deleted roles, restoring them and permanently deleting them currently requires Graph API requests.

Find custom roles before changing them

In the Entra admin center, open Roles and administrators > All Roles, filter Type to Custom, and select a role to use Delete custom role. That action soft-deletes the role. The interface doesn’t expose the deleted-role container or its restore and permanent-delete operations.

Administrators can enumerate custom role definitions in Microsoft Graph using the beta endpoint. The request requires RoleManagement.Read.Directory permission:

# List custom Entra ID directory roles
GET https://graph.microsoft.com/beta/roleManagement/directory/roleDefinitions?$filter=isBuiltIn eq false

Custom roles have been available for some time, with supported resource actions expanding over time. The available capabilities still don’t provide a fully developed role-based access control model, in part because scoping remains a limitation. Microsoft’s [custom role documentation](https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/custom-user-permissions) describes role creation, though its list of supported actions may not include every available action. Graph API details for role management are available in the [roleManagement resource reference](https://learn.microsoft.com/en-us/graph/api/resources/rolemanagement?view=graph-rest-beta).

Soft deletion affects assignments

To delete a custom role through Graph, use its ID in a DELETE request. The operation requires RoleManagement.ReadWrite.Directory or equivalent permissions. A successful request returns 204 No Content and moves the definition into the deleted-items container.

Deleting a custom Entra ID role

# Soft-delete a custom Entra ID directory role
DELETE https://graph.microsoft.com/beta/roleManagement/directory/roleDefinitions/e76ee92b-0665-4e06-a973-74bf95e19813

Administrators can then inspect deleted definitions by querying /beta/roleManagement/directory/deletedItems/roleDefinitions. The deleted role retains its other properties, while deletedDateTime records when it was removed. Deleted roles disappear from the Entra admin center and from the regular role definitions query. They can’t receive new role assignments, and active assignments are invalidated.

A custom role in the deleted-items container

# List deleted custom Entra ID directory roles
GET https://graph.microsoft.com/beta/roleManagement/directory/deletedItems/roleDefinitions

Eligible assignments may remain visible while PIM catches up with the role deletion. PIM synchronization can take additional time, so administrators should account for that delay when reviewing a removal or troubleshooting assignment state. The role’s presence in the deleted-items container indicates that it can still be restored, but it shouldn’t be treated as available for new assignment.

Restore a role or remove it permanently

To reverse a soft deletion, send a POST request to the role’s restore endpoint. The operation clears deletedDateTime and restores active role assignments. PIM-related changes may need more time to synchronize. Microsoft documents the operation in its [Graph restore method reference](https://learn.microsoft.com/en-us/graph/api/unifiedroledefinition-restore?view=graph-rest-beta).

Restoring a soft-deleted custom role

# Restore a soft-deleted custom role
POST https://graph.microsoft.com/beta/roleManagement/directory/deletedItems/roleDefinitions/e76ee92b-0665-4e06-a973-74bf95e19813/restore

A role can also be permanently removed before its soft-deleted copy expires. The retention period for custom role definitions isn’t specified in the available documentation. A 30-day period may be expected based on other soft-deleted object types, but that duration isn’t confirmed for these roles. Administrators who need immediate, permanent removal can send a DELETE request against the object in the deleted-items container.

Permanently deleting a soft-deleted custom role

# Permanently delete a custom role
DELETE https://graph.microsoft.com/beta/roleManagement/directory/deletedItems/roleDefinitions/e76ee92b-0665-4e06-a973-74bf95e19813

A 204 No Content response indicates that the permanent deletion succeeded. During testing, 401 Unauthorized responses were also seen; their cause wasn’t established, so administrators encountering them should verify the request permissions and current service behavior rather than assume the role was removed.

Track role lifecycle changes in the audit log

Role deletion, restoration and permanent deletion are recorded in the audit log as Delete role definition, Restore role definition and Hard Delete role definition. To narrow results to these lifecycle events, filter Service to Core Directory and Category to RoleManagement.

Audit log events for custom role lifecycle changes

One detail can complicate investigations: the audit event’s Target Id doesn’t match the role’s Id or templateId returned by the standard role definitions endpoint. Teams tracing a change should use the event type and surrounding audit details as well as the target identifier, rather than expecting those IDs to line up.

For administrators, the practical change is a recoverable deletion path for custom roles, with Graph API required for recovery and permanent removal. Before deleting a role, review its assignments and plan for PIM synchronization delays; after the change, use the deleted-items endpoint and audit events to confirm the role’s state.

Source: Vasil Michev · michev.info

From the same basket