Customer Account REST APIs With Example in Magento 2

For any new customer of the Magento 2 eCommerce website from creating an account to deleting the account, the details of any customer account rest apis required are being given in this post.

In this Customer API List, I am telling you in detail about each API.

I'll run each endpoint on Postman to show you an example of how each of the customer's APIs works.

Customer Account REST APIs
Customer APIs

 

List of Magento 2 Customer Account REST APIs

By the way, there are only a few customer rest APIs in Magento 2 which we frequently use.

It also depends on the function of our mobile application and what kind of functionality we want to provide to our customers.

Based on that, I am giving you the details of the Most Frequently Used Rest API, which has been prepared as an index in a way.

With this list of Magento 2's Customer Rest APIs, it will be easier for you to develop mobile applications.

 

1. Get Customer Details By Customer ID

This rest api will help you to get the customer account information by the getById service method.

Endpoint:

<host>/rest/<store_code>/V1/customers/:customerId

Method: GET

Headers:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

2. Create Customer Account REST APIs

You need to use this REST API to create a new customer account. This is the REST API for Magento 2's default customer account creation.

Endpoint:

<host>/rest/<store_code>/V1/customers

Method: POST

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

Create customer api detail with parameter

 

3. Save Customer Information API

When data is to be saved based on customer id then we save data by sending payload in Magento 2 customer rest api.

Endpoint:

<host>/rest/<store_code>/V1/customers/:customerId

Method: PUT

Header:

  • Authorization: Bearer <customer_token>
  • Content-Type: application/json

 

4. Customer API to Save Data

If Magento 2 customer data has to be saved without customer id then we use this rest api.

And also send the customer token in the header as authorization.

Endpoint:

<host>/rest/<store_code>/V1/customers/me

Method: PUT

Header:

  • Authorization: Bearer <customer_token>
  • Content-Type: application/json

 

5. Get Customer Information REST API

In Magento 2 store we use this api when we have to get customers' data.

In this, only we have to send the customer's token by putting it in the header and then we get all the details of the customer.

We have to gate all the details of the customer with only the login details of the customer, even then on the basis of this get by ID, we gate the information through this API.

Endpoint:

<host>/rest/<store_code>/V1/customers/me

Method: GET

Header:

  • Authorization: Bearer <admin_token>
  • Content-Type: application/json

 

6. Activate Customer ID via REST API

We use this api in Magento 2 to activate the customer id by activateById.

Endpoint:

<host>/rest/<store_code>/V1/customers/me/activate

Method: PUT

Header:

  • Authorization: Bearer <admin_token>
  • Content-Type: application/json

 

7. Search Customer REST API

This api help to get the list of the customer by the getList service method.

Endpoint:

<host>/rest/<store_code>/V1/customers/search

Method: GET

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

8. Activate Customer Email API

To activate the email id of the customer of magento 2, we use this rest api.

Endpoint:

<host>/rest/<store_code>/V1/customers/:email/activate

Method: GET

Header:

  • Authorization: Bearer <admin_token>
  • Content-Type: application/json

 

9. Change Customer Password REST API

Magento 2 Store by default provides REST API to change the password of the customer, using changePasswordById one can change the password of any customer account.

Endpoint:

<host>/rest/<store_code>/V1/customers/me/password

Method: PUT

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

10. Send Customer Password Lest Link API

Using the customer's token to send the reset password link to the customer's mail id, we use the validateResetPasswordLinkToken API.

Endpoint:

<host>/rest/<store_code>/V1/customers/:customerId/password/resetLinkToken/:resetPasswordLinkToken

Method: GET

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

11. Initiate Customer REST Password API

If the API is to be used to initiate the password reset, then we can change the password of any customer using this initiatePasswordReset API.

Endpoint:

<host>/rest/<store_code>/V1/customers/password

Method: PUT

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

12. Reset Password API

In this API, you have to enter the old password of the customer along with the new password that you want to select and hit it with the admin token.

Endpoint:

<host>/rest/<store_code>/V1/customers/resetPassword

Method: POST

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

13. Confirm Customer Account API

When a customer creates an account on the Magento store then we can choose the account confirmation or rejections option from the admin.

And after selecting the same option, you can use the API to get the confirmation status of the customer via rest api in Magento 2.

Endpoint:

<host>/rest/<store_code>/V1/customers/:customerId/confirm

Method: GET

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

14. Customer Account Confirmation API

And after selecting the customer account confirmation option, you can use this API to resend confirmation and validate the account status of any customer through the rest of the API.

Endpoint:

<host>/rest/<store_code>/V1/customers/confirm

Method: POST

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

15. Validate Customer Account API

This api provides a facility to validate any customer account by this any customer account can be validated through the rest api.

Endpoint:

<host>/rest/<store_code>/V1/customers/validate

Method: PUT

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

16. Read-Only Customer Account API

You can get the customer detail like isReadonly or not.

Endpoint:

<host>/rest/<store_code>/V1/customers/:customerId/permissions/readonly

Method: GET

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

17. Delete Customer By ID REST API

Magento2 also provides the facility of default rest api to delete customer accounts based on id. Using this, you can delete any customer on the basis of a customer ID.

Endpoint:

<host>/rest/<store_code>/V1/customers/:customerId

Method: DELETE

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

18. Check Email Available or not Via REST API

When creating a customer account, we have to check the email id.

Now if you want to check customer email id whether it is available or not then you can use this isEmailAvailable REST API for that.

Endpoint:

<host>/rest/<store_code>/V1/customers/isEmailAvailable

Method: POST

Header:

  • Authorization: Bearer <token>
  • Content-Type: application/json

 

 

References:

https://magento.stackexchange.com/

https://devdocs.magento.com/