Magento 2 Customer REST API: All Customer API Details

Here I am explaining to you the most commonly used Magento 2 customer rest API lists in detail.

If you want to know in detail then links are given on which you can click on that particular API to know in detail.

This Customer API list describes how to create a customer account, log in and update the customer account data.

If you want to activate a customer account then how will you will activate and if the password has to be changed then how you will be changing the password.

 

Most Used Magento 2 Customer REST API List

By using the below list of customer rest API in Magento 2 you can get the all details, save the details and update the information.

Magento 2 Customer API List

1. Create Customer REST API

This rest api helps you to create a new customer by using this customer creation rest api in magento2.

Endpoint:

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

Example:

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

Method: POST

Headers:

  • Content-Type: application/json

Body:

{
"customer": {
"email": "cs.hemantsingh@gmail.com",
"firstname": "Hemant",
"lastname": "Singh"
},
"password": "A$#in@#13"
}

 

2. Login Customer REST API

Create customer access token rest api that helps customers to login into Magento 2 store.

Endpoint:

POST <host>/rest/<store_code>/V1/integration/customer/token

Example:

https://wishusucess.com/rest/V1/integration/customer/token

Method: POST

Headers:

  • Content-Type: application/json

Payload:

{
"username": "cs.hemantsingh@gmail.com",
"password": "A$#in@#13"
}

 

3. Get Customer Information REST API

This is the Magento 2 customer rest api that is used to get the customer information by id.

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

Example:

https://wishusucess.com/rest/default/V1/customers/111

Method: GET

Headers:

  • Content-Type: application/json

Payload:

Not required

 

4. Update Customer Name REST API

Customer information can be updated by the customer id in Magento 2 rest api by using the following endpoint.

Endpoint:

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

Example:

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

Method: PUT

Headers:

  • Content-Type: application/json

Payload:

{ "customer": { "firstname": "Hemant", "lastname": "Singh"}}

 

5. Update Customer Custom Attribute Value By API

The custom attribute of customer value can be updated by the following endpoint by customer id.

Endpoint:

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

Example:

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

Method: PUT

Headers:

  • Content-Type: application/json

Payload:

{ "customer": {
"custom_attributes": [
{
"attribute_code": "customer_account_status",
"value": "1"
},
{
"attribute_code": "payment_status",
"value": "1"
}
]
}
}

 

6. Get Customer Information REST API

If all the details of the customer are to be received, then the Customer Me rest API is used in Magento 2 for that.

As mentioned below, in this you have to send by adding the customer token in the header as authorization.

Endpoint:

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

Example:

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

Method: GET

Headers:

  • Authorization: Bearer <customer_token>

Payload:

Not required

 

7. Save Customer Information REST API

To save the information of the Magento 2 customer, we use the Customer Rest API, for this we send the parameter to be saved in the payload.

Customer ID, Customer Group ID, Website ID, and Customer Store ID have to be sent compulsorily while sending the information in the payload.

And the information that has to be saved is to be sent along with the details.

Endpoint:

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

Example:

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

Method: PUT

Headers:

  • Authorization: Bearer <customer_token>

Payload:

{
"customer": {
"email": "cs.hemantsingh@gmail.com",
"firstname":"Hemant",
"lastname":"Singh",
"website_id": 1,
"addresses": [
{
"region": {
"region_code": "UP",
"region": "Uttar Pradesh",
"region_id": 566
},
"country_id": "IN",
"street": [
"Noida",
"Noida gauttam Budh Nagar"
],
"firstname": "Hemant",
"lastname": "Singh"
"default_shipping": true,
"default_billing": true,
"telephone": "8197565002",
"postcode": "201301",
"city": "Noida",
},
{
"region": {
"region_code": "UP",
"region": "uttar Pradesh",
"region_id": 566
},
"country_id": "IN",
"street": [
"Noida",
"Noida"
],
"firstname": "Hemant",
"lastname": "Singh",
"defaultShipping": false,
"defaultBilling": false,
"telephone": "8197565002",
"postcode": "201301",
"city": "Noida",
}
]
}
}

 

8. Activate Customer Account REST API

If we want to activate Magento 2 customer account through rest api, then for that we use the rest api given below.

In payload, we have to send customer id details and in authorization, we have to send customer access tokens by entering.

Endpoint:

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

Example:

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

Method: PUT

Headers:

  • Authorization: Bearer <customer_token>

Payload:

{"confirmationKey":customer_id}

Example: {"confirmationKey":111}

 

9. Activate Customer Email REST API

You can activate customer email by hitting the customer email active rest API in Magento 2.

Endpoint:

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

Example:

https://wishusucess.com/rest/default/V1/customers/:email/activate

Method: PUT

Headers:

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

Payload:

{"confirmationKey":customer_id}

Param:

email: cs.hemantsingh@gmail.com

 

10. Change Password Magento 2 API

To change the current password of the customer's account, we use the REST API which is given below.

We can change the password of any customer account using this Change Password API in Magento 2.

Endpoint:

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

Example:

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

Method: PUT

Headers:

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

Payload:

{"customer_id": 111, "currentPassword": "HK@#123", "newPassword": "HK@#$123"}

 

Recommended Posts:

Update Customer Attributes Value via Magento 2 REST API

Add/Update Many Customer Address REST API in Magento 2