Sorry, no results found for "".

Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Menu Item

Create a new menu item

Body parameters

id string Optional

RFC 4122 UUID of menu item expressed in URL-safe base64 format

Example: "uinr2zfqQLeCo_1O0-ao-Q"
type string Required

Must be exactly "menu_item".

attributes.label string Required

The label of the menu item

Example: "Posts"
attributes.external_url null, string Optional

The URL to which the menu item points to

attributes.position integer Optional

Ordering index

Example: 1
attributes.open_in_new_tab boolean Optional

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

relationships.item_type.data Optional

Item type associated with the menu item

relationships.item_type_filter.data Optional

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

relationships.parent.data Optional

Parent menu item

Returns

Returns a resource object of type menu_item.

Examples

POST https://site-api.datocms.com/menu-items HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Content-Type: application/vnd.api+json
{
"data": {
"type": "menu_item",
"attributes": {
"label": "Posts"
}
}
}
Terminal window
curl -g 'https://site-api.datocms.com/menu-items' \
-X POST \
-H "Authorization: Bearer YOUR-API-TOKEN" \
-H "Accept: application/json" \
-H "X-Api-Version: 3" \
-H "Content-Type: application/vnd.api+json" \
--data-binary '{"data":{"type":"menu_item","attributes":{"label":"Posts"}}}'
await fetch("https://site-api.datocms.com/menu-items", {
method: "POST",
headers: {
Authorization: "Bearer YOUR-API-TOKEN",
Accept: "application/json",
"X-Api-Version": "3",
"Content-Type": "application/vnd.api+json",
},
body: JSON.stringify({
data: { type: "menu_item", attributes: { label: "Posts" } },
}),
});
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": {
"type": "menu_item",
"id": "uinr2zfqQLeCo_1O0-ao-Q",
"relationships": {
"item_type": {
"data": {
"type": "item_type",
"id": "DxMaW10UQiCmZcuuA-IkkA"
}
},
"item_type_filter": {
"data": {
"type": "item_type_filter",
"id": "FF-P5of6Qp-DD2w0xoaa6Q"
}
},
"parent": {
"data": null
},
"children": {
"data": [
{
"type": "menu_item",
"id": "uinr2zfqQLeCo_1O0-ao-Q"
}
]
}
},
"attributes": {
"label": "Posts",
"position": 1,
"external_url": "",
"open_in_new_tab": true
}
}
}