Update Shipping Address
Updates existing shipping addresses of a company and adds new ones in the same request. Items with an id update that address. Items without an id are added as new addresses.
HTTP Request
- URL:
/shippingAddress/{companyId} - Method:
PUT - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_WRITE_COMPANY
Path Parameters
| Parameter | Type | Description |
|---|---|---|
companyId | String | The ID of the company that owns the addresses. |
Request Body
Send a JSON array with at least one address object.
| Field | Type | Required | Description |
|---|---|---|---|
id | String | No | ID of the shipping address to update. Leave out to add a new address. |
address1 | String | No | Address line 1. Required for new addresses. |
city | String | No | City. Required for new addresses. |
state | String | No | State code, for example NY. Required for new addresses. |
country | String | No | Country code, for example US. Required for new addresses. |
zipcode | String | No | Postal code. Required for new addresses. |
firstName | String | No | First name of the contact. |
lastName | String | No | Last name of the contact. |
companyName | String | No | Company name shown on the address. |
companyEmail | String | No | Email address for the address. |
address2 | String | No | Address line 2. |
phoneNumber | String | No | Phone number of the contact. |
isDefaultAddress | Boolean | No | Make this the company's default shipping address. Only one item can be the default. |
metaFields | Array | No | Custom field values as code and value. Replaces the current values. |
cURL Example
curl --location --request PUT '<BASE_URL>/shippingAddress/66b9b3b166169eecd60e5ba8' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '[
{
"id": "66d0f6973560dad7cf821e9a",
"address2": "Unit 5C",
"state": "NY",
"country": "US",
"isDefaultAddress": true
},
{
"firstName": "Jane",
"lastName": "Smith",
"address1": "456 Oak Ave",
"city": "Los Angeles",
"state": "CA",
"country": "US",
"zipcode": "90001"
}
]'
Response
- 200 OK: The shipping addresses were updated successfully.
- 400 Bad Request: The access token is missing or invalid, the body is empty, a field is missing or not valid, or more than one address is marked as default.
Sample JSON Response
{
"success": true,
"message": "Shipping Address Updated Successfully",
"data": [
{
"id": "66d0f6973560dad7cf821e9a",
"company": "66b9b3b166169eecd60e5ba8",
"type": "shipping",
"firstName": "Maria",
"lastName": "Lopez",
"address1": "123 Maple St",
"address2": "Unit 5C",
"phoneNumber": "2125550198",
"city": "New York",
"state": { "code": "NY", "name": "New York" },
"country": { "code": "US", "name": "United States" },
"zipcode": "10001",
"isDefaultAddress": true,
"status": true,
"metaFields": [],
"createdAt": "2024-08-29T22:41:59.512Z",
"updatedAt": "2024-10-09T13:05:59.036Z"
},
{
"id": "66f1a2b3c4d5e6f708192a3b",
"company": "66b9b3b166169eecd60e5ba8",
"type": "shipping",
"firstName": "Jane",
"lastName": "Smith",
"address1": "456 Oak Ave",
"city": "Los Angeles",
"state": { "code": "CA", "name": "California" },
"country": { "code": "US", "name": "United States" },
"zipcode": "90001",
"isDefaultAddress": false,
"status": true,
"metaFields": [],
"createdAt": "2024-10-09T13:05:59.040Z",
"updatedAt": "2024-10-09T13:05:59.040Z"
}
]
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request succeeded. |
message | String | Result message. |
data | Array | The updated and new shipping addresses, in request order. |
Shipping Address Data
Each item in data has the same fields as the address returned by Get Address by ID.
Notes
- Items whose
iddoes not match a shipping address of the company are skipped. - When an address is marked as default, the company's previous default shipping address is no longer the default.