How To Call Magento 2 REST API For Customer Account Update

Here, I am going to explain how you can call Magento 2 Customer REST API to update the customer information from another website. So for the Customer Account Update, we don't need to create any custom API if you don't need any extra facilities.

By using Magento 2 default customer REST API you can create customers from third-party websites and you can use that credentials to get the customer access token and again by using those customer access token you can implement forgot password process.

Magento 2 API Customer Account Update

 

Magento 2 Customer Account Update Default API

There are already default APIs in Magento 2 so simply we are going to use that API and we will create customers and then log in by using that customer API through using a customer access token.

We can also send and receive customer forgot password links on the mail using customer forgot rest API in the Magento store.

 

Magento 2 Create Customer REST API

https://wishusucess.com/rest/all/V1/customers

Method: POST

{
"customer": {
"email": "cs.hemantsingh@gmail.com",
"firstname": "Hemant",
"lastname": "Singh"

},
"password": "cs.hemantsingh@gmail.com"
}

Magento 2 Customer Account Update Create REST API

Now your customer has been created and you will get a response like the below image.

Customer Create Magento 2 REST API

 

Call Customer Login REST API

So here by using the below API you can log in to the Magento 2 store from any other website or third-party website. and you can do customer account update from that server.

This is the default Magento 2 Rest API that is used to call the customer login on another server.

Magento 2 has two steps to login from a third-party website so in the first step, you have to create a customer login token by using your customer details so when you will send a request with the customer login id and password then Magento stores send you the token.

After that, you have to utilize that tokens as authentication and then you will get your personal details.

http://wishusucess.com/rest/all/V1/integration/customer/token

Now you have created a customer account so you have to use that account credentials and send it with the POST method.

{
"username": "cs.hemantsingh@gmail.com",
"password": "Admin@$123456"
}

Magento 2 Customer Account Update Get Login Token

So here you have received your customer token now we will use this customer token for any kind of data receiving from the Magento 2 store.

So here we are using those tokens to log in to our Magento 2 store.

https://wishusucess.com/rest/V1/customers/me

Method: GET

Magento 2 Customer REST API Login Bu Access Token

You can see by using the tokens we have received each and every detail of the customer.

similarly, we can use that tokens to send a forgot password link on our registered email id.

https://wishusucess.com/rest/all/V1/customers/password

Method: PUT

Customer Account Update Authorisation TokenNow here we have added the received tokens from the Magento 2 store, This is the authorization of Magento 2 existing customers.

Magento 2 Customer Forgot Password REST API

Now you can see the forgot password email has been sent by using the Magento 2 REST API, and we have received the response true which means we have received a mail with forgot password link.

Forgot password Link Mail in Magento 2 Customer Account Update

 

Customer Account Update Email Available API

By using Magento 2 default REST API we can check whether customer email is available or not, if the email is available then you will receive a response true something like the below image.

https://wishusucess.com/rest/all/V1/customers/isEmailAvailable

Method: POST

Check Email Avilablity Using Magento 2 REST API

 

Conclusion: Magento 2 provides a default web API for access the data from other websites and we can use that API to retrieve the data or save the data.

 

Related Post:

ContactUs REST API: Create Magento 2 Custom Contact Us REST API

Checkout REST API: Get Checkout Data Using REST API Key in Magento

 

Wishusucess GitHub Profile

 

Leave a Reply