Groups
Manage SharePoint site groups — create, list, find, set owner, and add or
remove members.
Prerequisites
| Requirement |
Description |
Reference |
| Site Owner role |
Required to create, delete, and manage group membership. |
SharePoint admin roles |
Examples
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"
)
# List all site groups
groups = ctx.web.site_groups.get().execute_query()
for g in groups:
print(f" {g.title} (ID: {g.id})")
# Create a group
group = ctx.web.site_groups.add("Project Contributors").execute_query()
API reference