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.
The chosen template dictates whether the created resource will be a SharePoint Team Site or a SharePoint Communication Site.
Permissions
Permission Type | Permissions (Scope) |
---|---|
Delegated (work or school account) | https://api.insiders.easylife365.cloud/collab/App.ReadWrite.All |
Application | Not supported. |
HTTP Request
POST https://api.insiders.easylife365.cloud/collab/v1/spo/
Content-Type: application/json
HTTP Request Headers
Header | Value |
---|---|
Authorization | Bearer token. (Required) |
Content-Type | application/json |
Request Body
Property | Type | Description |
---|---|---|
displayName | String | Name of the SharePoint site. (Required) |
description | String | Description of the SharePoint site. (Optional) |
templateId | String | Template identifier. (Required) |
alias | String | Alias of the SharePoint site. (Optional) |
owners | Array of String | List of owners of the group. (Optional) The requester is automatically added. |
metadata | Object | List of key/value pairs representing additional information. (Optional) |
labelId | String | Sensitivity 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.insiders.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