We are in a project where Magento 2 CE is used as the commerce service provider. Usually when a guest user who has items in Cart login the cart gets merged to the customer's cart and the guest cart will be deleted. How can the same be achieved using Rest APIs in Magento 2? I know that in WCS, we needed to pass the guest token as a header to the Registered user login Rest API. Can someone help us on this?

  • hi @ many vijayan whether you got the solution for this api? Commented Nov 2, 2017 at 10:00

2 Answers 2


Use the below steps: Method - PUT

Param - {
  "customerId": 3,
  "storeId": 1

Authorization -"Bearer {user-token}"

It will assign the guest cart to a logged-in user


I got stuck on the same thing. I didn't have any issues using the Magento REST API when I was logged-in but I ran into a bunch of problems using the guest cart API including connecting a guest cart initialized from the REST API to the user session in the backend and transitioning the cart from the guest state to the logged-in state.

In the end I created a custom web service module so that I could do this logic in PHP.



This approach worked well for me so I wanted to put it out there as an option. I find that the Magento documentation for its REST API isn't as good as it could be.

  • 1
    Would you not mind sharing the cartMerge Api?
    – MagePsycho
    Commented Oct 2, 2017 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.