Manage content types using the REST API
How to create, update, and delete content types using the CMS (SaaS) REST API.
Create a content type
You can create content types using the content type API. You must provide a unique key
and a baseType
.
POST https://example.com/_cms/preview2/contenttypes
Content-Type: application/json
{
"key": "story",
"baseType": "component",
"displayName": "Story",
"properties": {
"heading": {
"type": "string",
"displayName": "Heading",
"description": "Write the greatest heading you can think of."
"localized": true,
"required": true,
"sortOrder": 10,
"maxLength": 100
},
"body": {
"type": "string",
"format": "html",
"displayName": "Body text",
"localized": true,
"required": true,
"sortOrder": 20
},
"tags": {
"type": "array",
"required": false,
"sortOrder": 30,
"items": {
"type": "string",
"format": "shortString",
"maxLength": 50
}
}
}
}
See Create content type API reference.
Update a content type
You can update existing content types using the content type API, but you cannot update the key
or baseType
of an existing content type.
PUT https://example.com/_cms/preview2/contenttypes/story
Content-Type: application/json
{
"key": "story",
"baseType": "component",
"displayName": "Story",
"properties": {
"heading": {
"type": "string",
"displayName": "Heading",
"description": "Write the greatest heading you can think of."
"localized": true,
"required": true,
"sortOrder": 10,
"maxLength": 100
},
"body": {
"type": "string",
"format": "html",
"displayName": "Body text",
"localized": true,
"required": true,
"sortOrder": 20
}
}
}
See Create or replace content type API reference.
You can modify individual content type properties and field values. The response returns the updated content type.
PATCH https://example.com/_cms/preview2/contenttypes/story
Content-Type: application/merge-patch+json
{
"properties": {
"heading": {
"required": false
}
}
}
See Update content API reference.
Get a specific content type
You can retrieve a content type using content type API with its unique key.
GET https://example.com/_cms/preview2/contenttypes/story
{
"key": "story",
"displayName": "Story",
"description": "The Story contains data about news stories."
"baseType": "component",
"sortOrder": 10,
"mayContainTypes": [ "*" ],
"features": [ "localization", "versioning", "publishPeriod" ],
"usage": [ "property", "instance" ],
"source": "",
"created": "2023-05-22T14:31:08.43+00:00",
"lastModified": "2023-05-22T14:31:20.557+00:00",
"lastModifiedBy": "steve",
"properties": {
"heading": {
"type": "string",
"displayName": "Heading",
"description": "Write the greatest heading you can think of."
"localized": true,
"required": true,
"sortOrder": 10,
"maxLength": 100
},
"body": {
"type": "string",
"format": "html",
"displayName": "Body text",
"localized": true,
"required": true,
"sortOrder": 20
},
"tags": {
"type": "array",
"required": false,
"sortOrder": 30,
"items": {
"type": "string",
"format": "shortString",
"maxLength": 50
}
}
}
}
See Get content type API reference.
List content types
You can retrieve a list of content types using the content type API.
GET https://example.com/_cms/preview2/contenttypes
{
"items": [
{
"key": "story",
"baseType": "component",
"displayName": "Story"
},
{
"key": "newspage",
"baseType": "page",
"displayName": "News"
}
],
"pageSize": 10,
"pageIndex": 0,
"totalItemCount": 2
}
See List content types API reference.
List editable content types
Because you can edit only certain content types, you may want to list only editable content types by providing the sources
parameter.
The value default
returns content types where the source
field is empty.
List content types from a specific source
You can restrict the list to only return content types from one or more sources. For example, you could use this to limit the listing to include only content types that are editable in the UI.
The value default
indicates that content types where the source
field is empty should be returned; all
indicates that every content type, regardless of source, should be returned.
GET https://example.com/_cms/preview2/contenttypes?sources=default,custom
See List content types API reference.
List content types you can create under a content type
Use the forContainerType
parameter to list which content type you can create under another content type.
GET https://example.com/_cms/preview2/contenttypes?forContainerType=news
See List content types API reference.
Delete a content type
You can delete existing content types using the content type API. You cannot delete built-in content types.
DELETE https://example.com/_cms/preview2/contenttypes/story
Updated 8 days ago