Create a SharePoint Team Site via Microsoft Graph

Prev Next

Provision a new Microsoft 365 Group-backed SharePoint Team Site with a designated owner, using the Graph API, SharePoint admin center, or PowerShell.

Complexity: Intermediate. Impact: Collaboration + Provisioning + SharePoint + Microsoft 365 Groups.

Why use this workflow

SharePoint Team Sites are the foundation of departmental, project, and committee collaboration in Microsoft 365. Each Team Site is backed by a Microsoft 365 Group that controls membership, mailbox, calendar, Planner plan, and optionally a Microsoft Teams team. When you are asked to set up a site for a team, a Group-connected Team Site is the cleanest path, because permissions, licensing, and lifecycle policies (retention, expiration, sensitivity labels) then flow through a single object.

Run this workflow when a business unit requests a new collaboration workspace, when you provision a project site that needs owners and members from day one, or when you script bulk site creation.

Why the Graph API path?

Creating the Microsoft 365 Group through Graph (POST /groups with groupTypes: ["Unified"]) provisions the SharePoint site at https://<tenant>.sharepoint.com/sites/<mailNickname>. This is reproducible and avoids the classic /sites/add endpoint, which creates site-only sites that are not Group-connected.

Expected outcomes

  • A new Microsoft 365 Group named after the site, with a chosen primary owner.
  • A provisioned SharePoint Team Site reachable at https://{tenant}.sharepoint.com/sites/{mailNickname}.
  • A default document library, OneNote notebook, Planner plan, and shared mailbox tied to the group.
  • Site visibility set to Private or Public per the request.
  • An audit trail of the creation event in the Microsoft 365 audit log.

Risks and considerations

  • Verify the owner exists first. Look up the owner by UPN before creation to prevent half-provisioned groups with no owner. A common mistake is assuming a domain (for example @contoso.com) that does not match the tenant's verified domain.
  • Name collisions. Run GET /groups?$filter=displayName eq '...' before creating. Duplicate display names are allowed but confuse users. Duplicate mailNickname values fail.
  • mailNickname rules. It must be unique across the tenant, with no spaces and limited special characters.
  • Group creation may be restricted. If your tenant limits group creation to a specific security group, the service principal or admin running this call must be in that group.
  • Sensitivity labels and naming policies. If a group naming policy is enabled, your displayName and mailNickname may be prefixed or suffixed automatically. Confirm the resulting site URL after creation.
  • Provisioning delay. The SharePoint site is provisioned asynchronously after the group is created. Do not assume the site URL is reachable immediately.
  • Deletion is soft. Deleting the group soft-deletes the site. Avoid creating test sites in production without a cleanup plan.

Required permissions

PermissionWhy it's needed
Group.ReadWrite.AllRequired to create the Microsoft 365 Group that backs the Team Site.
User.Read.AllRequired to resolve the site owner by UPN or display name before assigning ownership.
Directory.ReadWrite.AllRequired when the tenant has group creation governance or when binding owners via @odata.bind.
Sites.FullControl.AllOptional: needed only if you plan to immediately apply custom site-level configuration (templates, permissions, features) after creation.

Ask Dex

Paste the prompt into a Dex conversation.

Prompt for IT admins

Create a SharePoint Team Site named {site_name} with {owner_upn} as the primary owner. Use {mail_nickname} as the URL alias, set visibility to {visibility}, and confirm the site URL once provisioning completes.

How an end user can ask Dex

Can you set up a new SharePoint site for our team called {site_name}? I should be the owner.

Manual steps (admin center)

This path suits a one-off request where you want to review choices in the interface.

  1. Sign in to the SharePoint admin center at https://{tenant}-admin.sharepoint.com as a SharePoint Administrator or Global Administrator.
  2. In the left navigation, go to Sites > Active sites > Create.
  3. Choose Team site (the option that connects to a Microsoft 365 Group). Do not pick Other options unless you need a classic site.
  4. Fill in the site details:
    • Site name: the display name (for example Project Aurora).
    • Group email address: populated from the site name. This becomes the mailNickname and the site URL slug, so review it.
    • Site address: confirm the final URL, for example https://{tenant}.sharepoint.com/sites/ProjectAurora.
    • Site description: a one-line purpose statement.
    • Privacy settings: Private or Public.
    • Language: this cannot be changed later, so choose carefully.
  5. Click Next. On the members screen, add the primary site owner (required) and any additional members. The owner is a group owner, not only a site collection admin.
  6. Click Finish.
  7. Verify the site exists by opening its URL and confirming that the owner can access it with full control.

Microsoft Graph API

The Graph approach creates a Microsoft 365 Group with groupTypes: ["Unified"], which provisions the SharePoint Team Site.

Step 1: Resolve the owner's object ID

GET https://graph.microsoft.com/v1.0/users/{ownerUpn}?$select=id,displayName,userPrincipalName

If the UPN lookup returns 404, fall back to a search:

GET https://graph.microsoft.com/v1.0/users?$filter=startswith(userPrincipalName,'{prefix}')&$select=id,displayName,userPrincipalName

Step 2: Check for display name collisions

GET https://graph.microsoft.com/v1.0/groups?$filter=displayName eq '{siteName}'&$select=id,displayName

Expect an empty value array before you proceed.

Step 3: Create the group (provisions the site)

POST https://graph.microsoft.com/v1.0/groups
Content-Type: application/json

{
  "displayName": "Project Aurora",
  "mailNickname": "ProjectAurora",
  "description": "Cross-functional project collaboration site",
  "groupTypes": ["Unified"],
  "mailEnabled": true,
  "securityEnabled": false,
  "visibility": "Private",
  "owners@odata.bind": [
    "https://graph.microsoft.com/v1.0/users/{ownerObjectId}"
  ]
}

A 201 Created response returns the new group's id, mail, and other metadata. The SharePoint site is provisioned asynchronously.

Step 4: Retrieve the provisioned SharePoint site

Poll until the site responds:

GET https://graph.microsoft.com/v1.0/groups/{groupId}/sites/root

The response includes webUrl, for example https://{tenant}.sharepoint.com/sites/ProjectAurora.

Step 5 (optional): Add additional owners or members

POST https://graph.microsoft.com/v1.0/groups/{groupId}/members/$ref

{ "@odata.id": "https://graph.microsoft.com/v1.0/users/{userId}" }

PowerShell

Two options. Choose the one that matches your tooling.

Uses the same Graph endpoints as the API workflow.

# Install once
Install-Module Microsoft.Graph -Scope CurrentUser

# Connect with the scopes needed to create groups and read users
Connect-MgGraph -Scopes "Group.ReadWrite.All","User.Read.All","Directory.ReadWrite.All"

# Resolve the owner by UPN
$owner = Get-MgUser -UserId "owner@contoso.com"

# Build the group payload (owners@odata.bind requires AdditionalProperties)
$params = @{
    DisplayName          = "Project Aurora"
    MailNickname         = "ProjectAurora"
    Description          = "Cross-functional project site"
    GroupTypes           = @("Unified")
    MailEnabled          = $true
    SecurityEnabled      = $false
    Visibility           = "Private"
    AdditionalProperties = @{
        "owners@odata.bind" = @("https://graph.microsoft.com/v1.0/users/$($owner.Id)")
    }
}

$group = New-MgGroup -BodyParameter $params
Write-Host "Group created: $($group.Id)"

Option B: SharePoint PnP PowerShell

A higher-level cmdlet if you already use PnP for site configuration:

Install-Module PnP.PowerShell -Scope CurrentUser
Connect-PnPOnline -Url "https://{tenant}-admin.sharepoint.com" -Interactive

New-PnPSite `
    -Type TeamSite `
    -Title "Project Aurora" `
    -Alias "ProjectAurora" `
    -Description "Cross-functional project site" `
    -IsPublic:$false `
    -Owner "owner@contoso.com"

PnP returns the new site URL directly.