Hello john john,
Thanks for reaching out!
Yes, the Microsoft Graph API provides an endpoint to delete unique permissions for files, items, and folders in SharePoint Online. You can use the BreakAccessInheritance
method to achieve this action.
To delete unique permissions for a specific file, item, or folder, you need to make a POST
request to the following endpoint:
POST /sites/{site-id}/drive/items/{item-id}/breakAccessInheritance
Replace {site-id}
with the ID of the SharePoint site where the file, item, or folder is located, and replace {item-id}
with the ID of the file, item, or folder itself.
Here's an example of how the request can be made using the Microsoft Graph API in PowerShell:
$siteId = "<site-id>"
$itemId = "<item-id>"
$accessToken = "<access-token>"
$baseUrl = "https://graph.microsoft.com/v1.0"
$endpoint = "/sites/$siteId/drive/items/$itemId/breakAccessInheritance"
$headers = @{
"Authorization" = "Bearer $accessToken"
"Content-Type" = "application/json"
}
$response = Invoke-RestMethod -Method Post -Uri "$baseUrl$endpoint" -Headers $headers
if ($response.StatusCode -eq 204) {
Write-Host "Unique permissions deleted successfully."
} else {
Write-Host "Error deleting unique permissions: $($response.StatusCode) - $($response.StatusDescription)"
}
Make sure to replace <site-id>
, <item-id>
, and <access-token>
with the appropriate values for your scenario.
By using the BreakAccessInheritance
method, you can remove unique permissions and revert to the permissions inherited from the parent site.
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.