Create a SharePoint Site Using Power Apps & Power Automate [Via Rest API]

As we know, we can create a SharePoint Team site or a Communication site directly using the SharePoint Admin Center. However, to save time and effort, there is a good option that allows us to use the Power Apps form and create a team or communication site with a single button click.

In this tutorial, I will explain how to create a SharePoint site using Power Apps & Power Automate via Rest API step by step.

NOTE:

For the Advanced app (Create SharePoint Site), you can download this complete solution package using this button below:

Create a SharePoint Site Using Power Apps & Power Automate

In the GIF below, you can see the Power Apps controls where the user can enter details (Title, Description, URL, etc.). Once they click the Create Site button, a specific SharePoint site will be created automatically in a new tab.

Create a SharePoint Site Using Power Apps & Power Automate

Set up Power Apps

First, we need to set up or add the individual Power Apps fields below to display as a form. Refer to the table below: (Here I have used all the Modern controls)

NameType
TitleText input
DescriptionText input
Site URLText input
TemplateDropdown (Team Site, Communication Site)
OwnerCombo box (Returns all the person names from Office 365)
Formula: Office365Users.SearchUser({searchTerm:cmb_Owner.SearchText}).Mail
Create SiteButton

NOTE:

You can add another field called Site Design that should be a Dropdown/Combo box control. If you have any custom site designs, use their identifiers (GUIDs) here.

Create SharePoint Site Using Power Apps

Integrate Power Automate in Power Apps

Once the Power Apps fields are ready, we will proceed to build a Power Automate flow to create the SharePoint site. For this, we will create and set up the flow on the Power Apps Button’s (Create Site) OnSelect property.

Let’s follow the steps below:

1. Select the button and go to More option () from the left nav -> Select Power Automate.

Create Modern SharePoint Site Using Power Apps
  1. Click + Add flow -> + Create new flow.
Create Modern SharePoint Site Power Apps
  1. On the next page, click on + Create from blank.
Create Modern SharePoint Site PowerApps
  1. Initially, rename this flow without leaving any spaces (for example, CreateSites) and then click Save. Here, the Power Apps V2 action will be added automatically to get the values submitted from the Power Apps form. After that, we need to pass those values to the Send an HTTP request to SharePoint action.
create sharepoint site using power apps form
  1. When a user interacts with your Power Apps form (for example, by clicking a button), you need to send the relevant form field values to the flow. For example, if you’re creating a site, you might pass details such as the site title, description, owner, and other related information.

As I have a total of 5 fields in the Power Apps form, I added 4 Text inputs and 1 Email input for the Site Owner. Refer to the image below:

create sharepoint site using Power Apps Power Automate
  1. Next, add an Initialize variable action and provide the values below:
  • Name: Provide a variable name (for example, varNames).
  • Type: Select String.
Create SharePoint Team site using Power Apps
  1. Insert: ‘Send an HTTP request to SharePoint‘ action and provide all the values below:
FieldValue
Site AddressProvide a SharePoint site to connect.
MethodPOST
Uri/_api/SPSiteManager/create
HeadersKey:
Accept
Value: application/json;odata.metadata=none
BodyHere, we need to add all the body parameters—such as Title, URL, LCID, Description, Web template, etc.
We need to retrieve all these values from Power Apps. Add these from the Dynamic Content tab under the Manual section.

Reference: https://learn.microsoft.com/en-us/sharepoint/dev/apis/site-creation-rest#create-a-modern-site
Create SharePoint Site Power Apps
  1. Finally, add a ‘Respond to a Power App or flow‘ action and a ‘Text input‘.
  • varOutput: Provide a text name.
  • Body: Select Body from the Dynamic content under Send an HTTP request in SharePoint.
Create SharePoint Communication Site Using Power Apps
  1. Once everything is done, click Save and then return to Power Apps.
Create SharePoint Site Using Power Automate

Now, you can see the specific flow has been added in Power Apps, as shown below.

How to Create SharePoint Site Using Power Apps
  1. Next, select the Create Site button and apply the code below to its OnSelect property:
CreateSites.Run(
    txt_Title.Value,
    "https://szg52.sharepoint.com/sites/" & txt_SiteURL.Value,
    txt_Description.Value,
    If(
        dd_Template.Selected.Value = "Team Site",
        "STS#3",
        "SITEPAGEPUBLISHING#0"
    ),
    cmb_Owner.Selected.Mail
);
Notify(
    "Site has been created successfully",
    NotificationType.Success
);
Launch("https://szg52.sharepoint.com/sites/" & txt_SiteURL.Value);
Reset(txt_Title);
Reset(txt_Description);
Reset(txt_SiteURL);
Reset(dd_Template);
Reset(cmb_Owner);

Where,

  • CreateSites.Run = Flow name that we have created
  • txt_Title, txt_SiteURL, txt_Description = Text input controls
  • “https://szg52.sharepoint.com/sites/” = Specify the tenant name, including ‘/sites’
  • dd_Template = Dropdown control
  • cmb_Owner = Combo box control

The above code specifies that if the user has selected the template as Team Site, then it will create a SharePoint team site (STS#3), else it will create a Communication site (SITEPAGEPUBLISHING#0) including the specified Site owner.

Additionally, they will receive notification, and the newly created site will open in a new tab. After all, we will reset all the controls once the site is created.

Create SharePoint Site Using Power Apps and Power Automate
  1. Save, publish, and preview the app once. Provide Title, Description, Site URL, Owner, and choose the Template (either Team Site or Communication Site). Click on Create Site. The new SharePoint site will be created and opened in a new tab as shown below.
Create a SharePoint Site Using Power Apps & Power Automate

I hope this tutorial helped you learn how to create a SharePoint Team site or Communication site using Power Apps and Power Automate.

Also, you may like some more Power Apps and Power Automate articles:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

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