Choose your language:
    Create a new model
    Parameters
    name  string  Required

    Name of the model

    apiKey  string  Required

    API key of the model

    singleton  boolean  Optional

    Whether the model is single-instance or not

    allLocalesRequired  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

    modularBlock  boolean  Optional

    Whether this model is a modular content block or not

    draftModeActive  boolean  Optional

    Whether draft/published mode is active or not

    tree  boolean  Optional

    Whether editors can organize records in a tree or not

    orderingDirection  enum, null  Optional

    If an ordering field is set, this fields specify the sorting direction

    collectionAppearance  enum  Optional

    The way the model collection should be presented to the editors

    orderingField  field.id, null.id  Optional

    The field upon which the collection is sorted

    titleField  field.id, null.id  Optional

    The field to use as display title

    Deprecated
    collectionAppeareance  enum  Deprecated  Optional

    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

    Returns
    Returns a item_type object.

    Examples

    Example code:
    const SiteClient = require('datocms-client').SiteClient;
    const client = new SiteClient('YOUR-API-TOKEN');
    client.itemTypes.create({
    name: 'Blog post',
    apiKey: 'post',
    singleton: false,
    allLocalesRequired: false,
    sortable: true,
    modularBlock: false,
    draftModeActive: false,
    tree: false,
    orderingDirection: null,
    collectionAppearance: 'compact',
    orderingField: null,
    titleField: null
    })
    .then((itemType) => {
    console.log(itemType);
    })
    .catch((error) => {
    console.error(error);
    });
    Returned output:
    > node example.js
    {
    "id": "44",
    "name": "Blog post",
    "apiKey": "post",
    "collectionAppearance": "compact",
    "singleton": false,
    "allLocalesRequired": false,
    "sortable": true,
    "modularBlock": false,
    "draftModeActive": false,
    "tree": false,
    "orderingDirection": null,
    "hasSingletonItem": false,
    "singletonItem": null,
    "titleField": null,
    "orderingField": null
    }