Skip to content

Magento2 REST API, change address through /order/parent_id endpoint

I want to change the shipping address and billing address for Magento 2 orders through the /order/{parent_id} endpoint:

https://adobe-commerce.redoc.ly/2.4.7-admin/tag/ordersparent_id

Parent_id is the (parent) Order ID of the address. This currently works for setting either the shipping or billing address. E.g. the body of my query in that case looks like this:

entity: 
{
  address_type: 'shipping',
  city: 'Tilburg ',
  company: undefined,
  country_id: 'NL',
  email: '[email protected]',
  entity_id: 1,
  fax: '',
  firstname: 'xxx',
  lastname: 'Bodden',
  middlename: '',
  parent_id: 1,
  postcode: 'xxx',
  prefix: '',
  region: undefined,
  street: [ 'xxx 181' ],
  suffix: '',
  telephone: '0123456789'
}

It seems that if you change either the billing or shipping address, the other resets to some default values. From this I naturally conclude that you should forward the complete address entity for both the shipping and billing, however the API does not seem to accept multiple addresses like this:

entity: {
{
  address_type: 'shipping',
   city: 'Tilburg ',
  company: undefined,
  country_id: 'NL',
  email: '[email protected]',
  entity_id: 1,
  fax: '',
  firstname: 'xxx',
  lastname: 'Bodden',
  middlename: '',
  parent_id: 1,
  postcode: 'xxx',
  prefix: '',
  region: undefined,
  street: [ 'xxx 181' ],
  suffix: '',
  telephone: '0123456789'
},
 {
  address_type: 'billing',
  city: 'Tilburg ',
  company: undefined,
  country_id: 'NL',
  email: '[email protected]',
  entity_id: 1,
  fax: '',
  firstname: 'xxx',
  lastname: 'Bodden',
  middlename: '',
  parent_id: 1,
  postcode: 'xxx',
  prefix: '',
  region: undefined,
  street: [ 'xxx 181' ],
  suffix: '',
  telephone: '0123456789'
}
}

I am confused to how I should call the endpoint to set both the shipping and billing address seperately. Does anybody here have a hint to what could work? Thanks!