Sorry, no results found for "".

Show examples in:
Javascript HTTP

Content Management API > Model/Block

Create a new model

Query parameters

skip_menu_item_creation boolean

Skip the creation of a menu item linked to the model

menu_item_id string

Explicitely specify the ID of the menu item that will be linked to the model

Example: "FF-P5of6Qp-DD2w0xoaa6Q"
schema_menu_item_id string

Explicitely specify the ID of the schema menu item that will be linked to the model

Example: "FF-P5of6Qp-DD2w0xoaa6Q"

Body parameters

id string Optional

RFC 4122 UUID of item type expressed in URL-safe base64 format

Example: "DxMaW10UQiCmZcuuA-IkkA"
type string Required

Must be exactly "item_type".

attributes.name string Required

Name of the model

Example: "Blog post"
attributes.api_key string Required

API key of the model

Example: "post"
attributes.singleton boolean Optional

Whether the model is single-instance or not

attributes.all_locales_required boolean Optional

Whether we require all the project locales to be present for each localized field or not

attributes.sortable boolean Optional

Whether editors can sort records via drag & drop or not

attributes.modular_block boolean Optional

Whether this model is a modular content block or not

attributes.draft_mode_active boolean Optional

Whether draft/published mode is active or not

attributes.draft_saving_active boolean Optional

Whether draft records can be saved without satisfying the validations or not

attributes.tree boolean Optional

Whether editors can organize records in a tree or not

attributes.ordering_direction enum, null Optional

If an ordering field is set, this fields specify the sorting direction

asc Optional

Ascending order

desc Optional

Descending order

attributes.ordering_meta enum, null Optional

Specifies the model's sorting method. Cannot be set in concurrency with ordering_field

Example: "created_at"
created_at Optional

Order by date of creation

updated_at Optional

Order by date of last update

first_published_at Optional

Order by date of first publication

published_at Optional

Order by date of last publication

attributes.collection_appearance enum Optional

The way the model collection should be presented to the editors

Example: "compact"
compact Optional

Compact view

table Optional

Tabular view

attributes.hint string, null Optional

A hint shown to editors to help them understand the purpose of this model/block

Example: "Blog posts will be shown in our website under the Blog section"
attributes.inverse_relationships_enabled boolean Optional

Whether inverse relationships fields are expressed in GraphQL or not

relationships.ordering_field.data Optional

The field upon which the collection is sorted

relationships.presentation_title_field.data Optional

The field to use as presentation title

relationships.presentation_image_field.data Optional

The field to use as presentation image

relationships.title_field.data Optional

The field to use as fallback title for SEO purposes

relationships.image_preview_field.data Optional

The field to use as fallback image for SEO purposes

relationships.excerpt_field.data Optional

The field to use as fallback description for SEO purposes

relationships.workflow.data Optional

The workflow to enforce on records

attributes.collection_appeareance enum Deprecated

The way the model collection should be presented to the editors

This field contains a typo and will be removed in future versions: use collection_appearance instead

Example: "compact"
compact Optional

Compact view

table Optional

Tabular view

Returns

Returns a resource object of type item_type.

Examples

POST https://site-api.datocms.com/item-types HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Content-Type: application/vnd.api+json
{
"data": {
"type": "item_type",
"attributes": {
"name": "Blog post",
"api_key": "post"
}
}
}
Terminal window
curl -g 'https://site-api.datocms.com/item-types' \
-X POST \
-H "Authorization: Bearer YOUR-API-TOKEN" \
-H "Accept: application/json" \
-H "X-Api-Version: 3" \
-H "Content-Type: application/vnd.api+json" \
--data-binary '{"data":{"type":"item_type","attributes":{"name":"Blog post","api_key":"post"}}}'
await fetch("https://site-api.datocms.com/item-types", {
method: "POST",
headers: {
Authorization: "Bearer YOUR-API-TOKEN",
Accept: "application/json",
"X-Api-Version": "3",
"Content-Type": "application/vnd.api+json",
},
body: JSON.stringify({
data: {
type: "item_type",
attributes: { name: "Blog post", api_key: "post" },
},
}),
});
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": {
"type": "item_type",
"id": "DxMaW10UQiCmZcuuA-IkkA",
"relationships": {
"singleton_item": {
"data": null
},
"fields": {
"data": [
{
"type": "field",
"id": "Pkg-oztERp6o-Rj76nYKJg"
}
]
},
"fieldsets": {
"data": [
{
"type": "fieldset",
"id": "93Y1C2sySkG4Eg0atBRIwg"
}
]
},
"presentation_title_field": {
"data": null
},
"presentation_image_field": {
"data": null
},
"title_field": {
"data": null
},
"image_preview_field": {
"data": null
},
"excerpt_field": {
"data": null
},
"ordering_field": {
"data": null
},
"workflow": {
"data": null
}
},
"attributes": {
"name": "Blog post",
"api_key": "post",
"singleton": false,
"sortable": true,
"modular_block": false,
"tree": false,
"ordering_direction": null,
"ordering_meta": "created_at",
"draft_mode_active": false,
"all_locales_required": false,
"collection_appearance": "compact",
"hint": "Blog posts will be shown in our website under the Blog section",
"inverse_relationships_enabled": false,
"draft_saving_active": false
},
"meta": {
"has_singleton_item": false
}
}
}