Easiest Way to Create a Sharing Link for a File or Folder Using Power Automate

When working in Power Automate, one of my team members recently asked, “How can I automatically create a sharing link for a file or folder in SharePoint?” This is a common need when teams want to share files easily without creating links manually every time.

Luckily, Power Automate has a simple solution! We can use the “Create sharing link for a file or folder” action in SharePoint to generate links with permissions like view-only or edit access quickly.

In this tutorial, I will tell you how to create a sharing link for a file or folder using Power Automate.

What is the Create sharing link for a file or folder Action?

The “Create sharing link for a file or folder” action in Power Automate generates a shareable link for a file or folder stored in a supported location, such as SharePoint. Depending on the sharing settings, this link can be used to share the file or folder with other users within or outside your organization.

Power Automate Create sharing link for a file or folder action accepts Parameters:

  • Site Address: Specifies the SharePoint site where the file or folder is located.
  • Library Name: The name of the document library that contains the file or folder.
  • Item Id: The unique ID of the file or folder for which you want to create the sharing link.
  • Link Type:
    • View and Edit: The generated link lets the recipient view and edit the file or folder.
    • View Only: The generated link lets the recipient view the file or folder. They will not be able to edit or make any changes to it.
  • Link Scope:
    • Anyone with the link, including anonymous: This link can be accessed by anyone who has the link, including users outside your organization (anonymous access).
    • People in your organization: The link can only be accessed by users with the necessary permissions within your organization.
  • Link Expiration: Sets an expiration date for the link, after which it becomes invalid.
What is the Create sharing link for a file or folder Action

Create a Sharing Link for a File Using Power Automate

Imagine you are managing a SharePoint document library called Project Resources, where your team stores files like project plans and reports.

power automate get link to sharepoint file

Whenever a new file is uploaded, share it with the project team in Microsoft Teams, either as a view-only link for reference materials or an edit link for collaborative documents.

Now follow the below steps:

1. Create an automated cloud flow. Give the flow name and select the trigger When a file is created (properties only). Also, provide the Site Address and Library Name.

create sharing link for a file or folder power automate

2. Add Create sharing link for a file or folder action and provide below parameters:

  • Site Address: Select the SharePoint site address from the drop-down.
  • Library Name: Select the library name where your file will be uploaded.
  • Item Id: Select the Id from the dynamic content (When a file is created (properties only)).
  • Link Type: Select the link type based on the requirement.
  • Link Scope: Select the link scope based on the requirement.
power automate create sharing link for a file or folder

3. Add Post Messages in a Chat or Channel Action and Provide the below parameters:

  • Post As: Select User. This allows you to post the message as the logged-in user (you or another user in your organization).
  • Post In: Choose Channel (since you want to post the message in a Teams channel, not a chat).
  • Team: Select the Team where you want to post the message.
  • Channel: Select the Channel within the team where you want the message to appear.
  • Message: Customize the Message field with dynamic content from your SharePoint list.
<p class="editor-paragraph"><br>A new file has been uploaded to the Project Resources library!<br><br>File Name: @{triggerBody()?['{Name}']}<br>Link: <a href="@{outputs('Create_sharing_link_for_a_file_or_folder')?['body/link/webUrl']}" class="editor-link">Click Here</a><br></p><br>
create sharing link for a file or folder

Now, it’s time to save the flow. Click on Test -> Select Manually. Add a file to the SharePoint library.

Create a Sharing Link for a File using Power Automate

After the flow runs successfully, you can check that the message has been posted to the selected Teams channel with the file link.

create share link power automate

Create a Sharing Link for Multiple Files Using Power Automate

In the example above, we saw how to create a sharing link for a file. I will show you how to create a sharing link for multiple files using Power Automate.

1. In the Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

share power automate flow

2. Add an “Initialize variable” action, provide a name for the variable, and set the type to Array.

power automate create link to sharepoint file

3. To retrieve multiple files, add the Get files (properties only) action and provide the below parameters:

  • Site Address: Select the SharePoint site address from the drop-down.
  • Library Name: Select the library name where your file will be present.
how do you create a link for a file in Power Automate

4. Add Create sharing link for a file or folder action and provide below parameters:

  • Site Address: Select the SharePoint site address from the drop-down.
  • Library Name: Select the library name where your file will be uploaded.
  • Item Id: Select the Id from the dynamic content (Get files (properties only)).
  • Link Type: Select the link type based on the requirement.
  • Link Scope: Select the link scope based on the requirement.
power automate how to share a flow

5. Inside For each, add Append to array variable action and provide below parameters:

  • Name: Select the variable name from the drop-down.
  • Value: Provide the below expression:
@{outputs('Create_sharing_link_for_a_file_or_folder')?['body/link/webUrl']}
Create a Sharing Link for Multiple Files using Power Automate

6. Add Send an email action and provide the below parameters:

  • To- Set the user where you want to send.
  • Subject- Give a subject to the email.
  • Body- Specify the body using the dynamic content.
<p class="editor-paragraph">Project Resources File 1: <a href="@{variables('varFiles')?[0]}" class="editor-link">Click Here</a></p><p class="editor-paragraph">Project Resources File 2: <a href="@{variables('varFiles')?[0]}" class="editor-link">Click Here</a></p>
how to create a link for a file using Power Automate

Now, click Save and run the flow manually. After the flow runs successfully, you will receive an email with the shareable links. When you click the link, it will redirect you to the specific file in the document library.

how to Create a Sharing Link for Multiple Files using Power Automate

Create a Sharing Link for a Folder using Power Automate

In this scenario, we will automate the process of creating sharing links for folders in a SharePoint document library and sending those links via email to a designated recipient. The process includes filtering for folders, creating sharing links, storing them in an array, and then sending an email with the link.

Create a Sharing Link for a Folder using Power Automate

Ensure that your SharePoint document library is set to allow content types. The folders you work with should be categorized under the Folder content type in your SharePoint library.

  • Go to your Project Resources document library in SharePoint.
  • Under the Library Settings, enable content types and ensure that the “Folder” content type is available.
Create a Sharing Link for a Folder in Power Automate

Now follow the below steps:

1. Create an Instant Cloud flow and choose the trigger flow (i.e., manually trigger a flow). Add the Get files (properties only) action and provide the below parameters:

  • Site Address: Select the SharePoint site where your document library is located.
  • Library Name: Choose Project Resources or the relevant document library.
  • Filter Query: Apply the following filter to get only folders:
ContentType eq 'Folder'
Power Automate Create a Sharing Link for a Folder

2. Add an “Initialize variable” action, provide a name for the variable, and set the type to Array.

How to Create a Sharing Link for a Folder using Power Automate

3. Add Create sharing link for a file or folder action and provide below parameters:

  • Site Address: Select the SharePoint site.
  • Library Name: Choose Project Resources (or your relevant document library).
  • Item Id: Use the dynamic content from the previous step (usually ID).
  • Link Type: Choose View or View and Edit (based on your requirement).
  • Link Scope: Choose between People in your organization or Anyone with this link.
  • Link Expiration: Set the expiration date, for example, for 3 days, use the expression
addDays(utcNow(), 3, 'yyyy-MM-dd')
power automate create link

4. Inside For each, add Append to array variable action and provide below parameters:

  • Name: Select the variable name from the drop-down.
  • Value: Choose the Sharing Link from the dynamic content. This will store the generated link for each folder.
@{outputs('Create_sharing_link_for_a_file_or_folder')?['body/link/webUrl']}
how to create a sharepoint link using Power Automate

5. Add a new step: Select Send an email (V2) (Outlook) and provide below parameter:

  • Select the user (either hardcode or use dynamic content to choose the recipient).
  • Subject: Provide a subject, such as “Access Links for New Folders in Project Resources”.
  • Body: Specify the body of the email using the dynamic content. Use HTML to add the sharing links for each folder. Here’s an example:
<p class="editor-paragraph">Dear Team,</p><br><p class="editor-paragraph">A new folder has been created in the Project Resources library:</p><br><p class="editor-paragraph">Here’s the sharing link: <a href="@{variables('varFolder')}" class="editor-link">Click Here</a></p><br><p class="editor-paragraph">Regards,</p><br>
sharepoint create shared folder in Power Automate

Save the flow and run it by selecting the Run flow option. Once the flow runs successfully, you will receive an email with the shareable links.

How to Create a Sharing Link for a Folder in Power Automate

Conclusion

In this tutorial, I explained how to use the “Create sharing link for a file or folder” action in Power Automate to generate shareable links for files or folders in SharePoint. We covered creating sharing links for single files, multiple files, and folders, along with options for link types (View Only or Edit), link scope (organization or anonymous access), and expiration dates.

You may also like:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…