How to add new Customer Address By REST API Magento 2?

Add Update Customer Address Using REST Web API in Magento 2 with URL rest/{store_code}/V1/customers/me and PUT Action method.

API is useful when you have to import customer addresses from a third-party platform. Just call REST API and you can import the address to the Magento.

There are two ways to Add or Update Customer Addresses using REST,

1Using Admin Panel Token as Header Parameter.

Using this way, It’s a simple one to add or update customer addresses.

Endpoint URL:

Where store_code is your store code. Default store_code is the default.

Action: PUT

Headers:

Payload Request Body:

Using Admin Token as Header, you have to just pass addresses array as Payload Body and you don’t require email id, website id, or first name and last name.


2.  Using Customer Token as Header Parameter

You must require a customer token before adding a new address using REST API. This customer access token value will be passed in the Request Header.

Check the link,  Generate Customer Token by REST API.

Step by step guide to creating a new address using POSTMAN,

Endpoint URL:

Where store_code is your store code. By Default Magento comes with, store_code as default. You can get its value from the store database table.

Action:
PUT

Headers:

Payload Request Body:

In the Payload body,

first name, Last name, email, website_id are required fields.

Under the addresses object, all the fields are required which I mentioned in the above example.

You can assign default_shipping and default_billing as per your requirement.

When you run the given payload, Output will be display based on your data, and your addresses will be inserted into the customer address.