Simplify File Sharing with Power Automate Links
Generate secure, granular sharing links for your SharePoint files—from anonymous access to specific users—all within automated workflows.
Shared access to files in SharePoint doesn’t have to mean giving away the keys to the whole site. A sharing link lets you grant exactly the level of access you want—from anyone with the link (even anonymous users) down to a handful of named recipients. Power Automate can create these links automatically, saving you from manual clicks every time a file needs to be distributed. In this article you’ll learn two approaches: the built-in SharePoint action for broad links, and a more precise method using the SharePoint REST API for user‑specific links.
The Scenario: Distributing Campaign Assets
Imagine a marketing team that stores campaign deliverables in a SharePoint library called Campaign Assets. The flow needs to share a file named Summer Campaign Brief.pdf in three different situations:
- Share with an external client anonymously (anyone with the link can view).
- Share with all internal team members (anyone in the organization can view).
- Share with a specific group of stakeholders (only those people can edit).
We’ll walk through flows that handle all three cases, and along the way you’ll see how to control permissions, set expiration dates, and avoid common pitfalls.
Method 1: Using the SharePoint Connector Action for Broad Sharing
The quickest way to create a sharing link is the Create sharing link for a file or folder action from the SharePoint connector. It supports the Anonymous and People in your organization scopes, with optional expiration and view/edit choice.
Step‑by‑Step Implementation
-
Start an instant cloud flow – Choose any trigger, for example For a selected file or a manual button.
-
Add the SharePoint action – Search for Create sharing link for a file or folder and select it.
-
Configure the action:
- Site Address: Your SharePoint site.
- Library Name: Campaign Assets.
- Item Id: The ID of the file (you can get it dynamically from the trigger or a previous action).
- Link Type: view or edit.
- Link Scope: Anonymous or Organization.
- Link Expiration Date: (Optional) Set a date/time after which the link stops working.
-
Send the link by email – Add an Outlook – Send an email (V2) action. In the email body, include an HTML anchor tag:
<p>Your file is ready: <a href="@{outputs('Create_sharing_link_for_a_file_or_folder')?['body/link/webUrl']}">Summer Campaign Brief.pdf</a></p>- Test the flow – Save and run. The recipient receives a clickable link. For anonymous links, no login is required; for organization links, the user must authenticate with the same tenant.
Anonymous links can be accessed by anyone who obtains the URL. Always combine them with a short expiration date unless the file is intentionally public.
Method 2: User‑Specific Links via the SharePoint REST API
When you need to restrict a sharing link to an explicit list of email addresses (internal or external), the built‑in action isn’t enough. Instead, you must call the SharePoint REST API (which is actually the Microsoft Graph /v2.0/drives endpoint) to create a link with scope: "users". This requires two preliminary steps: obtaining the Drive ID and the File Item ID.
Step 1 – Get the Drive ID of the Document Library
Add a Send an HTTP request to SharePoint action with these settings:
- Method:
GET - Uri:
_api/v2.0/drives - Headers: Accept –
application/json
The response contains all libraries on the site. Filter the array to find the one named Campaign Assets.
item()['name']
Then store the drive ID in a variable:
first(body('Filter_Drive'))?['id']Step 2 – Get the Item ID of the Target File
Make a second HTTP request:
- Method:
GET - Uri:
_api/v2.0/drives/@{variables('varDriveId')}/items/root/children - Headers: Accept –
application/json
Filter the returned items by name:
item()['name']
Extract the file ID:
first(body('Filter_Items'))?['id']Step 3 – Create the Sharing Link for Specific Users
First, prepare the list of recipients. In a Compose action, create an array of objects with an email property:
[
{ "email": "client@example.com" },
{ "email": "manager@contoso.com" },
{ "email": "designer@contoso.com" }
]Now add a Send an HTTP request to SharePoint action with the following settings:
- Method:
POST - Uri:
_api/v2.0/drives/@{variables('varDriveId')}/items/@{variables('varItemId')}/createLink - Headers: Accept –
application/json - Body:
{
"type": "edit",
"scope": "users",
"recipients": @{outputs('Compose_Recipients')}
}The response includes a webUrl property containing the sharing link.
Step 4 – Send the Link to All Recipients
Because the recipients are in an array, you need to extract their email addresses and join them into a semicolon‑separated list for the email To field.
- Select action: Extract the email values from the Compose output.
item()?['email']
-
Join expression: Use
join(outputs('Select_Emails'), ';')in the To field of the Send an email (V2) action. -
Email body: Use the web URL from the HTTP response.
<p>Access the file here: <a href="@{body('Send_HTTP_createLink')?['link']?['webUrl']}">Summer Campaign Brief.pdf</a></p>- Run the flow – Each recipient will get an email with a link that only they can use (they must authenticate). External users will receive a one‑time code or be prompted to sign in.
The Send an HTTP request to SharePoint action uses the flow owner’s credentials. Ensure that user has at least Contribute permissions on the library and the “Create Share Link” permission (default for site members).
Security and Delegation Considerations
- Anonymous links – Widest access; anyone with the URL can view (or edit if type is “edit”). Use only for non‑sensitive content or set a short expiration.
- Organization links – All internal users can access; still broad. Best for company‑wide resources.
- User‑specific links – Most secure. The link can only be used by the specified recipients, and they must authenticate. Even if forwarded, others cannot use it.
- Expiration – Always set an expiration date when possible. The built‑in action has a dedicated field; for the API method you can omit the
expirationDateTimeproperty to never expire, or add it as ISO 8601.
Common Pitfalls and Troubleshooting
| Symptom | Likely Cause | Solution |
|---|---|---|
| SharePoint HTTP action returns 403 | Insufficient permissions | Verify flow owner has “Create Share Link” rights. Try a site collection admin account. |
| Filter array returns empty | Library name mismatch | Check the exact name in SharePoint (case‑sensitive). Use contains or eq carefully. |
| “You cannot access this link” from email | Recipient not in the recipients array | Confirm the email was included in the Compose action. External users may need to be added as guests. |
JSON parsing error in body | Incorrect syntax in recipients array | Ensure the @{} expression is placed correctly and the array is valid JSON. |
Final Recommendation
For simple, broad sharing (anonymous or all internal users), the Create sharing link for a file or folder action is sufficient and easy to configure. When you need to restrict access to a curated list of users—especially when mixing internal and external stakeholders—invest the extra steps to use the SharePoint REST API. In both cases, enforce an expiration date and regularly audit the sharing links your flows generate.
References
- Matthew Devaney’s original article: How to Create a Sharing Link for Files in Power Automate
- Microsoft Learn: Create sharing link for a file or folder (SharePoint connector) – [Placeholder: search for official URL]
- Microsoft Graph API: createLink endpoint – [Placeholder: docs.microsoft.com/graph/api/driveitem-createlink]
Core principles for resilient, maintainable, and efficient cloud flows, distilled from real-world implementations.
Build flows that gracefully handle failures and automatically notify you with run details.
Discover the trade-offs between Content-ID, Base64, and the Microsoft Graph API for embedding images in Power Automate emails. This guide covers which method works best for Outlook, Gmail, and more.