Sharing
Share files, folders, and sites with specific people, the whole organization,
or anonymous users via sharing links and direct permission grants.
Prerequisites
| Requirement |
Description |
Reference |
| Contribute or higher on the item being shared |
Required to create sharing links. Site Owner to change site-level sharing policy. |
SharePoint admin roles |
How sharing works
Every sharing operation creates a sharing link that encodes the access
level and audience. SharePoint supports these link types:
| Link kind |
Access level |
Scope |
| Anonymous view |
Anyone with the link can view |
External (no sign-in) |
| Anonymous edit |
Anyone with the link can edit |
External (no sign-in) |
| Organization view |
Everyone in your org can view |
Internal |
| Organization edit |
Everyone in your org can edit |
Internal |
| Specific people |
Only named users can access |
Internal or external |
| Direct |
Canonical URL (no sharing link) |
Inherits permissions |
Sharing is also controlled at the site level — admins can restrict or
disable external sharing entirely, and specific users can be granted
access via role assignments on the item.
Examples
Sharing links
Permissions & site policy
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"
)
# Create an anonymous view link for a file
from office365.sharepoint.sharing.links.kind import SharingLinkKind
file = ctx.web.get_file_by_server_relative_url("Shared Documents/report.docx")
result = file.share_link(SharingLinkKind.AnonymousView).execute_query()
print(f"Share link: {result.value.sharingLinkInfo.Url}")
API reference