Content Types
Manage content types on a SharePoint site — create, update, delete, add and
remove fields, reorder fields, and associate with lists.
Prerequisites
| Requirement |
Description |
Reference |
| Site Owner or Site Collection Administrator role |
Required to create, update, and delete content types at the site level. |
SharePoint admin roles |
| Site Columns (fields) must exist on the site |
Needed when adding fields to a content type. |
Field examples |
How content types work
graph TD
subgraph Site
CT["Content Type"]
CT --> FL["Field Links (ordered)"]
FL --> F1["Field: Title"]
FL --> F2["Field: Editor"]
FL --> F3["Field: CustomColumn"]
end
subgraph List
L["Document Library"]
L -->|has| CTs["Content Types"]
CTs --> D["Default CT"]
CTs --> O["Other CTs"]
end
CT -.->|add to| L
A content type lives at the site level and defines a reusable
set of columns (fields) with their display order (field links).
It can then be associated with one or more lists.
Examples
Workflow
| Operation |
File |
Required role |
API reference |
| End-to-end: create → add field → add to list → verify |
basic_usage.py |
Site Owner |
Full workflow |
Site-level content types
List association
Migration
| Operation |
File |
Required role |
API reference |
| Clone a content type (with fields) to another site |
copy_to_site.py |
Site Owner on both sites |
Provisioning |
Quick start
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.contenttypes.creation_information import ContentTypeCreationInformation
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 content types
cts = ctx.web.content_types.get().execute_query()
for ct in cts:
print(f" {ct.name} (ID: {ct.id})")
# Create a new content type
info = ContentTypeCreationInformation(Name="Project Document", Description="For Contoso projects")
ct = ctx.web.content_types.add(info).execute_query()
print(f"Created: {ct.name}")
API reference