Sites
Create, read, update, and delete SharePoint sites (site collections).
Prerequisites
| Requirement |
Description |
Reference |
| SharePoint Administrator or Global Administrator role |
Required to create, update, and delete sites. |
SharePoint admin roles |
Classic vs modern sites
SharePoint has two site models:
| Type |
Template |
Group-connected |
Use case |
| Modern Team site |
GROUP#0 |
Yes (M365 group) |
Team collaboration, document sharing |
| Modern Communication site |
SITEPAGEPUBLISHING#0 |
No |
Intranet, news, broad announcements |
| Classic site |
Various (STS#0, etc.) |
No |
Legacy workflows, on-prem migration |
Modern sites are the default for new provisioning. Classic sites are still
supported but Microsoft recommends modern for new work.
Examples
Create
Read, update, manage
Note: the SDK supports listing site collection administrators but not the
add/remove write operations — grant owner access via the Members group or
the SharePoint admin center.
Site lifecycle & compliance
Quick start
from office365.sharepoint.client_context import ClientContext
ctx = ClientContext("https://contoso.sharepoint.com/sites/team").with_client_certificate(
"contoso.onmicrosoft.com", client_id="client_id", thumbprint="thumbprint", cert_path="./cert.pem"
)
# Get site properties
web = ctx.web.get().execute_query()
print(f"{web.title} {web.url} ({web.web_template})")
API reference