How to Create a SharePoint Online Communication Site Using Power Automate?

Last week, I was working on a Power Automate task where I needed to create a SharePoint Online Communication Site. Instead of creating it manually, I wanted to automate the process to save time and make it easier for future use.

In this tutorial, I will show you how to create a SharePoint Online Communication Site using Power Automate. Additionally, I will explain how to add members to the site and set a maximum storage limit.

Create a SharePoint Online Communication Site Using Power Automate

Before I tell you how to create, ensure you have SharePoint Administrator or Global Administrator permissions in your Microsoft 365 tenant. Without these permissions, you won’t be able to perform actions such as creating sites or modifying site settings through Power Automate.

For this example, I created a SharePoint list called Site Request. I want a Communication Site to be created automatically whenever an item is added to this list.

Power Automate Cteate sharepoint communication site

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.

Create a SharePoint Online Communication Site using Power Automate

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

  • Site Address: Provide the SharePoint tenant address
  • Method: Select method as Post from the drop-down
  • Uri:
/_api/SPSiteManager/create
  • Header: Use the below headers to make REST API calls to SharePoint:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
  • Body:  Provide the JSON format below to create a SharePoint communication site:
{
"request": {
"Title": "@{triggerBody()?['Title']}",
"Url": "https://tenante.sharepoint.com/sites/@{triggerBody()?['Alias']}",
"Description": "@{triggerBody()?['SiteDescription']}",
"Owner": "@{triggerBody()?['SiteOwner/Email']}",
"Lcid": 1033,
"WebTemplate": "SITEPAGEPUBLISHING#0",
"SiteDesignId": "@{guid()}",
"ShareByEmailEnabled": true

}
}

Where:

  • Title: The name of the new site.
  • Url: The web address of the site. It combines our SharePoint URL and a short name (alias).
  • Description: A short explanation of the purpose of the site.
  • Owner: The email of the person who will manage the site.
  • Lcid: The site’s language and region settings. 1033 means English (United States).
  • WebTemplate: The type of site being created. In this case, it’s a Communication Site.
  • SiteDesignId: A unique ID automatically generated to identify the site’s design.
  • ShareByEmailEnabled: A setting to allow sharing the site via email.
Powert Automate create sharepoint online communication site

Next, we need to set the storage limit for the SharePoint site. To do this, we need the Site URL and Group ID. We will use the Parse JSON action to extract these details from the earlier ‘Send an HTTP request to SharePoint’ output. After that, we’ll send another HTTP request to set the storage limit and storage warning limit for the SharePoint Online Communication Site.

3. Add a Parse JSON action and provide the below parameter:

  • Content: Select the body(Send an HTTP request to SharePoint action) from the dynamic content.
  • Schema: To add the schema, click on ‘Generate from sample’, paste the code below, and then click ‘Done’. The schema will now be generated and visible.
{
  "d": {
    "Create": {
      "__metadata": {
        "type": "Microsoft.SharePoint.Portal.SPSiteCreationResponse"
      },
      "SiteId": "ade47e06-2b50-461c-9c92-e82356de1a2",
      "SiteStatus": 2,
      "SiteUrl": "https://tenante.sharepoint.com/sites/demo"
    }
  }
}
how to create a site in sharepoint using power Automate

4. Add a Send an HTTP request to SharePoint action to set the storage limit, then provide the below parameter:

  • Site Address: Provide the SharePoint Admin Center Address.
  • Method: Select POST from the drop-down.
  • Uri:
_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/Sites('@{body('Parse_JSON')?['d']?['Create']?['SiteId']}')
  • Header: Use the below headers to make REST API calls to SharePoint:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
X-HTTP-Method: MERGE
  • Body:  Provide the JSON format below:
{
"StorageMaximumLevel": "@{triggerBody()?['StorageLimit']}",
"StorageWarningLevel": "@{triggerBody()?['StorageWarningLimit']}"
}
Create a SharePoint Online Communication Site in Power Automate

Next, we will add members to the SharePoint Communication Site. First, we will fetch the Group ID of the site. Using this ID, we can then add one or more members to the SharePoint site.

5. Add a Send an HTTP request to SharePoint action and provide below parameters:

  • Site Address: Provide site URL from Parse JSON.
  • Method: Select GET from the drop-down.
  • Uri:
_api/web?$select=AssociatedMemberGroup/Id&$expand=AssociatedMemberGroup
  • Header: Use the below headers to make REST API calls to SharePoint:
Accept: application/json;odata=nometadata
How to create a Communication site in SharePoint Online with rest api call in Microsoft Power Automate

6. Add a Parse JSON action and provide the below parameter:

  • Content: Select the body(Send an HTTP request to SharePoint 2 action) from the dynamic content.
  • Schema: To add the schema, click on ‘Generate from sample’, paste the code below, and then click ‘Done’. The schema will now be generated and visible.
{
  "AssociatedMemberGroup": {
    "Id": 5
  }
}
Create a SharePoint Online Communication Site Power Automate

7. Now we have group ID so we can add members to do this, add a Send an HTTP request to SharePoint action, and provide the below parameters:

  • Site Address: Provide site URL from Parse JSON.
  • Method: Select POST from the drop-down.
  • Uri:
/_api/web/sitegroups/getById(@{body('Parse_JSON_1')?['AssociatedMemberGroup']?['Id']})/users
  • Header: Use the below headers to make REST API calls to SharePoint:
Accept: application/json;odata=verbose
Content-Type: application/json;odata=verbose
  • Body:  Provide the JSON format below:
{
    "__metadata": {
        "type": "SP.User"
    },
    "LoginName": "i:0#.f|membership|@{item()?['Email']}"
}

It will automatically add a For Each loop because the Member column in my SharePoint site is set to allow multiple selections.

Create a Communication site in SharePoint using Power Automate

Run the Flow to Create a SharePoint Online Communication Site

Now click on Save and run the Flow manually. Once the flow runs, add an item to the SharePoint list.

Power Automate Create a SharePoint Online Communication Site

Once the flow runs successfully, go to the SharePoint Admin Center to check if the site was created. Also, the storage limit must be verified, and the members must be checked to see if they were added to the site.

How to Create a SharePoint Online Communication Site using Power Automate

Conclusion

In this tutorial, I explained how to automate the creation of a SharePoint Online Communication Site using Power Automate. We covered how to create the site, set storage limits, and add members to the site using REST API calls.

You may also like the following Power Automate tutorials:

>