Magento 2 REST API – Update Single Customer Address

magento-2.1

Does the Magento 2 REST API support updating a single customer address?

This endpoint is incomplete: customerAddressRepositoryV1

GET /V1/customers/addresses/{addressId}
DELETE /V1/addresses/{addressId}

This endpoint allows adding/updating of addresses: customerCustomerRepositoryV1:

PUT /V1/customers/{id}

To update an existing address specify the address id property (table customer_address_entity column entity_id). For example, to update address id = 16:

{
    "customer": {
        "email": "test@test.com",
        "firstname": "Test",
        "lastname": "Test",
        "store_id": 1,
        "website_id": 1,
        "addresses": [{
            "id": 16,
            "customerId": 1,
            "region": {
                "region_code": "CA",
                "region": "California"
            },
            "region_id": 12,
            "countryId": "US",
            "street": [
                "123 Test St."
            ],
            "telephone": "555 555 5555",
            "postcode": "90210",
            "city": "Beverly Hills",
            "defaultShipping": false,
            "defaultBilling": true
        }]
    }
}

However, if a customer has more than one address then all other addresses are deleted from the customer. We want to update the address (but NOT delete other addresses). It also seems redundant to have to pass customer information e.g. email. If this feature doesn't exist we'll need to create our own endpoint.

Best Answer

Matthew

No, M2.2 even does not support Customer Address save/update. What you can do with current implementation is:

  1. Get full customer information:

    curl -X GET http://your.magento2.com/rest/default/V1/customers/ID \ -H 'authorization: Bearer TOKEN'

  2. Put full customer information updating the desired address/es:

    curl -X PUT http://your.magento2.com/rest/default/V1/customers/ID \ -H 'authorization: Bearer TOKEN'

Or declare in your own module two new endpoints into webapi.xml, since AddressRepository already have getList and UpdateAddressCollection (M2.2 I can see them) functions you can create a new interface and your own AddressRepository model which extends original Interface/Model and then use this functions for update and search.

Related Topic