Home
Content Management API⁡𝅶‍‍𝅺⁡‍𝅴⁡𝅴𝅹‍‍⁢𝅵‍‍⁣‌⁡⁣𝅺⁢𝅸⁡⁢‍𝅹⁢𝅺𝅸‍‍‍𝅷‍‍𝅳⁡‍⁠‍‍⁢𝅵‍‍𝅳⁡⁣⁡⁣⁡​⁡⁢⁢𝅵‍𝅺‍𝅺⁢𝅸⁡⁢‍𝅹⁣‌⁡⁣𝅺⁢𝅸⁡⁢‍𝅹⁢𝅺𝅸‍𝅺⁠⁣𝅴⁡⁣𝅺⁡‍‍𝅺𝅴⁡⁣⁠𝅸⁠𝅺⁡⁣⁡𝅴⁡​⁠⁡⁢‍𝅺⁢𝅳⁢‌⁢​⁢𝅴⁢‍⁢⁠‍𝅺𝅴⁡⁣⁠𝅸⁡⁢‍𝅺⁢⁢⁢𝅴⁢𝅳⁢⁢⁢‌⁢⁡⁢𝅳⁢‌‍‍⁡𝅸
Main resources
Upload-related
Site Search
Environments
UI
Workflows
Async jobs
Roles & permissions
Webhooks
Hosting & CI integrations
Subscription
Enterprise
    Show examples in:
    Update a model

    Parameters

    name  string  Optional

    Name of the model

    api_key  string  Optional

    API key of the model

    collection_appearance  enum  Optional

    The way the model collection should be presented to the editors

    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

    ordering_meta  enum, null  Optional

    Specifies the model's sorting method. Cannot be set in concurrency with ordering_field

    hint  string, null  Optional

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

    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

    ordering_field  { type: "field", id: field.id }, null  Optional

    The field upon which the collection is sorted

    title_field  { type: "field", id: field.id }, null  Optional

    The field to use as display title

    image_preview_field  { type: "field", id: field.id }, null  Optional

    The field to use as preview image

    excerpt_field  { type: "field", id: field.id }, null  Optional

    The field to use as fallback description for SEO purposes

    workflow  { type: "workflow", id: workflow.id }, null  Optional

    The workflow to enforce on records

    Returns

    Returns a item_type resource object.

    Examples

    Example code:
    import { buildClient } from '@datocms/cma-client-node';
    async function run() {
    const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
    const modelIdOrApiKey = 'blog_post';
    const itemType = await client.itemTypes.update(modelIdOrApiKey, {
    name: 'Blog post',
    api_key: 'post',
    collection_appearance: 'compact',
    singleton: false,
    all_locales_required: false,
    sortable: true,
    modular_block: false,
    draft_mode_active: false,
    tree: false,
    ordering_direction: null,
    ordering_meta: 'created_at',
    hint: 'Blog posts will be shown in our website under the Blog section',
    inverse_relationships_enabled: false,
    meta: {
    has_singleton_item: false
    },
    ordering_field: null,
    title_field: null,
    image_preview_field: null,
    excerpt_field: null,
    workflow: null
    });
    console.log(itemType);
    }
    run();
    Returned output:
    {
    id: '44',
    name: 'Blog post',
    api_key: 'post',
    collection_appearance: 'compact',
    singleton: false,
    all_locales_required: false,
    sortable: true,
    modular_block: false,
    draft_mode_active: false,
    tree: false,
    ordering_direction: null,
    ordering_meta: 'created_at',
    hint: 'Blog posts will be shown in our website under the Blog section',
    inverse_relationships_enabled: false,
    meta: {
    has_singleton_item: false
    },
    singleton_item: null,
    fields: [
    {
    type: 'field',
    id: '124'
    }
    ],
    fieldsets: [
    {
    type: 'fieldset',
    id: '124'
    }
    ],
    title_field: null,
    image_preview_field: null,
    excerpt_field: null,
    ordering_field: null,
    workflow: null
    }