---
title: "customerMerge"
description: "客户合并"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/mutations/customer-merge'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/mutations/customer-merge.md'
---
# customerMerge

客户合并

- **Required Scopes:** `write_customers`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Mutation

## Type Signature

`CustomerMergePayload`

## Required Permissions

* `write_customers`

接口访问需要令牌，具体如何获取令牌请参考：[身份认证](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md)

## Arguments

* `customerOneId`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  将被合并的第一个客户的ID

* `customerTwoId`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  将被合并的第二个客户的ID

* `overrideFields`

  [CustomerMergeOverrideFieldsInput](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/inputs/customer-merge-override-fields-input.md)

  用于覆盖默认客户合并规则的字段

## Returns

* `resultingCustomerId`

  [ID](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  客户合并后保留的客户ID

* `userErrors`

  [[CustomerMergeUserError]](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/objects/customer-merge-user-error.md)

  执行变异时发生的错误列表

## Code Example

```graphql
mutation customerMerge($customerOneId: ID! $customerTwoId: ID! $overrideFields: CustomerMergeOverrideFieldsInput ) {
	customerMerge(customerOneId: $customerOneId, customerTwoId: $customerTwoId, overrideFields: $overrideFields ) 
		 {
			# CustomerMergePayload fields
		}
		
	}

```

## Variables

```json
{
  "customerOneId": {},
  "customerTwoId": {},
  "overrideFields": {
    "customerIdOfDefaultAddressToKeep": "",
    "customerIdOfEmailToKeep": "",
    "customerIdOfFirstNameToKeep": "",
    "customerIdOfLastNameToKeep": "",
    "customerIdOfPhoneNumberToKeep": {},
    "note": {},
    "tags": ""
  }
}
```

## Error Handling

关于更多通用错误码说明，参考：[状态码和错误码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes)。

