Skip to main content

How to Remove a Group's Permissions from a SharePoint List with the REST API in Power Automate

· 9 min read
Jagdish Kumawat
Founder @ Dewiride

Once a SharePoint list has its own permissions, a flow can take a group's access away with one REST request: a DELETE of the group's role assignment on the list. Reading the group's ID and checking the list first means the flow removes only what's there.

Syntax​

All three requests go through Send an HTTP request to SharePoint (How to Use Send an HTTP Request to SharePoint), with the header Accept: application/json;odata=nometadata. A group's access to a list is a role assignment, found by the group's ID, its principal ID.

Read the group's ID​

FieldValue
MethodGET
Uri_api/web/<group>?$select=Id,Title
  • <group>: associatedmembergroup, associatedvisitorgroup or associatedownergroup for the site's own Members, Visitors or Owners group. Microsoft's Webs REST API reference lists them as the site's associated groups. For any other group, use sitegroups/getbyname('<group name>').

Check that the group has access​

FieldValue
MethodGET
Uri_api/web/lists/getbytitle('<list name>')/roleassignments?$filter=PrincipalId eq <group ID>&$select=PrincipalId

The answer's value array has one entry when the group has access to the list, and is empty when it hasn't.

Remove it​

FieldValue
MethodPOST
Uri_api/web/lists/getbytitle('<list name>')/roleassignments/getbyprincipalid(<group ID>)
HeadersX-HTTP-Method: DELETE, as well as Accept
  • <list name>: the list's title, as in Site contents.
  • <group ID>: the Id from the first request.

The request has no body. The X-HTTP-Method header turns the POST into a delete, as in Microsoft's Set custom permissions on a list by using the REST interface, which deletes a role assignment with getbyprincipalid the same way.

The Example​

A list called Suggestions, on the root site contoso.sharepoint.com, already has its own permissions, copied from the site (How to Stop Inheriting Permissions on a SharePoint List with the REST API in Power Automate). The site's Members group, Communication site Members, should no longer see it. The flow, Remove a Group from a List, has five parts:

  1. Manually trigger a flow (How to Create an Instant Cloud Flow Inside a Solution in Power Automate).
  2. Get the Members group, the first GET.
  3. Find the group on the list, the second GET.
  4. If the group has access, a condition.
  5. Remove the group, the DELETE, in the condition's True branch.

Prerequisites​

  • Full Control of the site for the account the flow's SharePoint connection uses. Changing a list's permissions needs the Manage Permissions permission, which only Full Control includes by default.
  • The list has its own permissions. A list that still inherits its site's permissions has to stop inheriting first.

Step 1: Read the Group's ID​

Add Send an HTTP request to SharePoint and rename it Get the Members group:

FieldValue
Site AddressYour site
MethodGET
Uri_api/web/associatedmembergroup?$select=Id,Title
HeadersAccept: application/json;odata=nometadata

The Get the Members group action with Site Address Communication site, Method GET, the Uri _api/web/associatedmembergroup?$select=Id,Title and the Accept header application/json;odata=nometadata

Step 2: Check the List​

Add Find the group on the list. Type the Uri up to eq , then add this expression where the group's ID goes (How to Add an Expression in Power Automate), and type the rest:

The group's ID
body('Get_the_Members_group')?['Id']
FieldValue
Site AddressYour site
MethodGET
Uri_api/web/lists/getbytitle('Suggestions')/roleassignments?$filter=PrincipalId eq Id &$select=PrincipalId
HeadersAccept: application/json;odata=nometadata

The designer shows the expression as an Id token:

The Find the group on the list action with the Uri _api/web/lists/getbytitle('Suggestions')/roleassignments?$filter=PrincipalId eq, an Id token from Get the Members group, and &$select=PrincipalId

Then add a Condition called If the group has access (How to Add a Condition in Power Automate). On the left, add this expression; choose is equal to; on the right, add the expression false:

If the group has access → left value
empty(body('Find_the_group_on_the_list')?['value'])

empty() is true when the value array has nothing in it, so the condition is true when the group does have access. In expressions, an action is named with underscores for its spaces.

Step 3: Remove the Group​

In the True branch, add Remove the group, with the same Id expression inside getbyprincipalid( ):

FieldValue
Site AddressYour site
MethodPOST
Uri_api/web/lists/getbytitle('Suggestions')/roleassignments/getbyprincipalid( Id )
HeadersAccept: application/json;odata=nometadata
X-HTTP-Method: DELETE

The Remove the group action with Method POST, the Uri _api/web/lists/getbytitle('Suggestions')/roleassignments/getbyprincipalid( with an Id token and a closing bracket, and the headers Accept and X-HTTP-Method DELETE

Step 4: Run the Flow​

Save the flow and test it manually (How to Test a Cloud Flow Manually in Power Automate). The group had access, so Remove the group ran:

The run of Remove a Group from a List with green ticks on Manually trigger a flow, Get the Members group, Find the group on the list, If the group has access and, in its True branch, Remove the group

The body of Get the Members group in the run shows the ID the other two requests used:

The body of Get the Members group in the run, with Id 5 and Title Communication site Members

The Result​

The list's permissions page, List settings > Permissions for this list, no longer lists Communication site Members. The Owners and Visitors groups are still there:

The Suggestions permissions page with the banner This list has unique permissions, listing only Communication site Owners with Full Control and Communication site Visitors with Read

The group itself is untouched: it keeps its members and its access to the rest of the site.

Common Mistakes​

MistakeWhat happensDo this instead
Typing the group's ID by handThe number belongs to one site's groupRead it from the site in the same flow
Leaving out X-HTTP-Method: DELETENothing in the request asks SharePoint to deleteAdd the header
Removing from a list that still inheritsMicrosoft's guide stops inheritance before adding or removing role assignmentsStop inheriting first
Removing the Owners group by mistakeThe site's owners lose the access that group gave them to the listCheck the group's Title before you remove it

Troubleshooting​

SymptomLikely causeFix
The condition is falseThe group has no access to the listCheck the list's permissions page
An access-denied errorThe connection's account can't manage permissionsUse an account with Full Control
The wrong group was removedThe first request read another groupCheck its Title in the run

FAQ​

Does this take the group's members out of the group?​

No. It removes the group's access to the one list. The group and its members stay as they are.

How do I remove a group that isn't one of the site's three?​

Read its ID with _api/web/sitegroups/getbyname('<group name>')?$select=Id, and use that ID the same way.

Can I do this without a flow?​

Yes, with Remove User Permissions on the list's permissions page: How to Remove a Group's Permissions from a SharePoint List.

Conclusion​

Read the group's Id, check …/roleassignments?$filter=PrincipalId eq <group ID>, and when the group has access, POST to …/roleassignments/getbyprincipalid(<group ID>) with X-HTTP-Method: DELETE. The group loses access to that list and nothing else.

Additional Resources​