data-src=../../includes/commerce-only.md
Set a company address as default
data-variant=info
data-slots=text
Magento_CompanyAddressStorefrontCompatibility::default ACL resource.This endpoint sets a company address as the default billing or shipping address for its company, using the setDefaultByAddressId operation of the companyDefaultAddressManagementV1 service. The address type (billing or shipping) is determined by the address itself, so the same endpoint is used for both.
Service Name:
companyDefaultAddressManagementV1
REST Endpoint:
PUT /V1/company-addresses/:addressId/default
Set a billing address as default
The following example sets billing address 12 as the default billing address for its company.
Sample Usage:
PUT <host>/rest/<store_code>/V1/company-addresses/12/default
data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON
Payload
// none
Response
{
"company_address_id": 12,
"company_id": 2,
"type": 1,
"nickname": "HQ Billing",
"firstname": "John",
"lastname": "Doe",
"company": "Acme Corp",
"street": [
"123 Main St"
],
"city": "Austin",
"country_id": "US",
"region_id": 57,
"region": {
"region_id": 57,
"region": "Texas",
"region_code": "TX"
},
"postcode": "78701",
"telephone": "5551234567",
"custom_attributes": []
}
Set a shipping address as default
The following example sets shipping address 13 as the default shipping address for its company.
Sample Usage:
PUT <host>/rest/<store_code>/V1/company-addresses/13/default
data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON
Payload
// none
Response
{
"company_address_id": 13,
"company_id": 2,
"type": 2,
"nickname": "Warehouse",
"firstname": "John",
"lastname": "Doe",
"company": "Acme Corp",
"street": [
"500 Distribution Way"
],
"city": "Austin",
"country_id": "US",
"region_id": 57,
"region": {
"region_id": 57,
"region": "Texas",
"region_code": "TX"
},
"postcode": "78702",
"telephone": "5551234567",
"custom_attributes": []
}
Read the default addresses for a company
After setting defaults, you can read them from the company's default billing and shipping endpoints:
GET /V1/companies/:companyId/billingAddress
GET /V1/companies/:companyId/shippingAddress
Notes
- The company address book must be enabled for the company, or the request fails with
400 Bad Requestand the messageCompany address book is not enabled for this company. - Requesting the default billing or shipping address for a company that has none configured returns
404 Not Foundwith the messageDefault company address not found.