Setting the file. One moment.
Subchapter 3.9
references/content-management/content-types.mdMarkdown7 KBView on GitHub
Content types define the structure of your content. They must be published before entries can be created.
curl https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id} \
-H "Authorization: Bearer {cma_token}"curl "https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types?limit=100" \
-H "Authorization: Bearer {cma_token}"curl -X PUT https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id} \
-H "Authorization: Bearer {cma_token}" \
-H "Content-Type: application/vnd.contentful.management.v1+json" \
-d '{
"name": "Blog Post",
"displayField": "title",
"fields": [
{
"id": "title",
"name": "Title",
"type": "Symbol",
"required": true,
"localized": false
},
{
"id": "body",
"name": "Body",
"type": "Text",
"required": false,
"localized": true
},
{
"id": "slug",
"name": "Slug",
"type": "Symbol",
"required": true,
"validations": [
{ "unique": true },
{ "regexp": { "pattern": "^[a-z0-9-]+$" } }
]
}
]
}'CRITICAL: Publish after creation to make it usable:
curl -X PUT https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id}/published \
-H "Authorization: Bearer {cma_token}" \
-H "X-Contentful-Version: 1"# 1. Get current version
curl https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id} \
-H "Authorization: Bearer {cma_token}"
# 2. Update — include ALL fields (existing + new)
curl -X PUT https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id} \
-H "Authorization: Bearer {cma_token}" \
-H "Content-Type: application/vnd.contentful.management.v1+json" \
-H "X-Contentful-Version: 2" \
-d '{
"name": "Blog Post",
"displayField": "title",
"fields": [
{ "id": "title", "name": "Title", "type": "Symbol", "required": true },
{ "id": "body", "name": "Body", "type": "Text" },
{ "id": "slug", "name": "Slug", "type": "Symbol", "required": true },
{ "id": "summary", "name": "Summary", "type": "Symbol" }
]
}'
# 3. Publish updated content type
curl -X PUT https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id}/published \
-H "Authorization: Bearer {cma_token}" \
-H "X-Contentful-Version: 3"curl -X PUT https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id}/published \
-H "Authorization: Bearer {cma_token}" \
-H "X-Contentful-Version: {version}"curl -X DELETE https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id}/published \
-H "Authorization: Bearer {cma_token}"Cannot unpublish if entries exist for this content type.
Must unpublish first. Cannot delete if entries exist.
# 1. Unpublish
curl -X DELETE https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id}/published \
-H "Authorization: Bearer {cma_token}"
# 2. Delete
curl -X DELETE https://api.contentful.com/spaces/{space_id}/environments/{env_id}/content_types/{content_type_id} \
-H "Authorization: Bearer {cma_token}"| Type | Description | Example Value |
|---|---|---|
Symbol | Short text (max 256 chars) | "Hello World" |
Text | Long text (max 50,000 chars) | "Long content..." |
Integer | Whole number | 42 |
Number | Decimal number | 3.14 |
Boolean | True/false | true |
Date | ISO 8601 date | "2024-01-15T10:30:00Z" |
Location | Lat/lon coordinates | {"lat": 40.71, "lon": -74.00} |
Object | Arbitrary JSON | {"key": "value"} |
RichText | Structured rich text | Rich text document |
Link | Reference to entry or asset | {"sys": {"type": "Link", ...}} |
Array | Array of symbols or links | ["tag1", "tag2"] |
{
"id": "author",
"name": "Author",
"type": "Link",
"linkType": "Entry",
"validations": [
{ "linkContentType": ["author", "contributor"] }
]
}{
"id": "image",
"name": "Image",
"type": "Link",
"linkType": "Asset"
}{
"id": "relatedPosts",
"name": "Related Posts",
"type": "Array",
"items": {
"type": "Link",
"linkType": "Entry",
"validations": [
{ "linkContentType": ["blogPost"] }
]
}
}{
"id": "tags",
"name": "Tags",
"type": "Array",
"items": { "type": "Symbol" }
}{
"id": "richBody",
"name": "Rich Body",
"type": "RichText",
"validations": [
{
"nodes": {
"embedded-entry-block": [
{ "linkContentType": ["quote", "callout"] }
]
}
}
]
}{ "unique": true }
{ "regexp": { "pattern": "^[a-z0-9-]+$" } }
{ "size": { "min": 3, "max": 100 } }
{ "in": ["tech", "design", "business"] }{ "range": { "min": 1, "max": 5 } }
{ "in": [1, 5, 10, 25, 50, 100] }{ "size": { "min": 1, "max": 10 } }{ "linkContentType": ["author", "contributor"] }
{ "assetFileSize": { "min": 1024, "max": 10485760 } }
{ "assetImageDimensions": { "width": { "min": 100, "max": 2000 }, "height": { "min": 100, "max": 2000 } } }linkContentType — restrict references to specific content typeslocalized: true — only for fields that need translationdisplayField — identifies content in the Contentful web app