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

Create a new model/block model

Query parameters

skip_menu_item_creationboolean

Skip the creation of a menu item linked to the model

menu_item_idstring

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

Example:"FF-P5of6Qp-DD2w0xoaa6Q"
schema_menu_item_idstring

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

Example:"FF-P5of6Qp-DD2w0xoaa6Q"

Body parameters

idstringOptional

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

Example:"DxMaW10UQiCmZcuuA-IkkA"
namestringRequired

Name of the model/block model

Example:"Blog post"
api_keystringRequired

API key of the model/block model

Example:"post"
singletonbooleanOptional

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

all_locales_requiredbooleanOptional

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

sortablebooleanOptional

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

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

draft_mode_activebooleanOptional

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

draft_saving_activebooleanOptional

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

treebooleanOptional

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

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

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

collection_appearanceenumOptional

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

Example:"compact"
compactOptional

Compact view

tableOptional

Tabular view

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

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

ordering_fieldOptional

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
presentation_title_fieldOptional

The field to use as presentation title

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

The field to use as presentation image

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

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
image_preview_fieldOptional

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
excerpt_fieldOptional

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
workflowOptional

The workflow to enforce on records

Type:<a href="/docs/content-management-api/resources/workflow">ResourceLinkage&#x3C;"workflow"></a>, null
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 resource object of type item_type

Examples

import { buildClient } from "@datocms/cma-client-node";
async function run() {
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const itemType = await client.itemTypes.create({
name: "Blog post",
api_key: "post",
});
// Check the 'Returned output' tab for the result ☝️
console.log(itemType);
}
run();
{
id: "DxMaW10UQiCmZcuuA-IkkA",
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 },
singleton_item: null,
fields: [{ type: "field", id: "Pkg-oztERp6o-Rj76nYKJg" }],
fieldsets: [{ type: "fieldset", id: "93Y1C2sySkG4Eg0atBRIwg" }],
presentation_title_field: null,
presentation_image_field: null,
title_field: null,
image_preview_field: null,
excerpt_field: null,
ordering_field: null,
workflow: null,
}