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"
name string Required

Name of the model

Example: "Blog post"
api_key string Required

API key of the model

Example: "post"
singleton boolean Optional

Whether the model is single-instance or not

all_locales_required boolean Optional

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

sortable boolean Optional

Whether editors can sort records via drag & drop or not

modular_block boolean Optional

Whether this model is a modular content block or not

draft_mode_active boolean Optional

Whether draft/published mode is active or not

tree boolean Optional

Whether editors can organize records in a tree or not

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

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

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

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"
inverse_relationships_enabled boolean Optional

Whether inverse relationships fields are expressed in GraphQL or not

ordering_field Optional

The field upon which the collection is sorted

title_field Optional

The field to use as display title

image_preview_field Optional

The field to use as preview image

excerpt_field Optional

The field to use as fallback description for SEO purposes

workflow Optional

The workflow to enforce on records

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
import { buildClient } from "@datocms/cma-client-node";
2
3
async function run() {
4
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
5
6
const itemType = await client.itemTypes.create({
7
name: "Blog post",
8
api_key: "post",
9
});
10
11
// Check the 'Returned output' tab for the result ☝️
12
console.log(itemType);
13
}
14
15
run();
1
{
2
id: "DxMaW10UQiCmZcuuA-IkkA",
3
name: "Blog post",
4
api_key: "post",
5
singleton: false,
6
sortable: true,
7
modular_block: false,
8
tree: false,
9
ordering_direction: null,
10
ordering_meta: "created_at",
11
draft_mode_active: false,
12
all_locales_required: false,
13
collection_appearance: "compact",
14
hint: "Blog posts will be shown in our website under the Blog section",
15
inverse_relationships_enabled: false,
16
meta: { has_singleton_item: false },
17
singleton_item: null,
18
fields: [{ type: "field", id: "Pkg-oztERp6o-Rj76nYKJg" }],
19
fieldsets: [{ type: "fieldset", id: "93Y1C2sySkG4Eg0atBRIwg" }],
20
title_field: null,
21
image_preview_field: null,
22
excerpt_field: null,
23
ordering_field: null,
24
workflow: null,
25
}