Skip to the stories
Microsoft 365 & SharePoint

Microsoft Entra ID Custom Roles Gain Graph API Soft Delete and Restore

  • Vasil Michev
  • 536 views

Custom Entra ID roles can now be restored after deletion through Microsoft Graph. Admins should check assignments, PIM sync and audit events.

Microsoft Entra ID Custom Roles Gain Graph API Soft Delete and Restore

Deleting a custom Microsoft Entra ID directory role no longer has to be an immediate, permanent change. Microsoft has added a soft-deleted container for custom role definitions, with Microsoft Graph methods to list, restore or permanently remove them. For administrators, the main operational change is a recovery path; the main limitation is that most of its controls are available through the Graph API rather than the Entra admin center.

The feature applies to custom unifiedRoleDefinition objects associated with the Entra ID provider. Built-in role definitions cannot be deleted and aren’t included. Custom roles have supported resource actions for some time, although scoping remains a limitation in the role based access control model. Microsoft’s custom permissions documentation describes creating these roles, and the Graph API role management resources provide endpoints for working with them.

Find custom roles and delete one

The Entra admin center can show custom roles under Roles and administrators > All Roles. Filter the list by Type and choose Custom. The interface offers a Delete custom role action, but it doesn’t expose the new deleted items container or its restore and permanent deletion methods.

To list custom role definitions through Graph, use the beta endpoint and filter out built-in roles. This query requires RoleManagement.Read.Directory permission:

GET https://graph.microsoft.com/beta/roleManagement/directory/roleDefinitions?$filter=isBuiltIn eq false

Record the role’s ID before deleting it. The deletion request requires RoleManagement.ReadWrite.Directory or equivalent permissions:

DELETE https://graph.microsoft.com/beta/roleManagement/directory/roleDefinitions/e76ee92b-0665-4e06-a973-74bf95e19813

A successful request returns 204 No Content. The role definition moves into the deleted items container, where administrators can inspect it with a GET request:

GET https://graph.microsoft.com/beta/roleManagement/directory/deletedItems/roleDefinitions

Deleting a custom Entra ID role through Graph

A custom role listed in the deleted items container

The deleted role retains its other properties, and its deletedDateTime property records when the deletion occurred. It disappears from the Entra admin center and from the standard /directory/roleDefinitions/ results. It can’t receive new role assignments while deleted. Existing active assignments are invalidated, though eligible assignments may still appear temporarily because Privileged Identity Management (PIM) can take additional time to synchronize role deletions.

Restore the role or remove it permanently

If the deletion needs to be reversed, send a POST request to the role’s restore endpoint. Microsoft documents this as the restore method for unified role definitions:

POST https://graph.microsoft.com/beta/roleManagement/directory/deletedItems/roleDefinitions/e76ee92b-0665-4e06-a973-74bf95e19813/restore

Restoration clears deletedDateTime and restores active role assignments. PIM data may take additional time to reflect the change, so administrators should allow for synchronization before treating the role and its assignments as fully available again.

The retention period for deleted role definitions isn’t specified in the documentation described here. A 30-day period may be expected based on other soft-deleted objects, but that duration isn’t confirmed for these roles. Administrators who need to remove a deleted role sooner can issue DELETE against its entry in the deleted items container:

DELETE https://graph.microsoft.com/beta/roleManagement/directory/deletedItems/roleDefinitions/e76ee92b-0665-4e06-a973-74bf95e19813

As with the initial deletion, 204 No Content indicates success. A 401 Unauthorized response was also observed during testing; it may have been temporary, so check the request’s permissions and retry behavior before drawing conclusions from that response.

Restoring a soft-deleted custom Entra ID role

Permanently deleting a soft-deleted custom role

Check the audit events

Custom role lifecycle operations are recorded in the audit log under Delete role definition, Restore role definition and Hard Delete role definition. To narrow the results, filter Service to Core Directory and Category to RoleManagement.

Audit log filters for custom role lifecycle events

One detail can complicate audit review: the event’s Target Id doesn’t match the custom role’s Id or templateId returned by the standard role definitions endpoint. Teams investigating a change should account for that mismatch when correlating audit entries with role records.

For now, the admin center provides a way to initiate deletion, while Graph handles listing deleted roles, restoring them and permanently removing them. Administrators managing custom roles should capture each role’s ID and understand how its assignments behave before deleting it; after a restore, allow PIM time to catch up and confirm the resulting state in the audit log.

Source: Vasil Michev · michev.info

Neighbouring cells