Sometimes, you may want to delete files from the SharePoint document library permanently. To do this, you can use Rest Api in Power Automate.
In this tutorial, I will show you how to delete a file from SharePoint using the REST API in Power Automate.
Delete Files From SharePoint Document Library Using Rest API in Power Automate
If you think we can delete the file using the Delete file action, why the Rest API? The Delete file action required the file identifier, meaning you must take another action to retrieve it. Then, it only deletes the file to the Recycle Bin and doesn’t offer advanced options like permanent deletion.
Suppose you are working on a project, and now that it’s completed, you want to delete a file or multiple files or delete files based on certain conditions. In this tutorial, I’ll explain how to do all of that.
Delete Single File From a SharePoint Library
Let’s start with the easiest example: deleting a single file in the SharePoint library using Rest API in Power Automate.
Below is a SharePoint Library set where I want to delete the Project Deadlines Excel file.

Here are the steps to do this:
- Open Power Automate and create an Instant cloud flow that will trigger the flow manually.
- Add a Send an HTTP request to SharePoint action under the trigger and provide the below parameters:
- Site Address: Select the SharePoint site address from the dynamic content.
- Method: Select DELETE as the method.
- URI: Provide the below URI:
_api/web/getFileByServerRelativeUrl('/sites/PowerAutomateTutorial/ReportStorage/Project Deadlines.xlsx')
Here:
- PowerAutomateTutorial: Site Internal Name
- ReportStorage: SharePoint Library Internal Name
- Project Deadlines.xlsx: File Name

- Now save the flow and run it manually. After the flow successfully runs, go to the SharePoint library. You can see the file has been deleted.

Note:
Test this flow with your demo file. Once you delete the file using this flow, you cannot retrieve it, as it permanently deletes the file.
Delete Multiple Files From the SharePoint Document Library
Deleting multiple files in the SharePoint library is a little different from deleting one file.
Below is a SharePoint library where I want to delete all files:

To do this, follow the below steps:
- Go to Power Automate and click Create -> Instant Cloud Flow. Select Manually trigger a flow as the trigger.
- Then, add a Get files (properties only) action to get all the file names. Provide the below parameters:
- Site Address: Select the site where the library is present.
- Library Name: Select the library from the drop-down.

- Add a Send an HTTP request to SharePoint action to delete files and provide the below parameters:
- Site Address: Select the SharePoint site address from the dynamic content.
- Method: Select DELETE as the method.
- URI: Provide the below URI:
_api/web/getFileByServerRelativeUrl('/sites/PowerAutomateTutorial/ Full Path ')
Where:
- Full Path: Replace the Full Path from Get files (properties only) using dynamic content.
It will automatically add the for each loop.

- Now, save the flow: click Test (top-right corner), select Manually, click Test again, and click Run flow.
- After the flow successfully runs, go to the SharePoint library. You can see the file has been deleted.

Delete Files From the SharePoint Document Library Based on Condition
Sometimes, you only want to delete specific files, like those older than a certain date or those with a particular name.
We will filter the files and use the REST API in Power Automate to delete only those that match our condition.
Let’s say you want to automatically delete all .pdf files older than 30 days in a SharePoint library.
Filter the Files From the SharePoint Library
- Create an Instant cloud flow with a trigger (Manually trigger a flow).
- Add the Get files (properties only) action:
- Site Address: Select your SharePoint site.
- Library Name: Choose your document library.

This will return all files from the library.
- Add an Apply to each loop to review each file from the “Get files” action.

- Inside the loop: Use the Condition control to check:
- If file is a PDF ->
Nameends with .pdf - And file is older than 30 days
- If file is a PDF ->
File Name with extentation ends with '.pdf'
AND
Created date is less than addDays(utcNow(), -30)

Note:
If you’re using the Created field from SharePoint, it’s usually available in dynamic content. Otherwise, use item()?[‘Created’] in an expression.
Delete Files From the SharePoint Library
Now the condition control will give the file which we want to delete; we need to add the last steps:
- Add a Send an HTTP request to SharePoint action to delete files and provide the below parameters:
- Site Address: Select the SharePoint site address from the dynamic content.
- Method: Select DELETE as the method.
- URI: Provide the below URI:
_api/web/getFileByServerRelativeUrl('/sites/PowerAutomateTutorial/items()?[{'FullPath'}] ')

This will delete the PDF file permanently if it matches both conditions.
- Save the flow and run it manually. Once the flow runs successfully.
- Go to the SharePoint document library. You will see that all PDF files created more than 30 days ago have been deleted.

On the left, you can see the files before deletion; on the right, you can see the result after the files were deleted.
These are some ways to permanently delete files from a SharePoint document library using Power Automate and REST API.
While using the Delete file action is quick, the REST API gives you more control, especially when you want to delete multiple files or delete files based on conditions permanently.
I hope you found this tutorial helpful! If you have any questions or suggestions, feel free to drop them in the comments.
Other Power Automate tutorials you may also like:
- Use Rest API in Power Automate
- Power Automate IF Expression
- Create a SharePoint List Lookup Column Using Power Automate
- Disable Title As Mandatory Field From SharePoint List Using Power Automate
- Disable Include Time Option in SharePoint List Date Time Column Using Power Automate

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.