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.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.title_field.data Optional

The field to use as display title

relationships.image_preview_field.data Optional

The field to use as preview image

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

1
POST https://site-api.datocms.com/item-types HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
5
Content-Type: application/vnd.api+json
6
7
{
8
"data": {
9
"type": "item_type",
10
"attributes": {
11
"name": "Blog post",
12
"api_key": "post"
13
}
14
}
15
}
Terminal window
1
curl -g 'https://site-api.datocms.com/item-types' \
2
-X POST \
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3" \
6
-H "Content-Type: application/vnd.api+json" \
7
--data-binary '{"data":{"type":"item_type","attributes":{"name":"Blog post","api_key":"post"}}}'
1
await fetch("https://site-api.datocms.com/item-types", {
2
method: "POST",
3
headers: {
4
Authorization: "Bearer YOUR-API-TOKEN",
5
Accept: "application/json",
6
"X-Api-Version": "3",
7
"Content-Type": "application/vnd.api+json",
8
},
9
body: JSON.stringify({
10
data: {
11
type: "item_type",
12
attributes: { name: "Blog post", api_key: "post" },
13
},
14
}),
15
});
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
Cache-Control: cache-control: max-age=0, private, must-revalidate
4
X-RateLimit-Limit: 30
5
X-RateLimit-Remaining: 28
6
7
{
8
"data": {
9
"type": "item_type",
10
"id": "DxMaW10UQiCmZcuuA-IkkA",
11
"relationships": {
12
"singleton_item": {
13
"data": null
14
},
15
"fields": {
16
"data": [
17
{
18
"type": "field",
19
"id": "Pkg-oztERp6o-Rj76nYKJg"
20
}
21
]
22
},
23
"fieldsets": {
24
"data": [
25
{
26
"type": "fieldset",
27
"id": "93Y1C2sySkG4Eg0atBRIwg"
28
}
29
]
30
},
31
"title_field": {
32
"data": null
33
},
34
"image_preview_field": {
35
"data": null
36
},
37
"excerpt_field": {
38
"data": null
39
},
40
"ordering_field": {
41
"data": null
42
},
43
"workflow": {
44
"data": null
45
}
46
},
47
"attributes": {
48
"name": "Blog post",
49
"api_key": "post",
50
"singleton": false,
51
"sortable": true,
52
"modular_block": false,
53
"tree": false,
54
"ordering_direction": null,
55
"ordering_meta": "created_at",
56
"draft_mode_active": false,
57
"all_locales_required": false,
58
"collection_appearance": "compact",
59
"hint": "Blog posts will be shown in our website under the Blog section",
60
"inverse_relationships_enabled": false
61
},
62
"meta": {
63
"has_singleton_item": false
64
}
65
}
66
}