Add a member
Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Use this API to add a member (user, group, or device) to an administrative unit or to create a new group within an administrative unit. All group types can be created within an administrative unit.
Note: Currently, it's only possible to add one member at a time to an administrative unit.`
This API is available in the following national cloud deployments.
Global service | US Government L4 | US Government L5 (DOD) | China operated by 21Vianet |
---|---|---|---|
✅ | ✅ | ✅ | ✅ |
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
Permissions to add an existing user, group, or device
Permission type | Permissions (from least to most privileged) |
---|---|
Delegated (work or school account) | AdministrativeUnit.ReadWrite.All |
Delegated (personal Microsoft account) | Not supported. |
Application | AdministrativeUnit.ReadWrite.All |
Important
In delegated scenarios with work or school accounts, the signed-in user must be a member user or be assigned a supported Microsoft Entra role or a custom role with a supported role permission. Privileged Role Administrator is the least privileged role supported for this operation.
Permissions to create a new group
Permission type | Permissions (from least to most privileged) |
---|---|
Delegated (work or school account) | Group.ReadWrite.All and AdministrativeUnit.Read.All, Directory.ReadWrite.All |
Delegated (personal Microsoft account) | Not supported. |
Application | Group.Create and AdministrativeUnit.Read.All, Group.ReadWrite.All and AdministrativeUnit.Read.All, Directory.ReadWrite.All |
Important
To create a new group in an administrative unit, the calling principal must be assigned at least one of the following Microsoft Entra roles at the scope of the administrative unit:
- Groups Administrator
- User Administrator
For app-only scenarios - apart from these roles, the service principal requires additional permissions to read the directory. These permissions can be granted via assignment of supported Microsoft Entra roles, such the Directory Readers role; or they can be granted via Microsoft Graph application permissions that allow reading the directory, such as Directory.Read.All.
HTTP request
The following request adds an existing user, group, or device to the administrative unit.
POST /administrativeUnits/{id}/members/$ref
The following request creates a new group within the administrative unit.
POST /administrativeUnits/{id}/members
Request headers
Name | Description |
---|---|
Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
Content-type | application/json. Required. |
Adding an existing user or group
In the request body, provide the id
of a user, group, device, or directoryObject to be added. If the administrative unit is a restricted management administrative unit (isMemberManagementRestricted
=true), the group type must be a Microsoft Entra security group. Only non-unified groups that are security enabled, not mail enabled, and not on-premises sync enabled are supported.
Creating a new group
The following table shows the properties of the group resource to specify when you create a group in the administrative unit.
Property | Type | Description |
---|---|---|
displayName | string | The name to display in the address book for the group. Required. |
description | string | A description for the group. Optional. |
isAssignableToRole | Boolean | Set to true to enable the group to be assigned to a Microsoft Entra role. Privileged Role Administrator is the least privileged role to set the value of this property. Optional. |
mailEnabled | Boolean | Set to true for mail-enabled groups. Required. |
mailNickname | string | The mail alias for the group. These characters cannot be used in the mailNickName: @()\[]";:.<>,SPACE . Required. |
securityEnabled | Boolean | Set to true for security-enabled groups, including Microsoft 365 groups. Required. |
owners | directoryObject collection | This property represents the owners for the group at creation time. Optional. |
members | directoryObject collection | This property represents the members for the group at creation time. Optional. |
visibility | String | Specifies the visibility of a Microsoft 365 group. Possible values are: Private , Public , HiddenMembership , or empty (which is interpreted as Public ). |
Response
If successful, adding an existing object (using $ref
) returns 204 No Content
response code. It doesn't return anything in the response body.
When creating a new group (without $ref
), this method returns a 201 Created
response code and a group object in the response body. The response includes only the default properties of the group. You must supply the "@odata.type" : "#microsoft.graph.group"
line in the request body to explicitly identify the new member as a group. A request body without the correct @odata.type returns a 400 Bad Request
error message.
Examples
Example 1: Add an existing user or group
The following will add an existing user or group to the administrative unit.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/administrativeUnits/{id}/members/$ref
Content-type: application/json
{
"@odata.id":"https://graph.microsoft.com/beta/groups/{id}"
}
In the request body, provide the id
of the user, group, or device object you want to add.
Response
The following example shows the response.
HTTP/1.1 204 No Content
Example 2: Create a new group
The following example creates a new group in the administrative unit. You must supply the "@odata.type" : "#microsoft.graph.group"
line in the request body to explicitly identify the new member as a group. A request body without the correct @odata.type returns a 400 Bad Request
error message.
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/administrativeUnits/{id}/members
Content-type: application/json
{
"@odata.type": "#microsoft.graph.group",
"description": "Self help community for golf",
"displayName": "Golf Assist",
"groupTypes": [
"Unified"
],
"mailEnabled": true,
"mailNickname": "golfassist",
"securityEnabled": false
}
In the request body, provide the properties of the group object you want to add.
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups/$entity",
"id": "45b7d2e7-b882-4a80-ba97-10b7a63b8fa4",
"deletedDateTime": null,
"classification": null,
"createdDateTime": "2018-12-22T02:21:05Z",
"description": "Self help community for golf",
"displayName": "Golf Assist",
"expirationDateTime": null,
"groupTypes": [
"Unified"
],
"isAssignableToRole": null,
"mail": "[email protected]",
"mailEnabled": true,
"mailNickname": "golfassist",
"membershipRule": null,
"membershipRuleProcessingState": null,
"onPremisesLastSyncDateTime": null,
"onPremisesSecurityIdentifier": null,
"onPremisesSyncEnabled": null,
"preferredDataLocation": "CAN",
"preferredLanguage": null,
"proxyAddresses": [
"SMTP:[email protected]"
],
"renewedDateTime": "2018-12-22T02:21:05Z",
"resourceBehaviorOptions": [],
"resourceProvisioningOptions": [],
"securityEnabled": false,
"securityIdentifier": "S-1-12-1-1753967289-1089268234-832641959-555555555",
"theme": null,
"visibility": "Public",
"onPremisesProvisioningErrors": []
}