Create a menu
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/menus';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"name":"Header Navigation","ref":"header-menu","menu_items":[{"label":"Electronics","parent_id":1,"entity_type":"category","entity_id":"123","custom_url":"https://example.com","target":"_self","children":[]}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://apibase.ecomweb.app/api/v1/stores/example/menus \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "name": "Header Navigation", "ref": "header-menu", "menu_items": [ { "label": "Electronics", "parent_id": 1, "entity_type": "category", "entity_id": "123", "custom_url": "https://example.com", "target": "_self", "children": [] } ] }'Creates a navigation menu, optionally with its items. Items can be nested to any depth through children. The ref must be unique within the store.
Required scopes: write:menus
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Menu name
Example
Header NavigationMenu reference for code usage (unique per store)
Example
header-menuMenu items with nested structure
object
Menu item label
Example
ElectronicsParent menu item ID for nesting
Example
1Entity type: product, category, collection, blog_post, blog_category, content_page, search, home, orders, profile, custom
Example
categoryEntity ID (referenced entity)
Example
123Custom URL for external links
Example
https://example.comLink target: _self, _blank, _parent, _top
Example
_selfResponses
Section titled “Responses”object
When the menu was deleted. Always null on menus you can read.
The menu’s top-level items, each with its nested children. Present only when items are included in the response.
object
ID of the parent item, or null for a top-level item.
What the link points at: product, category, collection, blog_post, blog_category, content_page, search, home, orders, profile or custom. Null for a plain URL.
ID of the referenced record, as a string. Null when the link has no target record.
Slug of the referenced record. Filled in for product, collection, blog_post, blog_category and content_page links; absent otherwise.
URL for external or custom links. Null when the link points at a record.
How the link opens: _self, _blank, _parent or _top.
Description of the referenced record, filled in together with entity_slug.
Item ID.
ID of the menu the item belongs to.
Text shown for the link.
When the item was created, as an ISO 8601 timestamp.
When the item was last updated, as an ISO 8601 timestamp.
Menu ID.
Menu name.
Reference used to look the menu up, unique within the store, such as header-menu.
When the menu was created, as an ISO 8601 timestamp.
When the menu was last updated, as an ISO 8601 timestamp.
Example generated
{ "deleted_at": "example", "menu_items": [ { "parent_id": 1, "entity_type": "example", "entity_id": "example", "entity_slug": "example", "custom_url": "example", "target": "example", "children": [], "description": "example", "id": 1, "menu_id": 1, "label": "example", "created_at": "example", "updated_at": "example" } ], "id": 1, "name": "example", "ref": "example", "created_at": "example", "updated_at": "example"}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}