Show examples in:
    Create a new menu item

    Parameters

    id  string  Optional
    RFC 4122 UUID of menu item expressed in URL-safe base64 format
    label  Required  string  Example: "Posts"

    The label of the menu item

    external_url  Optional  null, string

    The URL to which the menu item points to

    position  Optional  integer  Example: 1

    Ordering index

    open_in_new_tab  Optional  boolean  Example: true

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

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

    Item type associated with the menu item

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

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

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

    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({
    id: 'uinr2zfqQLeCo_1O0-ao-Q',
    label: 'Posts',
    external_url: '',
    position: 1,
    open_in_new_tab: true,
    item_type: {
    type: 'item_type',
    id: 'DxMaW10UQiCmZcuuA-IkkA'
    },
    item_type_filter: {
    type: 'item_type_filter',
    id: 'FF-P5of6Qp-DD2w0xoaa6Q'
    },
    parent: null
    });
    console.log(menuItem);
    }
    run();
    Returned output:
    {
    id: 'uinr2zfqQLeCo_1O0-ao-Q',
    label: 'Posts',
    external_url: '',
    position: 1,
    open_in_new_tab: true,
    item_type: {
    type: 'item_type',
    id: 'DxMaW10UQiCmZcuuA-IkkA'
    },
    item_type_filter: {
    type: 'item_type_filter',
    id: 'FF-P5of6Qp-DD2w0xoaa6Q'
    },
    parent: null,
    children: [
    {
    type: 'menu_item',
    id: 'uinr2zfqQLeCo_1O0-ao-Q'
    }
    ]
    }