Anchor to menuCreatemenu
menuCreate
mutation
Requires access scope.
Creates a menu.
Anchor to Arguments
Arguments
- Anchor to handlehandle•String!required
The menu's handle.
- Anchor to itemsitems•[Menu
Item requiredCreate Input!]! List of the menu's items.
- Anchor to titletitle•String!required
The menu's title.
Was this section helpful?
Anchor to MenuCreatePayload returnsMenuCreatePayload returns
- Anchor to menumenu•
The created menu.
- Anchor to userErrorsuser•
Errors [MenuCreate non-nullUser Error!]! The list of errors that occurred from executing the mutation.
Was this section helpful?
- Create a menu
- menuCreate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {
menuCreate(title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}`,
{
variables: {
"title": "Sidebar",
"handle": "sidebar",
"items": [
{
"title": "Collections",
"type": "COLLECTION",
"url": "/collection",
mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {
menuCreate(title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) { menuCreate(title: $title, handle: $handle, items: $items) { menu { id handle items { id title items { id title } } } } }",
"variables": {
"title": "Sidebar",
"handle": "sidebar",
"items": [
{
"title": "Collections",
"type": "COLLECTION",
"url": "/collection",
"items": [
{
"title": "Bestsellers",
"type": "COLLECTION",
"resourceId": "gid://shopify/Collection/1007901140",
"url": "/collection/bestsellers/new",
"tags": [
"new"
],
"items": []
}
]
},
{
"title": "Products",
"type": "CATALOG",
"url": "/collections/all",
"items": []
},
{
"title": "About us",
"type": "PAGE",
"resourceId": "gid://shopify/Page/905192165",
"url": "/pages/about-us",
"items": []
}
]
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {
menuCreate(title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}`,
{
variables: {
"title": "Sidebar",
"handle": "sidebar",
"items": [
{
"title": "Collections",
"type": "COLLECTION",
"url": "/collection",
"items": [
{
"title": "Bestsellers",
"type": "COLLECTION",
"resourceId": "gid://shopify/Collection/1007901140",
"url": "/collection/bestsellers/new",
"tags": [
"new"
],
"items": []
}
]
},
{
"title": "Products",
"type": "CATALOG",
"url": "/collections/all",
"items": []
},
{
"title": "About us",
"type": "PAGE",
"resourceId": "gid://shopify/Page/905192165",
"url": "/pages/about-us",
"items": []
}
]
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {
menuCreate(title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}`,
"variables": {
"title": "Sidebar",
"handle": "sidebar",
"items": [
{
"title": "Collections",
"type": "COLLECTION",
"url": "/collection",
"items": [
{
"title": "Bestsellers",
"type": "COLLECTION",
"resourceId": "gid://shopify/Collection/1007901140",
"url": "/collection/bestsellers/new",
"tags": [
"new"
],
"items": []
}
]
},
{
"title": "Products",
"type": "CATALOG",
"url": "/collections/all",
"items": []
},
{
"title": "About us",
"type": "PAGE",
"resourceId": "gid://shopify/Page/905192165",
"url": "/pages/about-us",
"items": []
}
]
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {
menuCreate(title: $title, handle: $handle, items: $items) {
menu {
id
handle
items {
id
title
items {
id
title
}
}
}
}
}
QUERY
variables = {
"title": "Sidebar",
"handle": "sidebar",
"items": [{"title"=>"Collections", "type"=>"COLLECTION", "url"=>"/collection", "items"=>[{"title"=>"Bestsellers", "type"=>"COLLECTION", "resourceId"=>"gid://shopify/Collection/1007901140", "url"=>"/collection/bestsellers/new", "tags"=>["new"], "items"=>[]}]}, {"title"=>"Products", "type"=>"CATALOG", "url"=>"/collections/all", "items"=>[]}, {"title"=>"About us", "type"=>"PAGE", "resourceId"=>"gid://shopify/Page/905192165", "url"=>"/pages/about-us", "items"=>[]}]
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"title": "Sidebar",
"handle": "sidebar",
"items": [
{
"title": "Collections",
"type": "COLLECTION",
"url": "/collection",
"items": [
{
"title": "Bestsellers",
"type": "COLLECTION",
"resourceId": "gid://shopify/Collection/1007901140",
"url": "/collection/bestsellers/new",
"tags": [
"new"
],
"items": []
}
]
},
{
"title": "Products",
"type": "CATALOG",
"url": "/collections/all",
"items": []
},
{
"title": "About us",
"type": "PAGE",
Response
JSON{
"menuCreate": {
"menu": null
}
}