Show examples in:
JavascriptHTTP
Endpoint info
Available examples
Content Management API > Model/Block model

Update a model/block model

Body parameters

typestringRequired

Must be exactly "item_type".

attributes.namestringOptional

Name of the model/block model

Example:"Blog post"
attributes.api_keystringOptional

API key of the model/block model

Example:"post"
attributes.collection_appearanceenumOptional

The way the model/block model collection should be presented to the editors

Example:"compact"
compactOptional

Compact view

tableOptional

Tabular view

attributes.singletonbooleanOptional

Whether the model is single-instance or not. This property only applies to models, not block models

attributes.all_locales_requiredbooleanOptional

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

attributes.sortablebooleanOptional

Whether editors can sort records via drag & drop or not. Must be false for block models

attributes.modular_blockbooleanOptional

Whether this is a block model or not. Block models define structures that can be embedded inside records, while regular models create standalone records

attributes.draft_mode_activebooleanOptional

Whether draft/published mode is active or not. Must be false for block models

attributes.draft_saving_activebooleanOptional

Whether draft records can be saved without satisfying the validations or not. Must be false for block models

attributes.treebooleanOptional

Whether editors can organize records in a tree or not. Must be false for block models

attributes.ordering_directionenum, nullOptional

If an ordering field is set, this field specifies the sorting direction. This property does not apply to block models

ascOptional

Ascending order

descOptional

Descending order

attributes.ordering_metaenum, nullOptional

Specifies the model's sorting method. Cannot be set in concurrency with ordering_field. This property does not apply to block models

Example:"created_at"
created_atOptional

Order by date of creation

updated_atOptional

Order by date of last update

first_published_atOptional

Order by date of first publication

published_atOptional

Order by date of last publication

attributes.hintstring, nullOptional

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

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

Whether inverse relationships fields are expressed in GraphQL or not. Must be false for block models

meta.has_singleton_itembooleanOptional

If this model is single-instance, this tells whether the single-instance record has already been created or not. This property only applies to models, not block models

relationships.ordering_field.dataOptional

The field upon which the collection is sorted. This relationship does not apply to block models

Type:<a href="/docs/content-management-api/resources/field">ResourceLinkage&#x3C;"field"></a>, null
relationships.presentation_title_field.dataOptional

The field to use as presentation title

Type:<a href="/docs/content-management-api/resources/field">ResourceLinkage&#x3C;"field"></a>, null
relationships.presentation_image_field.dataOptional

The field to use as presentation image

Type:<a href="/docs/content-management-api/resources/field">ResourceLinkage&#x3C;"field"></a>, null
relationships.title_field.dataOptional

The field to use as fallback title for SEO purposes. This relationship does not apply to block models

Type:<a href="/docs/content-management-api/resources/field">ResourceLinkage&#x3C;"field"></a>, null
relationships.image_preview_field.dataOptional

The field to use as fallback image for SEO purposes. This relationship does not apply to block models

Type:<a href="/docs/content-management-api/resources/field">ResourceLinkage&#x3C;"field"></a>, null
relationships.excerpt_field.dataOptional

The field to use as fallback description for SEO purposes. This relationship does not apply to block models

Type:<a href="/docs/content-management-api/resources/field">ResourceLinkage&#x3C;"field"></a>, null
relationships.workflow.dataOptional

The workflow to enforce on records

Type:<a href="/docs/content-management-api/resources/workflow">ResourceLinkage&#x3C;"workflow"></a>, null
attributes.collection_appeareanceenumDeprecated

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"
compactOptional

Compact view

tableOptional

Tabular view

Returns

Returns a Job ID. You can then poll for thecompletion of the jobthat will eventually return a resource object of type item_type

Examples

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

PUT https://site-api.datocms.com/item-types/:model_id_or_api_key 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",
"id": "DxMaW10UQiCmZcuuA-IkkA"
}
}
Terminal window
curl -g 'https://site-api.datocms.com/item-types/:model_id_or_api_key' \
-X PUT \
-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","id":"DxMaW10UQiCmZcuuA-IkkA"}}'
await fetch("https://site-api.datocms.com/item-types/:model_id_or_api_key", {
method: "PUT",
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", id: "DxMaW10UQiCmZcuuA-IkkA" },
}),
});
HTTP/1.1 202 Accepted
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": {
"type": "job",
"id": "4235"
}
}

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:

GET https://site-api.datocms.com/job-results/:job_result_id HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Terminal window
curl -g 'https://site-api.datocms.com/job-results/:job_result_id' \
\
-H "Authorization: Bearer YOUR-API-TOKEN" \
-H "Accept: application/json" \
-H "X-Api-Version: 3"
await fetch("https://site-api.datocms.com/job-results/:job_result_id", {
headers: {
Authorization: "Bearer YOUR-API-TOKEN",
Accept: "application/json",
"X-Api-Version": "3",
},
});
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": "job_result",
"id": "34",
"attributes": {
"status": 200,
"payload": {
"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
}
}
}
}
}
}