Add SharePoint Site Owners using REST API in Power Automate

Sometimes, when working with SharePoint sites for a client, you may want complete control over everything on that site, including all subsites, libraries, lists, and settings. In this case, you require Site Owner permission on the SharePoint Online site.

In this tutorial, I will show you not only how to add one user, but also how to add multiple users as site owners in a SharePoint site using Power Automate.

Add Site Owner in SharePoint Online Using REST API

Here, we are using the Send an HTTP Request to SharePoint action and the SharePoint REST API site owner permissions for a user.

For this example, I have created a team site with a connected Microsoft 365 group called HR Internal, where I want to add Miriam Graham as a Site owner.

However, you can follow the same steps to add a Site owner to a communication site, a team site (without a connected Microsoft 365 group), or a team site with a connected Microsoft 365 group (Team Connected Site).

Below are the steps to add a Site owner in a SharePoint site using the REST API:

  1. Go to the Power Automate site and create a new Instant cloud flow with Manually trigger a flow trigger.
  2. Add a Send an HTTP Request to SharePoint action and provide the below parameters:
    • Site Address: Select the SharePoint Site Address.
    • Method: Select POST as the method.
    • Uri: Provide the below URI:
_api/web/siteGroups/GetById(3)/users
  • _api/web – This is saying we’re working with the current SharePoint site (web).
  • siteGroups – We’re looking at the groups in the site.
  • GetById(3) – We want the group that has the ID 3.
  • /users – From that group, we want to get the users (members).
OwnerMemberVisitors
354
  1. Click on the Show all button to display all the Advanced parameters.
    • Headers: Click on the Switch to text mode button to the icon to input the json. Copy and paste the code below in the Headers section.
{
  "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose"
}
  1. Body:
{
    "__metadata": {
        "type": "SP.User"
    },
    "LoginName": "i:0#.f|membership|MiriamG@<tanant name>.onmicrosoft.com"
}
Create Sharepoint Site via REST API with multiple owners in Power Automate
  1. Then, save the flow and run it manually. Once the flow runs, you can see that the specified user will be added as a Site owner to your SharePoint site.
Add Site Owner in SharePoint Online Using REST API

Here, I manually add the user, but you can add the user dynamically using dynamic content.

Add Multiple Users to a Site Owner Using the REST API

Now I will create the same instant cloud flow, but this time we will dynamically add Multiple users to it. Follow the steps below:

  1. Open the Power Automate Home page and choose Instant cloud flow with trigger Manually trigger a flow.
  2. Then, click ‘ Manually trigger a flow’ and add an email parameter.
Add Multiple Users to a Site Owner Using the REST API
  1. Then, add a Compose action and use the following expression to split the string using a semicolon, converting it into an array. This is useful when multiple users are added, as they are returned in a single string.
split(triggerBody()?['email'],';')
  1. Add Apply to each loop flow action, which will loop through all the users one by one.
    • Select an output from previous steps: Take the Outputs of a compose action.
Add Multiple Users To SharePoint Group Using Power Automate
  1. Add a Send an HTTP Request to SharePoint action and provide the below parameters:
    • Site Address: Select the SharePoint Site Address.
    • Method: Select POST as the method.
    • Uri: Provide the below URI:
_api/web/siteGroups/GetById(3)/users
  1. Headers: Click on the Switch to text mode button to the icon to input the json. Copy and paste the code below in the Headers section.
{
  "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose"
}
  1. Body:
{
    "__metadata": {
        "type": "SP.User"
    },
    "LoginName": "i:0#.f|membership|items('Apply_to_each')"
}
Add User to SharePoint Group using Power Automate
  1. Then, save the flow and run it manually. After that, it will ask you for the user names. In my case, I added two users (Henrietta Mueller and Isaiah Langer). Click on the Run flow button to proceed.
Add Users to SharePoint Group From a SharePoint List Using Power Automate
  1. Once the flow runs successfully, navigate to the site address, and you will see that multiple users have been added to the Site Owner group.
Power Automate Add Multiple Users to a Site Owner Using the REST API

This way, you can add multiple users as Site Owners using the REST API in Power Automate.

If you want to add users dynamically but only one user at a time, do not include Steps 3 and 4.

You may also like:

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