How to add a new address (shipping or billing or another) via Magento 2 REST API?

I was having a similar problem and was digging into the AccountManagement class to find the proper payload. I noticed that the createAccount function checks if a customer ID exists and loads the stored data.

By performing a POST /V1/customers/:id, I was able to add another address with the following payload:

{ "customer":
    {
       "email":"[email protected]",
       "firstname":"test",
       "lastname":"test",
       "websiteId": 0,
       "addresses": [
            {
                "id": 9,
                "firstname": "test",
                "lastname": "test",
                "company": "test technology",
                "street": [
                "Test Street 9",
                "Tiny House 9"
                ],
                "city": "City Nine",
                "region_id": 12,
                "region": "California",
                "postcode": "91790",
                "country_id": "US",
                "telephone": "1234567890"
            },
            {
                "firstname": "test",
                "lastname": "test",
                "company": "test technology",
                "street": [
                "Test Street 10",
                "Tiny House 10"
                ],
                "city": "City Ten",
                "region_id": 12,
                "region": "California",
                "postcode": "91790",
                "country_id": "US",
                "telephone": "1234567890"
            }
        ]
    }

By post method how did you do this actually when i am trying it is showing me error of missing route did you write webapi.xml code for this route.


It should be possible to add/update customer addresses using customer repository API:

PUT /V1/customers/:id (for admin)
PUT /V1/customers/me (for customer)