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:
    Create a new menu item

    Parameters

    label  string  Required

    The label of the menu item

    external_url  null, string  Optional

    The URL to which the menu item points to

    position  integer  Optional

    Ordering index

    open_in_new_tab  boolean  Optional

    Opens link in new tab (to be used together with external_url)

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

    Item type associated with the menu item

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

    Item type filter associated with the menu item (to be used together with item_type relationship)

    parent  null, { type: "menu_item", id: menu_item.id }  Optional

    Parent menu item

    Returns

    Returns a menu_item resource object.

    Examples

    Example code:
    import { buildClient } from '@datocms/cma-client-node';
    async function run() {
    const client = buildClient({ apiToken: '<YOUR_API_TOKEN>' });
    const menuItem = await client.menuItems.create({
    label: 'Posts',
    external_url: '',
    position: 1,
    open_in_new_tab: true,
    item_type: {
    type: 'item_type',
    id: '44'
    },
    item_type_filter: {
    type: 'item_type_filter',
    id: '34'
    },
    parent: null
    });
    console.log(menuItem);
    }
    run();
    Returned output:
    {
    id: '34',
    label: 'Posts',
    external_url: '',
    position: 1,
    open_in_new_tab: true,
    item_type: {
    type: 'item_type',
    id: '44'
    },
    item_type_filter: {
    type: 'item_type_filter',
    id: '34'
    },
    parent: null,
    children: [
    {
    type: 'menu_item',
    id: '34'
    }
    ]
    }