Create Team from Group with Graph

Microsoft Graph is the gateway to data and intelligence in Microsoft 365.

If you are curious like me, well, in this post I’ll focus on creating a Microsoft Team from MSGroup (Microsoft 365 Group, Security group), you can create the previous types of groups.

The following permissions is required to call this API.

Permission typePermissions (from least to most privileged)
Delegated (work or school account)Group.ReadWrite.All, Directory.ReadWrite.All, Directory.AccessAsUser.All
ApplicationGroup.Create, Group.ReadWrite.All, Directory.ReadWrite.All

  1. Select the permissions from Microsoft Graph,

2. Now, go to create the Group, copy the next JSON format to create the Microsoft 365 Group into the “Request body” in Microsoft Graph, and use the next Request.

POST https://graph.microsoft.com/v1.0/groups
{
  "description": "Description of the group",
  "displayName": "Name of the Group",
  "groupTypes": [
    "Unified"
  ],
  "mailEnabled": true,
  "mailNickname": "library",
  "securityEnabled": false
}

Look at the property “groupTypes” this one define the type of the group, this is are the options available when you create a group:

Type of groupAssigned membershipDynamic membership
Microsoft 365 (aka unified group)[“Unified”][“Unified”,”DynamicMembership”]
Dynamic[] (null)[“DynamicMembership”]

The group it looks like this in the M365 Admin Center

3. It’s time to convert this group to MSTeams, with the previous response from create the group, copy the ID Group and use the next Request and JSON format to convert the group, remove the curly brackets {id}

PUT https://graph.microsoft.com/v1.0/groups/{id}/team
{  
  "memberSettings": {
    "allowCreatePrivateChannels": true,
    "allowCreateUpdateChannels": true
  },
  "messagingSettings": {
    "allowUserEditMessages": true,
    "allowUserDeleteMessages": true
  },
  "funSettings": {
    "allowGiphy": true,
    "giphyContentRating": "strict"
  }
}

Your MSTeams is ready to use…

Reference:

“Sharing is caring”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.