“Can I restrict users from restoring deleted files from the recycle bin, to delete them also from there within Power Automate flow?”
If you use SharePoint as a document management system, you get a lot of functionality out of the box. Files are versioned, there’s support for draft/published versions, and nothing is deleted permanently. And that’s great in many situations. But in some specific situations it’s not beneficial, more specifically if you delete files using a flow and users keep restoring them from the recycle bin.
How do you fully delete a file to avoid it?
Delete file from a recycle bin with an HTTP request
As Power Automate doesn’t have any action related to the SharePoint recycle bin, you must use a “workaround”. That means another HTTP requests, or two…
To delete a file from a recycle bin you need the file ID. Not the file name, not the identifier, but the unique id in the recycle bin. This id will be among the outputs of the HTTP request below…
Method: GET Uri: _api/web/RecycleBin?$filter=LeafName eq '<fileNameWithExtension>'&$select=Id
…and you can access it directly with this expression:
Once you have the id you can do the actual removal from the recycle bin.
Method: DELETE Uri: _api/web/RecycleBin('<fileUniqueId>')
That’s it, the file is completely gone.
Recycle bin is another part of SharePoint that doesn’t have a direct support from Power Automate, yet if you delete any file it’ll always end there. If you want to remove it also from the recycle bin, you’ll need two HTTP requests – one to get the file ID and another one to delete the file. Just be careful with the solution as it’s bypassing one of the safety SharePoint features. Once you delete the file it’ll be deleted completely.