Skip to main content

How to Create a File in SharePoint in Power Automate

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

The SharePoint connector's Create file action saves a file into a document library: you give it the site, the folder, a file name and the content. The content can be text you type, or the content of another file, which makes it the way to copy a file under a new name.

The example creates hello.txt, containing Hello from SharePoint!, in the Documents library of a SharePoint site called Communication site.

Prerequisites​

  • Permission to add files to the library for the account the flow's SharePoint connection uses. The file is created as that account.

Step 1: Add Create file​

In a flow with the trigger Manually trigger a flow, select +, Add an action and search for Create file. Select it under SharePoint: OneDrive for Business has an action with the same name, and the search may list that one first.

Step 2: Fill the Four Fields​

  • Site Address: the site, picked from the list, here Communication site.
  • Folder Path: select the folder icon and pick the library, or a folder in it. The Documents library's path is /Shared Documents, its address in the site. Microsoft's SharePoint connector reference says the path must start with an existing library.
  • File Name: the name with its extension, here hello.txt.
  • File Content: what goes in the file, here Hello from SharePoint!.

The Create file action with Site Address Communication site - https://contoso.sharepoint.com, Folder Path /Shared Documents, File Name hello.txt and File Content Hello from SharePoint!

Step 3: Run the Flow​

Save the flow and test it (How to Test a Cloud Flow Manually in Power Automate). Create file took 0.7 seconds:

The run of Create a SharePoint File with the message Your flow ran successfully., and green ticks on Manually trigger a flow, 0s, and Create file, 0.7s

The Result​

The Documents library has hello.txt, modified about a minute ago:

The Documents library listing the Scripts folder, hello.txt modified About a minute ago, and Team Budget.xlsx, each modified by Admin User

Create file also returns details of the new file for the steps after it, such as its path and an identifier. To get its link, see How to Get a Link to a SharePoint File in Power Automate.

Common Mistakes​

MistakeWhat happensDo this instead
Picking OneDrive's Create fileThe file goes to a OneDrive, not the sitePick the action under SharePoint
Typing the library's name, /Documents, as the pathThe path is the library's address, /Shared Documents, not its namePick the folder with the folder icon

Troubleshooting​

SymptomLikely causeFix
The action asks you to sign in to OneDriveIt's OneDrive's Create fileDelete it and add the SharePoint one
The action uses a connection you didn't expectThe designer picked an existing connection referenceCheck Connected to under the action and Change connection reference (Fixed: A Flow in a Solution Uses Another Solution's Connection Reference in Power Automate)
The run fails with access deniedThe connection's account can't add files to the libraryGive that account edit access to the library

FAQ​

How do I copy a file under a new name?​

Read the original with Get file content using path (How to Read a File from SharePoint in Power Automate), then use its File Content in Create file with the new name.

Can the name come from the flow?​

Yes. Type around tokens or expressions in File Name, for example a month from formatDateTime() to make one file per month (How to Format a Date in Power Automate with formatDateTime).

Can I put the file in a folder that doesn't exist yet?​

The reference says Must start with an existing library. Add folders if needed. Pick an existing folder with the folder icon, or create the folder first (How to Create a Folder in a SharePoint Document Library).

Conclusion​

Create file, under SharePoint, saves a file: a site, a folder path that starts with a library, a name and the content. Pick the folder with the folder icon, so the path matches the library's address.

Additional Resources​