Magento 2 API – Reset Customer Password

Hello, Magento peeps!

I am here back with another blog post on Magento 2 API. My last post was about getting customer tokens in Magento 2 using API, which is required for the customer login. If you haven’t checked it, read it now at Magento 2 API – Get Customer Token. This blog post will show you how to reset customer password using Magento 2 API.

In a survey by HYPR, 78% of the respondents revealed that they had to reset the password they forgot in 90 days. Therefore, it becomes vital to provide password reset functionality to the customers if you are developing a mobile shopping app based on Magento 2 or creating a new storefront. Magento 2 includes default API endpoints that provide customers with such functionality to reset their passwords.

In this blog post, I will guide you through the Magento 2 API to request a password reset token email and use that token to reset the customer password.

Let’s begin with the Magento 2 API to Reset Customer Password!

How to Reset Customer Password Using REST API in Magento 2?

The client needs a password reset token to set a new password in Magento 2 using REST API. The client needs to pass the customer email id through a PUT method in Magento 2 API to request the password reset token. The request will generate a password reset token in Magento 2, which will be sent to the customers’ email that can be later used to set a new password.

Step 1: Request Customer Password Reset Token Using Magento 2 API

Provided below is the complete structure of the Magento 2 API request to get the customer password reset token:

Method: PUT

URL: store_url/rest/V1/customers/password

Body:

Send Customer Password Reset Token Request Using Magento 2 API

If a customer with the provided email id is registered, Magento 2 will return a ‘true’ response and send a customer password reset link containing the reset token to the same email address.

Step 2: Use Customer Password Reset Token to Set New Password Using Magento 2 API

The next step is to utilize the password reset token to set a new password using Magento 2 API request. Generally, the password reset token is present in the URL of the password reset link received on the customer’s email. The client must pass the customer’s email address, password reset token, and a new password through a POST request to the customers/resetPassword endpoint. Here’s the complete structure of the Magento 2 API request to reset the customer password:

Method: POST

URL: store_url/rest/V1/customers/resetPassword

Body:

Reset Customer ID Password Using Magento 2 Rest API

Response:

Magento 2 will reset the customer password as requested on the successful validation of the password reset token. An error message will be displayed in case of a mismatch of the password.

That’s it!

This is how you can use Magento 2 REST API to reset customer password.

Conclusion

Developers can harness the features and functionalities of Magento 2 by using the REST APIs in third-party developments such as new storefronts or mobile apps. Magento 2 API Rest Customer Password is useful to add the ‘forgot password’ feature by using the APIs. I hope this guide will help you with the customer password reset API in Magento 2 and add value to your Magento knowledge.

In case you still have any doubts or queries using the customer password reset API in Magento 2, feel free to comment. I’d be happy to help you. 😇

Also, do not forget to share this Magento 2 API guide with your developer friends via social media. 😃

Thanks for reading! 🍀

◄ Magento 2 API – Get Customer TokenMagento 2 API – Create Cart & Add Products to Cart ►

5
(based on 5 Reviews)
Magento 2 API – Reset Customer PasswordAuthor Magento Badge

Jignesh Parmar

An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.

Leave a Reply

Your email address will not be published.