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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { key namespace value createdAt updatedAt } userErrors { field message code } } }\",\n \"variables\": {\n \"metafields\": [\n {\n \"key\": \"example_key\",\n \"namespace\": \"example_namespace\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Example Value\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"metafields\": [\n {\n \"key\": \"example_key\",\n \"namespace\": \"example_namespace\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Example Value\"\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"metafields\": [{\"key\"=>\"example_key\", \"namespace\"=>\"example_namespace\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Example Value\"}]\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"metafields\" => [{\"key\"=>\"example_key\", \"namespace\"=>\"example_namespace\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Example Value\"}],\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"metafields\": [\n {\n \"key\": \"example_key\",\n \"namespace\": \"example_namespace\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Example Value\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n}"
input: { "metafields": [ { "key": "example_key", "namespace": "example_namespace", "ownerId": "gid://shopify/Product/20995642", "type": "single_line_text_field", "value": "Example Value" } ] }
response: { "data": { "metafieldsSet": { "metafields": [ { "key": "example_key", "namespace": "example_namespace", "value": "Example Value", "createdAt": "2024-11-18T21:40:28Z", "updatedAt": "2024-11-18T21:40:28Z" } ], "userErrors": [] } } }
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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { key namespace value createdAt updatedAt } userErrors { field message code } } }\",\n \"variables\": {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\"\n },\n {\n \"key\": \"manufactured\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Made in Canada\"\n },\n {\n \"key\": \"product_description\",\n \"namespace\": \"custom\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"rich_text_field\",\n \"value\": \"{\\\"type\\\":\\\"root\\\",\\\"children\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"This is italicized text and \\\",\\\"italic\\\":true},{\\\"url\\\":\\\"https:\\\\/\\\\/example.com\\\",\\\"title\\\":\\\"Link to example.com\\\",\\\"type\\\":\\\"link\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"a bolded hyperlink\\\",\\\"bold\\\":true}]}]}]}\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\"\n },\n {\n \"key\": \"manufactured\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Made in Canada\"\n },\n {\n \"key\": \"product_description\",\n \"namespace\": \"custom\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"rich_text_field\",\n \"value\": \"{\\\"type\\\":\\\"root\\\",\\\"children\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"This is italicized text and \\\",\\\"italic\\\":true},{\\\"url\\\":\\\"https:\\\\/\\\\/example.com\\\",\\\"title\\\":\\\"Link to example.com\\\",\\\"type\\\":\\\"link\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"a bolded hyperlink\\\",\\\"bold\\\":true}]}]}]}\"\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"metafields\": [{\"key\"=>\"materials\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"multi_line_text_field\", \"value\"=>\"95% Cotton\\n5% Spandex\"}, {\"key\"=>\"manufactured\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Made in Canada\"}, {\"key\"=>\"product_description\", \"namespace\"=>\"custom\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"rich_text_field\", \"value\"=>\"{\\\"type\\\":\\\"root\\\",\\\"children\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"This is italicized text and \\\",\\\"italic\\\":true},{\\\"url\\\":\\\"https:\\\\/\\\\/example.com\\\",\\\"title\\\":\\\"Link to example.com\\\",\\\"type\\\":\\\"link\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"a bolded hyperlink\\\",\\\"bold\\\":true}]}]}]}\"}]\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"metafields\" => [{\"key\"=>\"materials\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"multi_line_text_field\", \"value\"=>\"95% Cotton\\n5% Spandex\"}, {\"key\"=>\"manufactured\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Made in Canada\"}, {\"key\"=>\"product_description\", \"namespace\"=>\"custom\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"rich_text_field\", \"value\"=>\"{\\\"type\\\":\\\"root\\\",\\\"children\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"This is italicized text and \\\",\\\"italic\\\":true},{\\\"url\\\":\\\"https:\\\\/\\\\/example.com\\\",\\\"title\\\":\\\"Link to example.com\\\",\\\"type\\\":\\\"link\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"a bolded hyperlink\\\",\\\"bold\\\":true}]}]}]}\"}],\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\"\n },\n {\n \"key\": \"manufactured\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Made in Canada\"\n },\n {\n \"key\": \"product_description\",\n \"namespace\": \"custom\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"rich_text_field\",\n \"value\": \"{\\\"type\\\":\\\"root\\\",\\\"children\\\":[{\\\"type\\\":\\\"paragraph\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"This is italicized text and \\\",\\\"italic\\\":true},{\\\"url\\\":\\\"https:\\\\/\\\\/example.com\\\",\\\"title\\\":\\\"Link to example.com\\\",\\\"type\\\":\\\"link\\\",\\\"children\\\":[{\\\"type\\\":\\\"text\\\",\\\"value\\\":\\\"a bolded hyperlink\\\",\\\"bold\\\":true}]}]}]}\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n}"
input: { "metafields": [ { "key": "materials", "namespace": "my_fields", "ownerId": "gid://shopify/Product/20995642", "type": "multi_line_text_field", "value": "95% Cotton\n5% Spandex" }, { "key": "manufactured", "namespace": "my_fields", "ownerId": "gid://shopify/Product/20995642", "type": "single_line_text_field", "value": "Made in Canada" }, { "key": "product_description", "namespace": "custom", "ownerId": "gid://shopify/Product/20995642", "type": "rich_text_field", "value": "{\"type\":\"root\",\"children\":[{\"type\":\"paragraph\",\"children\":[{\"type\":\"text\",\"value\":\"This is italicized text and \",\"italic\":true},{\"url\":\"https:\\/\\/example.com\",\"title\":\"Link to example.com\",\"type\":\"link\",\"children\":[{\"type\":\"text\",\"value\":\"a bolded hyperlink\",\"bold\":true}]}]}]}" } ] }
response: { "data": { "metafieldsSet": { "metafields": [ { "key": "materials", "namespace": "my_fields", "value": "95% Cotton\n5% Spandex", "createdAt": "2024-11-13T20:04:12Z", "updatedAt": "2024-11-13T20:04:13Z" }, { "key": "manufactured", "namespace": "my_fields", "value": "Made in Canada", "createdAt": "2024-11-13T20:04:13Z", "updatedAt": "2024-11-13T20:04:13Z" }, { "key": "product_description", "namespace": "custom", "value": "{\"type\":\"root\",\"children\":[{\"type\":\"paragraph\",\"children\":[{\"type\":\"text\",\"value\":\"This is italicized text and \",\"italic\":true},{\"url\":\"https://example.com\",\"title\":\"Link to example.com\",\"type\":\"link\",\"children\":[{\"type\":\"text\",\"value\":\"a bolded hyperlink\",\"bold\":true}]}]}]}", "createdAt": "2024-11-13T20:04:13Z", "updatedAt": "2024-11-13T20:04:13Z" } ], "userErrors": [] } } }
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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { key namespace value compareDigest createdAt updatedAt } userErrors { field message code } } }\",\n \"variables\": {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\",\n \"compareDigest\": \"fd6b73725c9e83da2d2bcfaf90b27305b9058a48a1565639aa00d718d4caf8e8\"\n },\n {\n \"key\": \"manufactured\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Made in Canada\",\n \"compareDigest\": null\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n compareDigest\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\",\n \"compareDigest\": \"fd6b73725c9e83da2d2bcfaf90b27305b9058a48a1565639aa00d718d4caf8e8\"\n },\n {\n \"key\": \"manufactured\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Made in Canada\",\n \"compareDigest\": null\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n compareDigest\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"metafields\": [{\"key\"=>\"materials\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"multi_line_text_field\", \"value\"=>\"95% Cotton\\n5% Spandex\", \"compareDigest\"=>\"fd6b73725c9e83da2d2bcfaf90b27305b9058a48a1565639aa00d718d4caf8e8\"}, {\"key\"=>\"manufactured\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Made in Canada\", \"compareDigest\"=>nil}]\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n compareDigest\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"metafields\" => [{\"key\"=>\"materials\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"multi_line_text_field\", \"value\"=>\"95% Cotton\\n5% Spandex\", \"compareDigest\"=>\"fd6b73725c9e83da2d2bcfaf90b27305b9058a48a1565639aa00d718d4caf8e8\"}, {\"key\"=>\"manufactured\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"single_line_text_field\", \"value\"=>\"Made in Canada\", \"compareDigest\"=>nil}],\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n compareDigest\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\",\n \"compareDigest\": \"fd6b73725c9e83da2d2bcfaf90b27305b9058a48a1565639aa00d718d4caf8e8\"\n },\n {\n \"key\": \"manufactured\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"single_line_text_field\",\n \"value\": \"Made in Canada\",\n \"compareDigest\": null\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n compareDigest\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n}"
input: { "metafields": [ { "key": "materials", "namespace": "my_fields", "ownerId": "gid://shopify/Product/20995642", "type": "multi_line_text_field", "value": "95% Cotton\n5% Spandex", "compareDigest": "fd6b73725c9e83da2d2bcfaf90b27305b9058a48a1565639aa00d718d4caf8e8" }, { "key": "manufactured", "namespace": "my_fields", "ownerId": "gid://shopify/Product/20995642", "type": "single_line_text_field", "value": "Made in Canada", "compareDigest": null } ] }
response: { "data": { "metafieldsSet": { "metafields": [ { "key": "materials", "namespace": "my_fields", "value": "95% Cotton\n5% Spandex", "compareDigest": "8164fa2a8e66a6bb54181ac0c095375c701ae276e801f43efa16ea7be516f678", "createdAt": "2024-11-13T20:03:43Z", "updatedAt": "2024-11-13T20:04:12Z" }, { "key": "manufactured", "namespace": "my_fields", "value": "Made in Canada", "compareDigest": "f8c307f7c79ec624884e1c71640ee3e6441cf7bb4589b9e3cc551ab3e3b95ff1", "createdAt": "2024-11-13T20:04:12Z", "updatedAt": "2024-11-13T20:04:12Z" } ], "userErrors": [] } } }
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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) { metafieldsSet(metafields: $metafields) { metafields { key namespace value createdAt updatedAt } userErrors { field message code } } }\",\n \"variables\": {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n \"variables\": {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\"\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY\n\nvariables = {\n \"metafields\": [{\"key\"=>\"materials\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"multi_line_text_field\", \"value\"=>\"95% Cotton\\n5% Spandex\"}]\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }\nQUERY;\n\n$variables = [\n \"metafields\" => [{\"key\"=>\"materials\", \"namespace\"=>\"my_fields\", \"ownerId\"=>\"gid://shopify/Product/20995642\", \"type\"=>\"multi_line_text_field\", \"value\"=>\"95% Cotton\\n5% Spandex\"}],\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 MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n }`,\n {\n variables: {\n \"metafields\": [\n {\n \"key\": \"materials\",\n \"namespace\": \"my_fields\",\n \"ownerId\": \"gid://shopify/Product/20995642\",\n \"type\": \"multi_line_text_field\",\n \"value\": \"95% Cotton\\n5% Spandex\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation MetafieldsSet($metafields: [MetafieldsSetInput!]!) {\n metafieldsSet(metafields: $metafields) {\n metafields {\n key\n namespace\n value\n createdAt\n updatedAt\n }\n userErrors {\n field\n message\n code\n }\n }\n}"
input: { "metafields": [ { "key": "materials", "namespace": "my_fields", "ownerId": "gid://shopify/Product/20995642", "type": "multi_line_text_field", "value": "95% Cotton\n5% Spandex" } ] }
response: { "data": { "metafieldsSet": { "metafields": [ { "key": "materials", "namespace": "my_fields", "value": "95% Cotton\n5% Spandex", "createdAt": "2024-11-18T21:40:55Z", "updatedAt": "2024-11-18T21:40:55Z" } ], "userErrors": [] } } }