How to Add a New Customer Address by REST API in Magento 2?

In today’s tutorial, we will explain how to add a new customer address by REST API in Magento 2. Note that if you are adding a new customer address in Magento 2, you must have the customer token before adding a new customer address. To get the customer token, you can refer to our previous article.

Steps to Add a New Customer Address by REST API in Magento 2

Step 1. First of all, Set End Point of REST API:

{{url}}/rest/{store_code}/V1/customers/me
PS - {{url}} = Your_Site_Base_Url

Step 2. Set your End Point as URL and set Method:PUT

Step 3. Set Header as 

Content-Type: application/json
Authorization Bearer {CUSTOMER_ACCESS_TOKEN}

Request Body:
{
  "customer": {
    "email": "[email protected]",
    "firstname":"MageDelight",
    "lastname":"Solutions",
    "website_id": 1,
    "addresses": [
      {
        "region": {
            "region_code": "DC",
            "region": "Washington",
            "region_id": 57
        },
        "country_id": "US",
        "street": [
            "Wonder Valley"
        ],
        "telephone": "1111122222",
        "postcode": "78701",
        "city": "Virginia",
        "firstname": "MageDelight",
        "lastname": "Solutions",
        "default_shipping": true,
        "default_billing": true
      },
      {
        "region": {
            "region_code": "TX",
            "region": "Texas",
            "region_id": 12
        },
        "country_id": "US",
        "street": [
            "Horse Boulevard"
        ],
        "Firstname": Shaun",
        "lastname": "Murphy",
        "telephone": "1234123412",
        "postcode": "45405",
        "city": "Los Angeles",
        "default_shipping": false,
        "default_billing": false
      }
    ]
  }
}

In the Above Mentioned code, First Name, Last Name, Website ID, Email Address, are required fields. 

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

The store owner can assign default_shipping and default_billing as per the requirement.

Once you execute the API, the output will be displayed based on your data.

Also read: How to Manage Index and Cache Management Using Magento 2 REST API?

We hope that we covered everything about customer address in this article if we missed out anything, feel free to reach us out.