Skip to content

Commit b38f4a1

Browse files
erwinvanhunenVesaJuvonen
authored andcommitted
Modern Sites REST API (#4135)
* Updated communication site creation * Updated TOC and renamed article
1 parent 2b384dc commit b38f4a1

File tree

3 files changed

+142
-131
lines changed

3 files changed

+142
-131
lines changed

docs/apis/communication-site-creation-rest.md

Lines changed: 0 additions & 129 deletions
This file was deleted.

docs/apis/site-creation-rest.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
---
2+
title: Create Modern SharePoint Sites using REST
3+
description: Create and get the status of a new modern SharePoint site by using the REST interface.
4+
ms.date: 4/19/2018
5+
ms.prod: sharepoint
6+
localization_priority: Priority
7+
---
8+
9+
# Manage modern SharePoint sites using REST
10+
11+
This topic assumes that you are already familiar with the following topics:
12+
13+
- [Get to know the SharePoint REST service](../sp-add-ins/get-to-know-the-sharepoint-rest-service.md)
14+
- [Complete basic operations using SharePoint REST endpoints](../sp-add-ins/complete-basic-operations-using-sharepoint-rest-endpoints.md)
15+
16+
This topic does not provide code snippets. The REST examples below assume an HTTP Accept header of 'application/json;odata.metadata=none'.
17+
18+
The following REST commands are available for creating a modern SharePoint Communication site:
19+
20+
- **Create**. Create a new SharePoint site.
21+
- **Delete**. Deletes a SharePoint site.
22+
- **Status**. Get the status of a SharePoint site.
23+
24+
The base URL for the REST commands is `_api/SPSiteManager`.
25+
26+
## Create a modern site
27+
28+
Using the following REST api you can create both Communication sites and non-group associated Team Sites.
29+
30+
To specify which type of site to create you use the WebTemplate attribute. Use one of the following templates to select which type of site to create:
31+
32+
* Communication Site: `SITEPAGEPUBLISHING#0`
33+
* non-group associated Team Site: `STS#3`
34+
35+
```json
36+
url: /_api/SPSiteManager/create
37+
accept: application/json;odata.metadata=none
38+
odata-version: 4.0
39+
method: POST
40+
body:
41+
{
42+
"Title": "Communication Site 1",
43+
"Url":"https://contoso.sharepoint.com/sites/commsite1",
44+
"Lcid": 1033,
45+
"ShareByEmailEnabled":false,
46+
"Classification":"Low Business Impact",
47+
"Description":"Description",
48+
"WebTemplate":"SITEPAGEPUBLISHING#0",
49+
"SiteDesignId":"6142d2a0-63a5-4ba0-aede-d9fefca2c767",
50+
51+
}
52+
```
53+
54+
> [!IMPORTANT]
55+
> If you use an app-only context to create the site collection the **owner property is required**. In other cases this is an optional property and if not present will default to the user calling the REST endpoint.
56+
57+
58+
The site design id can be retrieved by using the [Get-SPOSiteDesign](/powershell/module/sharepoint-online/get-spositedesign) (Microsoft SharePoint Online Management Shell) or [Get-PnPSiteDesign](/powershell/module/sharepoint-pnp/get-pnpsitedesign) (PnP PowerShell) cmdlets. If you want to apply an out-of-the-box available site design, use the following values:
59+
60+
- Topic: null
61+
- Showcase: `6142d2a0-63a5-4ba0-aede-d9fefca2c767`
62+
- Blank: `f6cc5403-0d63-442e-96c0-285923709ffc`
63+
64+
### Response
65+
66+
If successful, this method returns a `200, OK` response code and simple JSON object in the response body with the following details.
67+
68+
```json
69+
{
70+
"SiteId":"d11e59ca-1465-424c-be90-c847ba849af5",
71+
"SiteStatus":2,
72+
"SiteUrl":"https://contoso.sharepoint.com/sites/commsite1"
73+
}
74+
```
75+
76+
## Delete a modern site
77+
78+
The REST API to delete a modern site is:
79+
80+
```json
81+
url: /_api/SPSiteManager/delete
82+
method: POST
83+
accept: application/json;odata.metadata=none
84+
odata-version: 4.0
85+
body:
86+
{
87+
"siteId":"d11e59ca-1465-424c-be90-c847ba849af5"
88+
}
89+
```
90+
### Response
91+
92+
If succesfull this method returns a `200, OK` response code.
93+
94+
## Get modern site status
95+
96+
The REST API for getting the status of a modern SharePoint site:
97+
98+
```json
99+
url: /_api/SPSiteManager/status?url='https%3A%2F%2Fcontoso.sharepoint.com%2Fsites%2Fcommsite1'
100+
method: GET
101+
accept: application/json;odata.metadata=none
102+
odata-version: 4.0
103+
body: none
104+
```
105+
106+
### Response
107+
108+
If successful, this method returns a `200, OK` response code and simple JSON object in the response body with the following details.
109+
110+
If the site exists, the response returns the site status and site URL:
111+
112+
```json
113+
{
114+
"SiteId":"d11e59ca-1465-424c-be90-c847ba849af5",
115+
"SiteStatus":2,
116+
"SiteUrl":"https://contoso.sharepoint.com/sites/comm1"
117+
}
118+
```
119+
120+
121+
If the site does not exist, the response returns a site status of 0 with no URL and no site id.
122+
123+
```json
124+
{
125+
"SiteId":,
126+
"SiteStatus":0,
127+
"SiteUrl":
128+
}
129+
```
130+
131+
The full set of values for SiteStatus are as follows:
132+
133+
+ `0` - Not Found. The site doesn't exist.
134+
+ `1` - Provisioning. The site is currently being provisioned.
135+
+ `2` - Ready. The site has been created.
136+
+ `3` - Error. An error occurred while provisioning the site.
137+
138+
## See also
139+
140+
- [Get to know the SharePoint REST service](../sp-add-ins/get-to-know-the-sharepoint-rest-service.md)

docs/toc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@
402402
href: declarative-customization/column-formatting.md
403403
- name: View formatting
404404
href: declarative-customization/view-formatting.md
405-
- name: Communication site
406-
href: apis/communication-site-creation-rest.md
405+
- name: Creating modern sites
406+
href: apis/site-creation-rest.md
407407
- name: Site Footer
408408
href: features/site-footer.md
409409
- name: Shorter share links

0 commit comments

Comments
 (0)