Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Model/Block

Update a model

Body parameters

type string Required

Must be exactly "item_type".

attributes.name string Optional

Name of the model

Example: "Blog post"
attributes.api_key string Optional

API key of the model

Example: "post"
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.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.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

meta.has_singleton_item boolean Optional

If this model is single-instance, this tells the single-instance record has already been created 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 Job ID. You can then poll for the completion of the job that will eventually return a resource object of type item_type

Examples

The response contains the ID of the asynchronous job that started:

1
PUT https://site-api.datocms.com/item-types/:model_id_or_api_key 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
"id": "DxMaW10UQiCmZcuuA-IkkA"
11
}
12
}
Terminal window
1
curl -g 'https://site-api.datocms.com/item-types/:model_id_or_api_key' \
2
-X PUT \
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","id":"DxMaW10UQiCmZcuuA-IkkA"}}'
1
await fetch("https://site-api.datocms.com/item-types/:model_id_or_api_key", {
2
method: "PUT",
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: { type: "item_type", id: "DxMaW10UQiCmZcuuA-IkkA" },
11
}),
12
});
1
HTTP/1.1 202 Accepted
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": "job",
10
"id": "4235"
11
}
12
}

To get the asynchronous job result, poll the job result endpoint. While the task is in progress, the endpoint returns a 404 status code. When the job completes, the status changes to 200 OK:

1
GET https://site-api.datocms.com/job-results/:job_result_id HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
Terminal window
1
curl -g 'https://site-api.datocms.com/job-results/:job_result_id' \
2
\
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3"
1
await fetch("https://site-api.datocms.com/job-results/:job_result_id", {
2
headers: {
3
Authorization: "Bearer YOUR-API-TOKEN",
4
Accept: "application/json",
5
"X-Api-Version": "3",
6
},
7
});
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": "job_result",
10
"id": "34",
11
"attributes": {
12
"status": 200,
13
"payload": {
14
"data": {
15
"type": "item_type",
16
"id": "DxMaW10UQiCmZcuuA-IkkA",
17
"relationships": {
18
"singleton_item": {
19
"data": null
20
},
21
"fields": {
22
"data": [
23
{
24
"type": "field",
25
"id": "Pkg-oztERp6o-Rj76nYKJg"
26
}
27
]
28
},
29
"fieldsets": {
30
"data": [
31
{
32
"type": "fieldset",
33
"id": "93Y1C2sySkG4Eg0atBRIwg"
34
}
35
]
36
},
37
"title_field": {
38
"data": null
39
},
40
"image_preview_field": {
41
"data": null
42
},
43
"excerpt_field": {
44
"data": null
45
},
46
"ordering_field": {
47
"data": null
48
},
49
"workflow": {
50
"data": null
51
}
52
},
53
"attributes": {
54
"name": "Blog post",
55
"api_key": "post",
56
"singleton": false,
57
"sortable": true,
58
"modular_block": false,
59
"tree": false,
60
"ordering_direction": null,
61
"ordering_meta": "created_at",
62
"draft_mode_active": false,
63
"all_locales_required": false,
64
"collection_appearance": "compact",
65
"hint": "Blog posts will be shown in our website under the Blog section",
66
"inverse_relationships_enabled": false
67
},
68
"meta": {
69
"has_singleton_item": false
70
}
71
}
72
}
73
}
74
}
75
}