menu Createmutation
mutation
2025-01release candidate
Requires
write_online_store_navigation
access scope.
Creates a menu.
Arguments
The menus's handle.
List of the menus' items.
The menu's title.
Was this section helpful?
MenuCreatePayload returns
The created menu.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Examples
Hide code
DescriptionCopy
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();
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)
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": [ ] } ] }, }, });
use Shopify\Clients\Graphql; $client = new Graphql("your-development-store.myshopify.com", $accessToken); $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]);
Hide code
Input variables
Copy
{ "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": [] } ] }
Hide code
Response
JSON
{ "menuCreate": { "menu": null } }