Version: 2024-10
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } } } }\",\n \"variables\": {\n \"title\": \"Sidebar\",\n \"handle\": \"sidebar\",\n \"items\": [\n {\n \"title\": \"Collections\",\n \"type\": \"COLLECTION\",\n \"url\": \"/collection\",\n \"items\": [\n {\n \"title\": \"Bestsellers\",\n \"type\": \"COLLECTION\",\n \"resourceId\": \"gid://shopify/Collection/1007901140\",\n \"url\": \"/collection/bestsellers/new\",\n \"tags\": [\n \"new\"\n ],\n \"items\": []\n }\n ]\n },\n {\n \"title\": \"Products\",\n \"type\": \"CATALOG\",\n \"url\": \"/collections/all\",\n \"items\": []\n },\n {\n \"title\": \"About us\",\n \"type\": \"PAGE\",\n \"resourceId\": \"gid://shopify/Page/905192165\",\n \"url\": \"/pages/about-us\",\n \"items\": []\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {\n menuCreate(title: $title, handle: $handle, items: $items) {\n menu {\n id\n handle\n items {\n id\n title\n items {\n id\n title\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"title\": \"Sidebar\",\n \"handle\": \"sidebar\",\n \"items\": [\n {\n \"title\": \"Collections\",\n \"type\": \"COLLECTION\",\n \"url\": \"/collection\",\n \"items\": [\n {\n \"title\": \"Bestsellers\",\n \"type\": \"COLLECTION\",\n \"resourceId\": \"gid://shopify/Collection/1007901140\",\n \"url\": \"/collection/bestsellers/new\",\n \"tags\": [\n \"new\"\n ],\n \"items\": []\n }\n ]\n },\n {\n \"title\": \"Products\",\n \"type\": \"CATALOG\",\n \"url\": \"/collections/all\",\n \"items\": []\n },\n {\n \"title\": \"About us\",\n \"type\": \"PAGE\",\n \"resourceId\": \"gid://shopify/Page/905192165\",\n \"url\": \"/pages/about-us\",\n \"items\": []\n }\n ]\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {\n menuCreate(title: $title, handle: $handle, items: $items) {\n menu {\n id\n handle\n items {\n id\n title\n items {\n id\n title\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"title\": \"Sidebar\",\n \"handle\": \"sidebar\",\n \"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\"=>[]}]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {\n menuCreate(title: $title, handle: $handle, items: $items) {\n menu {\n id\n handle\n items {\n id\n title\n items {\n id\n title\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"title\" => \"Sidebar\",\n \"handle\" => \"sidebar\",\n \"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\"=>[]}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {\n menuCreate(title: $title, handle: $handle, items: $items) {\n menu {\n id\n handle\n items {\n id\n title\n items {\n id\n title\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"title\": \"Sidebar\",\n \"handle\": \"sidebar\",\n \"items\": [\n {\n \"title\": \"Collections\",\n \"type\": \"COLLECTION\",\n \"url\": \"/collection\",\n \"items\": [\n {\n \"title\": \"Bestsellers\",\n \"type\": \"COLLECTION\",\n \"resourceId\": \"gid://shopify/Collection/1007901140\",\n \"url\": \"/collection/bestsellers/new\",\n \"tags\": [\n \"new\"\n ],\n \"items\": []\n }\n ]\n },\n {\n \"title\": \"Products\",\n \"type\": \"CATALOG\",\n \"url\": \"/collections/all\",\n \"items\": []\n },\n {\n \"title\": \"About us\",\n \"type\": \"PAGE\",\n \"resourceId\": \"gid://shopify/Page/905192165\",\n \"url\": \"/pages/about-us\",\n \"items\": []\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) {\n menuCreate(title: $title, handle: $handle, items: $items) {\n menu {\n id\n handle\n items {\n id\n title\n items {\n id\n title\n }\n }\n }\n }\n}"
input: { "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: { "data": { "menuCreate": { "menu": null } } }