Namespace: microsoft.graph
Create a new setting based on the templates available in groupSettingTemplates. These settings can be at the tenant-level or at the group level.
Group settings apply to only Microsoft 365 groups. The template named Group.Unified
can be used to configure tenant-wide Microsoft 365 group settings, while the template named Group.Unified.Guest
can be used to configure group-specific settings.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
✅ |
✅ |
✅ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
Directory.ReadWrite.All |
Not available. |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Directory.ReadWrite.All |
Not available. |
Important
In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation.
- Read basic properties on setting templates and settings - Microsoft Entra Joined Device Local Administrator, Directory Readers, Global Reader
- Manage all group/directory settings - Directory Writers
- Manage global and local settings for groups; manage
Group.Unified.Guest
and Group.Unified
settings - Groups Administrator
- Update
Password Rule Settings
- Authentication Policy Administrator
- Update settings, Read basic properties on setting templates and settings - User Administrator
HTTP request
Create a tenant-wide setting.
POST /groupSettings
Create a group-specific setting.
POST /groups/{id}/settings
Request body
In the request body, supply a JSON representation of groupSetting object. The display name, templateId, and description are inherited from the referenced groupSettingTemplates object. Only the value property can be changed from the default value.
The following properties are required when creating the groupSetting object.
Parameter |
Type |
Description |
templateId |
String |
Unique identifier for the tenant-level groupSettingTemplates object used to create this group-level settings object. Read-only. |
values |
settingValue collection |
Collection of name-value pairs corresponding to the name and defaultValue properties in the referenced groupSettingTemplates object. |
Response
If successful, this method returns 201 Created
response code and groupSetting object in the response body.
Example 1: Create a new setting for all Microsoft 365 groups in the tenant
Request
Only the groupSettingTemplates object named Group.Unified
can be applied to all Microsoft 365 groups at the tenant-level.
POST https://graph.microsoft.com/v1.0/groupSettings
Content-type: application/json
{
"templateId": "62375ab9-6b52-47ed-826b-58e47e0e304b",
"values": [
{
"name": "GuestUsageGuidelinesUrl",
"value": "https://privacy.contoso.com/privacystatement"
},
{
"name": "EnableMSStandardBlockedWords",
"value": "true"
},
{
"name": "EnableMIPLabels",
"value": "true"
},
{
"name": "PrefixSuffixNamingRequirement",
"value": "[Contoso-][GroupName]"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new GroupSetting
{
TemplateId = "62375ab9-6b52-47ed-826b-58e47e0e304b",
Values = new List<SettingValue>
{
new SettingValue
{
Name = "GuestUsageGuidelinesUrl",
Value = "https://privacy.contoso.com/privacystatement",
},
new SettingValue
{
Name = "EnableMSStandardBlockedWords",
Value = "true",
},
new SettingValue
{
Name = "EnableMIPLabels",
Value = "true",
},
new SettingValue
{
Name = "PrefixSuffixNamingRequirement",
Value = "[Contoso-][GroupName]",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.GroupSettings.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc group-settings create --body '{\
"templateId": "62375ab9-6b52-47ed-826b-58e47e0e304b",\
"values": [\
{\
"name": "GuestUsageGuidelinesUrl",\
"value": "https://privacy.contoso.com/privacystatement"\
},\
{\
"name": "EnableMSStandardBlockedWords",\
"value": "true"\
},\
{\
"name": "EnableMIPLabels",\
"value": "true"\
},\
{\
"name": "PrefixSuffixNamingRequirement",\
"value": "[Contoso-][GroupName]"\
}\
]\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewGroupSetting()
templateId := "62375ab9-6b52-47ed-826b-58e47e0e304b"
requestBody.SetTemplateId(&templateId)
settingValue := graphmodels.NewSettingValue()
name := "GuestUsageGuidelinesUrl"
settingValue.SetName(&name)
value := "https://privacy.contoso.com/privacystatement"
settingValue.SetValue(&value)
settingValue1 := graphmodels.NewSettingValue()
name := "EnableMSStandardBlockedWords"
settingValue1.SetName(&name)
value := "true"
settingValue1.SetValue(&value)
settingValue2 := graphmodels.NewSettingValue()
name := "EnableMIPLabels"
settingValue2.SetName(&name)
value := "true"
settingValue2.SetValue(&value)
settingValue3 := graphmodels.NewSettingValue()
name := "PrefixSuffixNamingRequirement"
settingValue3.SetName(&name)
value := "[Contoso-][GroupName]"
settingValue3.SetValue(&value)
values := []graphmodels.SettingValueable {
settingValue,
settingValue1,
settingValue2,
settingValue3,
}
requestBody.SetValues(values)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
groupSettings, err := graphClient.GroupSettings().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupSetting groupSetting = new GroupSetting();
groupSetting.setTemplateId("62375ab9-6b52-47ed-826b-58e47e0e304b");
LinkedList<SettingValue> values = new LinkedList<SettingValue>();
SettingValue settingValue = new SettingValue();
settingValue.setName("GuestUsageGuidelinesUrl");
settingValue.setValue("https://privacy.contoso.com/privacystatement");
values.add(settingValue);
SettingValue settingValue1 = new SettingValue();
settingValue1.setName("EnableMSStandardBlockedWords");
settingValue1.setValue("true");
values.add(settingValue1);
SettingValue settingValue2 = new SettingValue();
settingValue2.setName("EnableMIPLabels");
settingValue2.setValue("true");
values.add(settingValue2);
SettingValue settingValue3 = new SettingValue();
settingValue3.setName("PrefixSuffixNamingRequirement");
settingValue3.setValue("[Contoso-][GroupName]");
values.add(settingValue3);
groupSetting.setValues(values);
GroupSetting result = graphClient.groupSettings().post(groupSetting);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const groupSetting = {
templateId: '62375ab9-6b52-47ed-826b-58e47e0e304b',
values: [
{
name: 'GuestUsageGuidelinesUrl',
value: 'https://privacy.contoso.com/privacystatement'
},
{
name: 'EnableMSStandardBlockedWords',
value: 'true'
},
{
name: 'EnableMIPLabels',
value: 'true'
},
{
name: 'PrefixSuffixNamingRequirement',
value: '[Contoso-][GroupName]'
}
]
};
await client.api('/groupSettings')
.post(groupSetting);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\GroupSetting;
use Microsoft\Graph\Generated\Models\SettingValue;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new GroupSetting();
$requestBody->setTemplateId('62375ab9-6b52-47ed-826b-58e47e0e304b');
$valuesSettingValue1 = new SettingValue();
$valuesSettingValue1->setName('GuestUsageGuidelinesUrl');
$valuesSettingValue1->setValue('https://privacy.contoso.com/privacystatement');
$valuesArray []= $valuesSettingValue1;
$valuesSettingValue2 = new SettingValue();
$valuesSettingValue2->setName('EnableMSStandardBlockedWords');
$valuesSettingValue2->setValue('true');
$valuesArray []= $valuesSettingValue2;
$valuesSettingValue3 = new SettingValue();
$valuesSettingValue3->setName('EnableMIPLabels');
$valuesSettingValue3->setValue('true');
$valuesArray []= $valuesSettingValue3;
$valuesSettingValue4 = new SettingValue();
$valuesSettingValue4->setName('PrefixSuffixNamingRequirement');
$valuesSettingValue4->setValue('[Contoso-][GroupName]');
$valuesArray []= $valuesSettingValue4;
$requestBody->setValues($valuesArray);
$result = $graphServiceClient->groupSettings()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.group_setting import GroupSetting
from msgraph.generated.models.setting_value import SettingValue
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = GroupSetting(
template_id = "62375ab9-6b52-47ed-826b-58e47e0e304b",
values = [
SettingValue(
name = "GuestUsageGuidelinesUrl",
value = "https://privacy.contoso.com/privacystatement",
),
SettingValue(
name = "EnableMSStandardBlockedWords",
value = "true",
),
SettingValue(
name = "EnableMIPLabels",
value = "true",
),
SettingValue(
name = "PrefixSuffixNamingRequirement",
value = "[Contoso-][GroupName]",
),
],
)
result = await graph_client.group_settings.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
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/v1.0/$metadata#groupSettings/$entity",
"id": "844d252c-4de2-43eb-a784-96df77231aae",
"displayName": null,
"templateId": "62375ab9-6b52-47ed-826b-58e47e0e304b",
"values": [
{
"name": "GuestUsageGuidelinesUrl",
"value": "https://privacy.contoso.com/privacystatement"
},
{
"name": "EnableMSStandardBlockedWords",
"value": "true"
},
{
"name": "EnableMIPLabels",
"value": "true"
},
{
"name": "PrefixSuffixNamingRequirement",
"value": "[Contoso-][GroupName]"
}
]
}
The displayName property and other name-value pairs will be populated with the default values from the groupSettingTemplates object that matches the templateId.
Example 2: Create a setting to block guests for a specific Microsoft 365 group
Request
Only the groupSettingTemplates object named Group.Unified.Guest
can be applied to specific Microsoft 365 groups.
POST https://graph.microsoft.com/v1.0/groups/055a5d18-a3a9-4338-b9c5-de92559b7ebf/settings
Content-type: application/json
{
"templateId": "08d542b9-071f-4e16-94b0-74abb372e3d9",
"values": [
{
"name": "AllowToAddGuests",
"value": "false"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new GroupSetting
{
TemplateId = "08d542b9-071f-4e16-94b0-74abb372e3d9",
Values = new List<SettingValue>
{
new SettingValue
{
Name = "AllowToAddGuests",
Value = "false",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].Settings.PostAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
mgc groups settings create --group-id {group-id} --body '{\
"templateId": "08d542b9-071f-4e16-94b0-74abb372e3d9",\
"values": [\
{\
"name": "AllowToAddGuests",\
"value": "false"\
}\
]\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewGroupSetting()
templateId := "08d542b9-071f-4e16-94b0-74abb372e3d9"
requestBody.SetTemplateId(&templateId)
settingValue := graphmodels.NewSettingValue()
name := "AllowToAddGuests"
settingValue.SetName(&name)
value := "false"
settingValue.SetValue(&value)
values := []graphmodels.SettingValueable {
settingValue,
}
requestBody.SetValues(values)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
settings, err := graphClient.Groups().ByGroupId("group-id").Settings().Post(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupSetting groupSetting = new GroupSetting();
groupSetting.setTemplateId("08d542b9-071f-4e16-94b0-74abb372e3d9");
LinkedList<SettingValue> values = new LinkedList<SettingValue>();
SettingValue settingValue = new SettingValue();
settingValue.setName("AllowToAddGuests");
settingValue.setValue("false");
values.add(settingValue);
groupSetting.setValues(values);
GroupSetting result = graphClient.groups().byGroupId("{group-id}").settings().post(groupSetting);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
const options = {
authProvider,
};
const client = Client.init(options);
const groupSetting = {
templateId: '08d542b9-071f-4e16-94b0-74abb372e3d9',
values: [
{
name: 'AllowToAddGuests',
value: 'false'
}
]
};
await client.api('/groups/055a5d18-a3a9-4338-b9c5-de92559b7ebf/settings')
.post(groupSetting);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\GroupSetting;
use Microsoft\Graph\Generated\Models\SettingValue;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new GroupSetting();
$requestBody->setTemplateId('08d542b9-071f-4e16-94b0-74abb372e3d9');
$valuesSettingValue1 = new SettingValue();
$valuesSettingValue1->setName('AllowToAddGuests');
$valuesSettingValue1->setValue('false');
$valuesArray []= $valuesSettingValue1;
$requestBody->setValues($valuesArray);
$result = $graphServiceClient->groups()->byGroupId('group-id')->settings()->post($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
Import-Module Microsoft.Graph.Groups
$params = @{
templateId = "08d542b9-071f-4e16-94b0-74abb372e3d9"
values = @(
@{
name = "AllowToAddGuests"
value = "false"
}
)
}
New-MgGroupSetting -GroupId $groupId -BodyParameter $params
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.group_setting import GroupSetting
from msgraph.generated.models.setting_value import SettingValue
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = GroupSetting(
template_id = "08d542b9-071f-4e16-94b0-74abb372e3d9",
values = [
SettingValue(
name = "AllowToAddGuests",
value = "false",
),
],
)
result = await graph_client.groups.by_group_id('group-id').settings.post(request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation.
In the request body, supply a JSON representation of groupSetting object.
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/v1.0/$metadata#groupSettings/$entity",
"id": "a06fa228-3042-4662-bd09-33e298da1afe",
"displayName": null,
"templateId": "08d542b9-071f-4e16-94b0-74abb372e3d9",
"values": [
{
"name": "AllowToAddGuests",
"value": "false"
}
]
}