How to Create a SharePoint Document Library in Power Automate?

Last week, I worked on a SharePoint project where I received a requirement to automate the creation of a SharePoint Document Library. The client needed a solution to dynamically create a new SharePoint Document Library whenever a specific event occurred, without manually setting them up each time.

After researching, I found a solution: we can automatically use the Power Automate “Send an HTTP request to SharePoint” connector to create a SharePoint library.

In this tutorial, we will learn how to create a SharePoint document library in Power Automate. We will also cover how to create a folder and a file within the SharePoint document library using Power Automate.

Create a SharePoint Document Library in Power Automate

I will show you how to create a document library using Power Automate.

In Power Automate, we don’t have any direct action to create a document library, so I will use HTTP requests to create a SharePoint document library.

Now follow the below steps:

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).

how to create a document library in sharepoint using Power Automate

2. Then add a Send an HTTP request to SharePoint action from sharePoint Connector with the below parameter:

  • Site Address: Select the SharePoint site where you want the library to be created
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
_api/web/lists/
  • Headers: Add a key-value pair:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
  • Body: Provide the below JSON format to specify the properties of the new SharePoint document library:
{
  "__metadata": { "type": "SP.List" },
  "BaseTemplate": 101,
  "Title": "Finance Records",
  "Description": "For managing financial documents"
}

Replace “Finance Records” with your desired name for the SharePoint document library. The BaseTemplate value of 101 is for a custom list. You can use other templates, like 100, for a SharePoint list if needed.

Create a SharePoint Document Library using Power Automate

Now, click Save and run the flow manually after it runs successfully. Go to the SharePoint site to see that the SharePoint document library has been created successfully.

Power Automate Create a SharePoint Document Library

Create Columns in SharePoint Document Library Using Power Automate

Suppose you are looking to create columns for a SharePoint document library using Power Automate. In that case, I’ve already written a complete tutorial on how to Create Different Columns in a SharePoint Library Using Power Automate.

Create a Folder in Document Library using Power Automate

For this example, I created a SharePoint document library called Corporate Projects.

power automate create document library

I also created a SharePoint list called Project Tracker.

power automate sharepoint document library

Each new project requires its own subfolder structure. Every time a new project is added to your project tracker (a SharePoint list), you need to create folders like Contracts, Designs, and Reports within a specific folder for that project. Creating these folders can be time-consuming, so I will show you how to create them using Power Automate.

Now follow the below steps:

1. Create an automated cloud flow. Give the flow name and select the trigger When an item is created. Also, provide the Site Address and List Name.

how to create a document library in sharepoint online using Power Automate

2. Then add a Send an HTTP request to SharePoint action from sharePoint Connector with the below parameter:

  • Site Address: Select the SharePoint site where is your library
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
_api/web/GetFolderByServerRelativePath(decodedurl='YourLibraryName')/Folders
  • Headers: Add a key-value pair:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose

Body: Provide the below JSON format to specify the properties of creating the folder:

{
 '__metadata': { 'type': 'SP.Folder' },
 'ServerRelativeUrl': 'YourLibraryName/@{triggerBody()?['ProjectName']}'
}
Create a Folder in Document Library using Power Automate

3. Then again, add a Send an HTTP request to SharePoint action from sharePoint Connector with the below parameter:

  • Site Address: Select the SharePoint site
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
_api/web/GetFolderByServerRelativePath(decodedurl='YourLibraryName')/Folders
  • Headers: Add a key-value pair:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
  • Body: Provide the below JSON format to specify the properties of creating the folder:
{
 '__metadata': { 'type': 'SP.Folder' },
 'ServerRelativeUrl': 'YourLibraryName/@{triggerBody()?['ProjectName']}/Contracts'
}
how to create a new library in sharepoint using Power Automate

In the same way add Send an HTTP request to SharePoint two times for Designs and Reports like the below screenshot:

how to create document library in sharepoint using Power Automate

Now click on Save, and to run the flow, create an item in the SharePoint list.

create a new library in sharepoint using Power Automate

After the flow runs successfully, go to the SharePoint site and check the document library. You will see that the folder and subfolder have been created successfully.

How to Create a Folder in Document Library using Power Automate

Create a File in SharePoint Document Library Using Power Automate

In this example, I will show you how to create a file in the SharePoint document library using a Power Automate HTTP request.

Create an Instant clued flow, then add a Send an HTTP request to SharePoint action and Provide the below parameter:

  • Site Address: Select the SharePoint site
  • Method: Select “POST” as the method
  • URI: Provide the below URI:
_api/web/GetFolderByServerRelativeUrl('YourLibraryName')/Files/add(url='YourFileName.extension',overwrite=true)
  • Headers: Add a key-value pair:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose

In my case, I want to create an Excel file, so give the URL Project Management Tasks.xlsx

How to Create a File in SharePoint Document Library using Power Automate

Now, click Save and run the flow manually after it runs successfully. Go to the SharePoint site to see that the Excel file has been created successfully.

Create a File in SharePoint Document Library using Power Automate

In this tutorial, I covered how to create a SharePoint document library using the “Send an HTTP request to SharePoint” action in Power Automate. We also explored creating folders and subfolders dynamically within a document library and learned how to create files within a SharePoint document library using Power Automate.

Related Power Automate articles:

  • Can any of these steps be used to create a new view in a current library? Looking for a way for a user to complete a simple form which will be used as the basis for setting up a new site page along with creating a new folder in the library. On the site page I’m hoping to include a library webpart which would be filtered to only show items with the project title. Hoping I’d be able to use power automate to create the filtered view.

  • >

    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…