Merge two customers
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/customers/1/merge';const options = { method: 'POST', headers: {'x-api-key': '<x-api-key>', 'Content-Type': 'application/json'}, body: '{"absorbed_id":"example","keep":{"name":"survivor","email":"survivor","phone":"survivor","default_address_id":1},"reason":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://apibase.ecomweb.app/api/v1/stores/example/customers/1/merge \ --header 'Content-Type: application/json' \ --header 'x-api-key: <x-api-key>' \ --data '{ "absorbed_id": "example", "keep": { "name": "survivor", "email": "survivor", "phone": "survivor", "default_address_id": 1 }, "reason": "example" }'Folds one customer into another. The path names the customer that remains; absorbed_id in the body names the one folded in. Irreversible: the absorbed customer is deleted, and its orders, addresses, sign-in identities and metafield values move to the surviving customer. keep chooses, field by field, whose name, email and phone win. Merging a customer into itself is refused.
Required scopes: write:customers
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The customer ID.
The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
ID of the customer folded in and deleted. The path names the customer that remains.
Which customer each conflicting field is taken from. A field left out keeps the surviving customer’s value.
object
Whose name the surviving customer keeps.
Whose email the surviving customer keeps.
Whose phone number the surviving customer keeps.
ID of the address that becomes the default. It must belong to one of the two customers.
Why the customers are being merged. Recorded on the customer timeline.
Responses
Section titled “Responses”object
ID of the customer that remains.
IDs of the customers that were folded in and deleted.
Orders moved to the surviving customer.
Addresses moved to the surviving customer.
Sign-in identities moved to the surviving customer.
Example generated
{ "survivor_id": 1, "merged_ids": [ 1 ], "moved_orders": 1, "moved_addresses": 1, "moved_identities": 1}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The resource does not exist in this store.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}