Version: unstable
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createCollectionMetafields($input: CollectionInput!) { collectionCreate(input: $input) { collection { id metafields(first: 3) { edges { node { id namespace key value } } } } userErrors { message field } } }\",\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"subtitle\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Bold Colors\"\n }\n ],\n \"title\": \"Spring Styles\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createCollectionMetafields($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"subtitle\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Bold Colors\"\n }\n ],\n \"title\": \"Spring Styles\"\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 createCollectionMetafields($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"metafields\": [{\"namespace\"=>\"my_field\", \"key\"=>\"subtitle\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Bold Colors\"}],\n \"title\": \"Spring Styles\"\n }\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 = <<[\n \"metafields\" => [{\"namespace\"=>\"my_field\", \"key\"=>\"subtitle\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Bold Colors\"}],\n \"title\" => \"Spring Styles\",\n ],\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 createCollectionMetafields($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"subtitle\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Bold Colors\"\n }\n ],\n \"title\": \"Spring Styles\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createCollectionMetafields($input: CollectionInput!) {\n collectionCreate(input: $input) {\n collection {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}"
input: { "input": { "metafields": [ { "namespace": "my_field", "key": "subtitle", "type": "single_line_text_field", "value": "Bold Colors" } ], "title": "Spring Styles" } }
response: { "data": { "collectionCreate": { "collection": { "id": "gid://shopify/Collection/1063001321", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069229258", "namespace": "my_field", "key": "subtitle", "value": "Bold Colors" } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CollectionCreate($input: CollectionInput!) { collectionCreate(input: $input) { userErrors { field message } collection { id title descriptionHtml handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition } } } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Our entire shoe collection\",\n \"descriptionHtml\": \"View every shoe available in our store.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": {\n \"column\": \"TITLE\",\n \"relation\": \"CONTAINS\",\n \"condition\": \"shoe\"\n }\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Our entire shoe collection\",\n \"descriptionHtml\": \"View every shoe available in our store.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": {\n \"column\": \"TITLE\",\n \"relation\": \"CONTAINS\",\n \"condition\": \"shoe\"\n }\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 CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Our entire shoe collection\",\n \"descriptionHtml\": \"View every shoe available in our store.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": {\n \"column\": \"TITLE\",\n \"relation\": \"CONTAINS\",\n \"condition\": \"shoe\"\n }\n }\n }\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 = <<[\n \"title\" => \"Our entire shoe collection\",\n \"descriptionHtml\" => \"View every shoe available in our store.\",\n \"ruleSet\" => [\n \"appliedDisjunctively\" => false,\n \"rules\" => [\n \"column\" => \"TITLE\",\n \"relation\" => \"CONTAINS\",\n \"condition\" => \"shoe\",\n ],\n ],\n ],\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 CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Our entire shoe collection\",\n \"descriptionHtml\": \"View every shoe available in our store.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": {\n \"column\": \"TITLE\",\n \"relation\": \"CONTAINS\",\n \"condition\": \"shoe\"\n }\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n }\n }\n }\n }\n}"
input: { "input": { "title": "Our entire shoe collection", "descriptionHtml": "View every shoe available in our store.", "ruleSet": { "appliedDisjunctively": false, "rules": { "column": "TITLE", "relation": "CONTAINS", "condition": "shoe" } } } }
response: { "data": { "collectionCreate": { "userErrors": [], "collection": { "id": "gid://shopify/Collection/1063001320", "title": "Our entire shoe collection", "descriptionHtml": "View every shoe available in our store.", "handle": "our-entire-shoe-collection", "sortOrder": "BEST_SELLING", "ruleSet": { "appliedDisjunctively": false, "rules": [ { "column": "TITLE", "relation": "CONTAINS", "condition": "shoe" } ] } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation CollectionCreate($input: CollectionInput!) { collectionCreate(input: $input) { userErrors { field message } collection { id title descriptionHtml handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition conditionObject { ... on CollectionRuleMetafieldCondition { metafieldDefinition { id name type { name } ownerType } } } } } } } }\",\n \"variables\": {\n \"input\": {\n \"title\": \"Our entire leather collection\",\n \"descriptionHtml\": \"Check out our leather products.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": [\n {\n \"column\": \"PRODUCT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"leather\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456244\"\n },\n {\n \"column\": \"VARIANT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"true\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456245\"\n }\n ]\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n conditionObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n type {\n name\n }\n ownerType\n }\n }\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"title\": \"Our entire leather collection\",\n \"descriptionHtml\": \"Check out our leather products.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": [\n {\n \"column\": \"PRODUCT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"leather\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456244\"\n },\n {\n \"column\": \"VARIANT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"true\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456245\"\n }\n ]\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 CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n conditionObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n type {\n name\n }\n ownerType\n }\n }\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"title\": \"Our entire leather collection\",\n \"descriptionHtml\": \"Check out our leather products.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": [{\"column\"=>\"PRODUCT_METAFIELD_DEFINITION\", \"relation\"=>\"EQUALS\", \"condition\"=>\"leather\", \"conditionObjectId\"=>\"gid://shopify/MetafieldDefinition/1071456244\"}, {\"column\"=>\"VARIANT_METAFIELD_DEFINITION\", \"relation\"=>\"EQUALS\", \"condition\"=>\"true\", \"conditionObjectId\"=>\"gid://shopify/MetafieldDefinition/1071456245\"}]\n }\n }\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 = <<[\n \"title\" => \"Our entire leather collection\",\n \"descriptionHtml\" => \"Check out our leather products.\",\n \"ruleSet\" => [\n \"appliedDisjunctively\" => false,\n \"rules\" => [{\"column\"=>\"PRODUCT_METAFIELD_DEFINITION\", \"relation\"=>\"EQUALS\", \"condition\"=>\"leather\", \"conditionObjectId\"=>\"gid://shopify/MetafieldDefinition/1071456244\"}, {\"column\"=>\"VARIANT_METAFIELD_DEFINITION\", \"relation\"=>\"EQUALS\", \"condition\"=>\"true\", \"conditionObjectId\"=>\"gid://shopify/MetafieldDefinition/1071456245\"}],\n ],\n ],\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 CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n conditionObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n type {\n name\n }\n ownerType\n }\n }\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"title\": \"Our entire leather collection\",\n \"descriptionHtml\": \"Check out our leather products.\",\n \"ruleSet\": {\n \"appliedDisjunctively\": false,\n \"rules\": [\n {\n \"column\": \"PRODUCT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"leather\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456244\"\n },\n {\n \"column\": \"VARIANT_METAFIELD_DEFINITION\",\n \"relation\": \"EQUALS\",\n \"condition\": \"true\",\n \"conditionObjectId\": \"gid://shopify/MetafieldDefinition/1071456245\"\n }\n ]\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation CollectionCreate($input: CollectionInput!) {\n collectionCreate(input: $input) {\n userErrors {\n field\n message\n }\n collection {\n id\n title\n descriptionHtml\n handle\n sortOrder\n ruleSet {\n appliedDisjunctively\n rules {\n column\n relation\n condition\n conditionObject {\n ... on CollectionRuleMetafieldCondition {\n metafieldDefinition {\n id\n name\n type {\n name\n }\n ownerType\n }\n }\n }\n }\n }\n }\n }\n}"
input: { "input": { "title": "Our entire leather collection", "descriptionHtml": "Check out our leather products.", "ruleSet": { "appliedDisjunctively": false, "rules": [ { "column": "PRODUCT_METAFIELD_DEFINITION", "relation": "EQUALS", "condition": "leather", "conditionObjectId": "gid://shopify/MetafieldDefinition/1071456244" }, { "column": "VARIANT_METAFIELD_DEFINITION", "relation": "EQUALS", "condition": "true", "conditionObjectId": "gid://shopify/MetafieldDefinition/1071456245" } ] } } }
response: { "data": { "collectionCreate": { "userErrors": [], "collection": { "id": "gid://shopify/Collection/1063001322", "title": "Our entire leather collection", "descriptionHtml": "Check out our leather products.", "handle": "our-entire-leather-collection", "sortOrder": "BEST_SELLING", "ruleSet": { "appliedDisjunctively": false, "rules": [ { "column": "PRODUCT_METAFIELD_DEFINITION", "relation": "EQUALS", "condition": "leather", "conditionObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/1071456244", "name": "Material", "type": { "name": "single_line_text_field" }, "ownerType": "PRODUCT" } } }, { "column": "VARIANT_METAFIELD_DEFINITION", "relation": "EQUALS", "condition": "true", "conditionObject": { "metafieldDefinition": { "id": "gid://shopify/MetafieldDefinition/1071456245", "name": "Imported", "type": { "name": "boolean" }, "ownerType": "PRODUCTVARIANT" } } } ] } } } } }