In this post I will share you the steps to add user/users to SharePoint (online) group using REST API.

Prerequisites
You need the below to follow the tutorial/steps
- To call REST API I have used Power Automate. You can use Postman or VS code or anything else as per your choice.
- SharePoint Online Management Shell for SPO PowerShell
Implementation
To add a user in SharePoint you need to send a HTTP POST request to the SharePoint user collection library. The request looks as below

As you can see in the above screenshot we are sending a POST request with user login details in the body. For SharePoint online the login name should be in the below format.
LoginName > i:0#.f|membership|user@email.com
However it depends upon your organization settings, so make sure you are providing the correct LoginName parameter value.
Rest of the details are explained below
Request Parameters
Site Address : The SharePoint site URL where you want to add the user using the REST API call
Method : As this is a item creation request, POST is used.
Uri: The endpoint for adding the user to SharePoint.
For this example I have used _api/web/sitegroups(<group id>)/users , this is helpful to add user to any particular group. However if you wish to add user directly and not through any group then you can use the following endpoint as well; _api/web/siteusers
Headers: Just to provide more information about the request body. However if you are using any other application to call the REST end point then you need to pass authentication information as well.
Body:
{
'__metadata': { 'type': 'SP.User' },
'LoginName': 'i:0#.f|membership|user@email.com'
}
That’s all for the request, if you call the API successfully then the users will add in the SharePoint site group as expected.

Well that’s all I have on how add users to SharePoint using REST API. I hope you now have some idea on how to proceed. However if you want to learn more, check this Microsoft document
Please Help us Grow!
I hope you have found this article helpful. If you are happy with the document, please use the below links when you buy something from Amazon to help us grow.
Ways to Help
Amazon Affiliate Links
How this works?
Amazon affiliate program gives a small (%)share of price to the referrers, so feel free to buy anything.
Below are some Amazon affiliate links, if you open amazon application/website using these links and buy something, (it can be one of the below items or anything of your choice) Then Amazon will give us a little percentage(%) of the money you spend on Amazon. To know more check this document.
Thank you
For your Contribution
Newbietechie.com
Author @ramizmollahmd
About Ramiz
Ramiz is a professional working in an MNC as a business and technology consultant for quite a few years now. Ramiz is proficient in various Microsoft tools and technologies. He is a tech enthusiast and an active blogger. Ramiz spends his free time playing games or watching movies. He writes blogs to share his knowledge with the world and to make it a better place to live.