Skip to main content
Version: 2.100.0

New SharePoint site

The EasyLife 365 Collaboration API empowers users to create SharePoint sites effortlessly. These sites are fashioned based on pre-existing templates and their associated policies.

info

The chosen template dictates whether the created resource will be a SharePoint Team Site or a SharePoint Communication Site.

Permissions

Permission TypePermissions (Scope)
Delegated (work or school account)https://api.easylife365.cloud/collab/App.ReadWrite.All
ApplicationNot supported.

HTTP Request

POST https://api.easylife365.cloud/collab/v1/spo/
Content-Type: application/json

HTTP Request Headers

HeaderValue
AuthorizationBearer token. (Required)
Content-Typeapplication/json

Request Body

PropertyTypeDescription
displayNameStringName of the SharePoint site. (Required)
descriptionStringDescription of the SharePoint site. (Optional)
templateIdStringTemplate identifier. (Required)
aliasStringAlias of the SharePoint site. (Optional)
ownersArray of StringList of owners of the group. (Optional) The requester is automatically added.
metadataObjectList of key/value pairs representing additional information. (Optional)
labelIdStringSensitivity labelId for the group. (Optional)

Response

Upon queuing the request, the API will respond with the following payload:

{
"requestId": "72d2f4b8-76fe-4140-9460-3c7ef9091cb5",
"tenantId": "1840b34e-6fe7-4a56-9ad3-0b7b58c49dc7",
"approvalRequired": false
}

The requestId can be utilized to track all activities associated with the creation process. Once the SharePoint site is created, the configured provisioning webhook on the template will receive a payload containing the corresponding requestId.

Example 1: Create a SharePoint Site

The following sample creates a SharePoint site with two owners. The user initiating the call will automatically become an owner.

POST https://api.easylife365.cloud/collab/v1/spo/
Content-Type: application/json
{
"displayName": "My Demo SharePoint Site",
"description": "A demonstration of SharePoint site creation via the API.",
"templateId": "fc6ffbd8-f7f0-4c05-b707-227d233b9e1b",
"alias": "",
"owners": [
"49cf935a-284f-4c84-8df7-a5b11f1be527",
"6a95c23b-cbb3-4f06-9b05-5e96ac65c78c"
],
"metadata": {
"el-text-388": "Custom text field content goes here!"
}
}

Example 2: Create a SharePoint Site using PowerShell

The next example illustrates creating a SharePoint site using PowerShell. Prior to execution, ensure you've registered an application and obtained the TenantId and ClientId. Additionally, retrieve the correct scope from this document.

Import-Module MSAL.PS

$msalParam = @{
tenantId = "[TENANT_ID]"
clientId = "[CLIENT_ID]"
scopes = "[SCOPE]"
}

# Get JWT authentication token.
if($token){
$token = Get-MsalToken @msalParam -Silent
} else {
$token = Get-MsalToken @msalParam -DeviceCode
}

# Create object with values to pass to the API.
$uri = "https://api.dev.easylife365.cloud/collab/v1/spo/"

$body = @{
displayName = "My Demo SharePoint Site"
description = "A demonstration of SharePoint site creation via the API."
templateId = "fc6ffbd8-f7f0-4c05-b707-227d233b9e1b"
alias = ""
owners= @("49cf935a-284f-4c84-8df7-a5b11f1be527", "6a95c23b-cbb3-4f06-9b05-5e96ac65c78c")
metadata = @{
"el-text-388" = "Custom text field content goes here!"
}
}

# Invoke the API and capture responses.
$jsonBody = $body | ConvertTo-Json -Depth 5 -Compress
$encodedBody = [System.Text.Encoding]::UTF8.GetBytes($jsonBody)

$headers = @{
"Authorization"="Bearer $($token.AccessToken)"
"Content-Type" = "application/json"
}

Write-Information "Creating SharePoint site with: $jsonBody" -InformationAction Continue
$response = Invoke-RestMethod -Method post -Uri $uri -Headers $headers -Body $encodedBody
$response