customer Mergemutation
mutation
2024-10latest
Requires write
access scope. Also: User needs merge_customers permission.
Merges two customers.
Arguments
The ID of the first customer that will be merged.
The ID of the second customer that will be merged.
Anchor to overrideFieldsoverrideFieldsThe fields to override the default customer merge rules.
Was this section helpful?
CustomerMergePayload returns
The asynchronous job for merging the customers.
Anchor to CustomerMergePayload.resultingCustomerIdresultingCustomer Id The ID of the customer resulting from the merge.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: customerMerge
Query Reference for MUTATION: customerMerge
"mutation customerMerge($customerOneId: ID!, $customerTwoId: ID!) {\n customerMerge(customerOneId: $customerOneId, customerTwoId: $customerTwoId) {\n job {\n # Job fields\n }\n resultingCustomerId\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: customerMerge
"{\n \"customerOneId\": \"gid://shopify/<objectName>/10079785100\",\n \"customerTwoId\": \"gid://shopify/<objectName>/10079785100\",\n \"overrideFields\": {\n \"customerIdOfDefaultAddressToKeep\": \"gid://shopify/<objectName>/10079785100\",\n \"customerIdOfEmailToKeep\": \"gid://shopify/<objectName>/10079785100\",\n \"customerIdOfFirstNameToKeep\": \"gid://shopify/<objectName>/10079785100\",\n \"customerIdOfLastNameToKeep\": \"gid://shopify/<objectName>/10079785100\",\n \"customerIdOfPhoneNumberToKeep\": \"gid://shopify/<objectName>/10079785100\",\n \"note\": \"<your-note>\",\n \"tags\": [\n \"<your-tags>\"\n ]\n }\n}"
Schema Reference for MUTATION: customerMerge
"input CustomerMergeOverrideFields {\n customerIdOfDefaultAddressToKeep: ID\n customerIdOfEmailToKeep: ID\n customerIdOfFirstNameToKeep: ID\n customerIdOfLastNameToKeep: ID\n customerIdOfPhoneNumberToKeep: ID\n note: String\n tags: [String!]\n}\n"
Display Examples for MUTATION: customerMerge
[ { "example": { "type_name": "customermerge", "title": "Merge customers with override fields", "description": "Merge customers with override fields.\n", "query_string": "mutation CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\", overrideFields: {customerIdOfFirstNameToKeep: \"gid://shopify/Customer/544365967\", customerIdOfLastNameToKeep: \"gid://shopify/Customer/624407574\"}) {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n}", "variables": { "customerOneId": "gid://shopify/Customer/544365967", "customerTwoId": "gid://shopify/Customer/624407574", "overrideFields": { "customerIdOfFirstNameToKeep": "gid://shopify/Customer/544365967", "customerIdOfLastNameToKeep": "gid://shopify/Customer/544365967" } }, "response": { "data": { "customerMerge": { "resultingCustomerId": "gid://shopify/Customer/624407574", "job": { "id": "gid://shopify/Job/ab22429a-ea18-4dad-ac2c-5823288b1e59", "done": true }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/mutations/customer_merge_test.rb", "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 CustomerMerge { customerMerge(customerOneId: \\\"gid://shopify/Customer/544365967\\\", customerTwoId: \\\"gid://shopify/Customer/624407574\\\", overrideFields: {customerIdOfFirstNameToKeep: \\\"gid://shopify/Customer/544365967\\\", customerIdOfLastNameToKeep: \\\"gid://shopify/Customer/624407574\\\"}) { resultingCustomerId job { id done } userErrors { code field message } } }\",\n \"variables\": {\n \"customerOneId\": \"gid://shopify/Customer/544365967\",\n \"customerTwoId\": \"gid://shopify/Customer/624407574\",\n \"overrideFields\": {\n \"customerIdOfFirstNameToKeep\": \"gid://shopify/Customer/544365967\",\n \"customerIdOfLastNameToKeep\": \"gid://shopify/Customer/544365967\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\", overrideFields: {customerIdOfFirstNameToKeep: \"gid://shopify/Customer/544365967\", customerIdOfLastNameToKeep: \"gid://shopify/Customer/624407574\"}) {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"customerOneId\": \"gid://shopify/Customer/544365967\",\n \"customerTwoId\": \"gid://shopify/Customer/624407574\",\n \"overrideFields\": {\n \"customerIdOfFirstNameToKeep\": \"gid://shopify/Customer/544365967\",\n \"customerIdOfLastNameToKeep\": \"gid://shopify/Customer/544365967\"\n }\n },\n },\n);\n\nconst data = await response.json();\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 CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\", overrideFields: {customerIdOfFirstNameToKeep: \"gid://shopify/Customer/544365967\", customerIdOfLastNameToKeep: \"gid://shopify/Customer/624407574\"}) {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"customerOneId\": \"gid://shopify/Customer/544365967\",\n \"customerTwoId\": \"gid://shopify/Customer/624407574\",\n \"overrideFields\": {\n \"customerIdOfFirstNameToKeep\": \"gid://shopify/Customer/544365967\",\n \"customerIdOfLastNameToKeep\": \"gid://shopify/Customer/544365967\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\", overrideFields: {customerIdOfFirstNameToKeep: \"gid://shopify/Customer/544365967\", customerIdOfLastNameToKeep: \"gid://shopify/Customer/624407574\"}) {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"customerOneId\": \"gid://shopify/Customer/544365967\",\n \"customerTwoId\": \"gid://shopify/Customer/624407574\",\n \"overrideFields\": {\n \"customerIdOfFirstNameToKeep\": \"gid://shopify/Customer/544365967\",\n \"customerIdOfLastNameToKeep\": \"gid://shopify/Customer/544365967\"\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\", overrideFields: {customerIdOfFirstNameToKeep: \"gid://shopify/Customer/544365967\", customerIdOfLastNameToKeep: \"gid://shopify/Customer/624407574\"}) {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"customerOneId\" => \"gid://shopify/Customer/544365967\",\n \"customerTwoId\" => \"gid://shopify/Customer/624407574\",\n \"overrideFields\" => [\n \"customerIdOfFirstNameToKeep\" => \"gid://shopify/Customer/544365967\",\n \"customerIdOfLastNameToKeep\" => \"gid://shopify/Customer/544365967\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "customerOneId", "description": "The ID of the first customer that will be merged.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "customerOneId", "argValue": " \"gid://shopify/Customer/544365967\"", "typeKind": "MUTATION" }, { "arg": { "name": "customerTwoId", "description": "The ID of the second customer that will be merged.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "customerTwoId", "argValue": " \"gid://shopify/Customer/624407574\"", "typeKind": "MUTATION" }, { "arg": { "name": "overrideFields", "description": "The fields to override the default customer merge rules.", "type": { "kind": "INPUT_OBJECT", "name": "CustomerMergeOverrideFields", "list": false, "non_null": false }, "defaultValue": null, "typeSignature": "CustomerMergeOverrideFields", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "overrideFields", "argValue": " {\"customerIdOfFirstNameToKeep\":\"gid://shopify/Customer/544365967\",\"customerIdOfLastNameToKeep\":\"gid://shopify/Customer/544365967\"}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "customermerge", "title": "Merge two customers", "description": "Merge two customers.\n", "query_string": "mutation CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\") {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n}", "variables": { "customerOneId": "gid://shopify/Customer/544365967", "customerTwoId": "gid://shopify/Customer/624407574" }, "response": { "data": { "customerMerge": { "resultingCustomerId": "gid://shopify/Customer/624407574", "job": { "id": "gid://shopify/Job/ab22429a-ea18-4dad-ac2c-5823288b1e59", "done": true }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/mutations/customer_merge_test.rb", "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 CustomerMerge { customerMerge(customerOneId: \\\"gid://shopify/Customer/544365967\\\", customerTwoId: \\\"gid://shopify/Customer/624407574\\\") { resultingCustomerId job { id done } userErrors { code field message } } }\",\n \"variables\": {\n \"customerOneId\": \"gid://shopify/Customer/544365967\",\n \"customerTwoId\": \"gid://shopify/Customer/624407574\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\") {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"customerOneId\": \"gid://shopify/Customer/544365967\",\n \"customerTwoId\": \"gid://shopify/Customer/624407574\"\n },\n },\n);\n\nconst data = await response.json();\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 CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\") {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"customerOneId\": \"gid://shopify/Customer/544365967\",\n \"customerTwoId\": \"gid://shopify/Customer/624407574\"\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\") {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"customerOneId\": \"gid://shopify/Customer/544365967\",\n \"customerTwoId\": \"gid://shopify/Customer/624407574\"\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation CustomerMerge {\n customerMerge(customerOneId: \"gid://shopify/Customer/544365967\", customerTwoId: \"gid://shopify/Customer/624407574\") {\n resultingCustomerId\n job {\n id\n done\n }\n userErrors {\n code\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"customerOneId\" => \"gid://shopify/Customer/544365967\",\n \"customerTwoId\" => \"gid://shopify/Customer/624407574\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "customerOneId", "description": "The ID of the first customer that will be merged.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "customerOneId", "argValue": " \"gid://shopify/Customer/544365967\"", "typeKind": "MUTATION" }, { "arg": { "name": "customerTwoId", "description": "The ID of the second customer that will be merged.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "customerTwoId", "argValue": " \"gid://shopify/Customer/624407574\"", "typeKind": "MUTATION" } ] } ]