Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation updateCustomerMetafields($input: CustomerInput!) { customerUpdate(input: $input) { customer { 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\": \"nickname\",\n \"type\": \"single_line_text_field\",\n \"value\": \"rob\"\n },\n {\n \"id\": \"gid://shopify/Metafield/1069230189\",\n \"value\": \"they/them\"\n }\n ],\n \"id\": \"gid://shopify/Customer/1018520244\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateCustomerMetafields($input: CustomerInput!) {\n customerUpdate(input: $input) {\n customer {\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\": \"nickname\",\n \"type\": \"single_line_text_field\",\n \"value\": \"rob\"\n },\n {\n \"id\": \"gid://shopify/Metafield/1069230189\",\n \"value\": \"they/them\"\n }\n ],\n \"id\": \"gid://shopify/Customer/1018520244\"\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 updateCustomerMetafields($input: CustomerInput!) {\n customerUpdate(input: $input) {\n customer {\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\"=>\"nickname\", \"type\"=>\"single_line_text_field\", \"value\"=>\"rob\"}, {\"id\"=>\"gid://shopify/Metafield/1069230189\", \"value\"=>\"they/them\"}],\n \"id\": \"gid://shopify/Customer/1018520244\"\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 = <<<QUERY\n mutation updateCustomerMetafields($input: CustomerInput!) {\n customerUpdate(input: $input) {\n customer {\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\n$variables = [\n \"input\" => [\n \"metafields\" => [{\"namespace\"=>\"my_field\", \"key\"=>\"nickname\", \"type\"=>\"single_line_text_field\", \"value\"=>\"rob\"}, {\"id\"=>\"gid://shopify/Metafield/1069230189\", \"value\"=>\"they/them\"}],\n \"id\" => \"gid://shopify/Customer/1018520244\",\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 updateCustomerMetafields($input: CustomerInput!) {\n customerUpdate(input: $input) {\n customer {\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\": \"nickname\",\n \"type\": \"single_line_text_field\",\n \"value\": \"rob\"\n },\n {\n \"id\": \"gid://shopify/Metafield/1069230189\",\n \"value\": \"they/them\"\n }\n ],\n \"id\": \"gid://shopify/Customer/1018520244\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateCustomerMetafields($input: CustomerInput!) {\n customerUpdate(input: $input) {\n customer {\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": "nickname", "type": "single_line_text_field", "value": "rob" }, { "id": "gid://shopify/Metafield/1069230189", "value": "they/them" } ], "id": "gid://shopify/Customer/1018520244" } }
response: { "data": { "customerUpdate": { "customer": { "id": "gid://shopify/Customer/1018520244", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069230189", "namespace": "my_field", "key": "pronouns", "value": "they/them" } }, { "node": { "id": "gid://shopify/Metafield/1069230190", "namespace": "my_field", "key": "nickname", "value": "rob" } } ] } }, "userErrors": [] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation customerUpdate($input: CustomerInput!) { customerUpdate(input: $input) { userErrors { field message } customer { id firstName } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Customer/1\",\n \"firstName\": \"Tobi\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Customer/1\",\n \"firstName\": \"Tobi\"\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 customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Customer/1\",\n \"firstName\": \"Tobi\"\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 = <<<QUERY\n mutation customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/Customer/1\",\n \"firstName\" => \"Tobi\",\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 customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Customer/1\",\n \"firstName\": \"Tobi\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n }\n }\n}"
input: { "input": { "id": "gid://shopify/Customer/1", "firstName": "Tobi" } }
response: { "data": { "customerUpdate": { "userErrors": [ { "field": [ "id" ], "message": "Customer does not exist" } ], "customer": null } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation customerUpdate($input: CustomerInput!) { customerUpdate(input: $input) { userErrors { field message } customer { id firstName lastName } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Customer/1018520244\",\n \"firstName\": \"Tobi\",\n \"lastName\": \"Lutke\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n lastName\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Customer/1018520244\",\n \"firstName\": \"Tobi\",\n \"lastName\": \"Lutke\"\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 customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n lastName\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Customer/1018520244\",\n \"firstName\": \"Tobi\",\n \"lastName\": \"Lutke\"\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 = <<<QUERY\n mutation customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n lastName\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"id\" => \"gid://shopify/Customer/1018520244\",\n \"firstName\" => \"Tobi\",\n \"lastName\" => \"Lutke\",\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 customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n lastName\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Customer/1018520244\",\n \"firstName\": \"Tobi\",\n \"lastName\": \"Lutke\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation customerUpdate($input: CustomerInput!) {\n customerUpdate(input: $input) {\n userErrors {\n field\n message\n }\n customer {\n id\n firstName\n lastName\n }\n }\n}"
input: { "input": { "id": "gid://shopify/Customer/1018520244", "firstName": "Tobi", "lastName": "Lutke" } }
response: { "data": { "customerUpdate": { "userErrors": [], "customer": { "id": "gid://shopify/Customer/1018520244", "firstName": "Tobi", "lastName": "Lutke" } } } }