Choose your language:
    Create a new menu item
    Parameters
    label  string  Optional

    The label of the menu item

    position  integer  Optional

    Ordering index

    externalUrl  null, string  Optional

    The URL to which the menu item points to

    openInNewTab  boolean  Optional

    Opens link in new tab (used together with external_url)

    itemType  item_type.id, null  Optional

    item type associated with the menu item

    parent  null, menu_item.id  Optional

    Parent menu item

    Returns
    Returns a menu_item object.

    Examples

    Example code:
    const SiteClient = require('datocms-client').SiteClient;
    const client = new SiteClient('YOUR-API-TOKEN');
    client.menuItem.create({
    label: 'Posts',
    externalUrl: '',
    position: 1,
    openInNewTab: true,
    itemType: '44',
    parent: null
    })
    .then((menuItem) => {
    console.log(menuItem);
    })
    .catch((error) => {
    console.error(error);
    });
    Returned output:
    > node example.js
    {
    "id": "34",
    "label": "Posts",
    "externalUrl": "",
    "position": 1,
    "openInNewTab": true,
    "itemType": "44",
    "parent": null,
    "children": [
    "34"
    ]
    }