Update Shipping Address
This PUT API allows you to update existing shipping addresses or add new ones for a specific company. This endpoint also supports adding custom meta fields for additional address information.
Endpoint Details
- URL:
/shippingAddress/{company_id} - Method:
PUT - Authentication: Bearer Token (required)
Path Parameters
| Parameter | Type | Description |
|---|---|---|
company_id | string | The unique identifier of the company for which shipping addresses are being updated or added. |
Authentication
You must provide a valid accessToken in the request headers to authenticate and access this endpoint.
Authentication Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be set to application/json. |
accessToken | string | A valid access token is required. |
Request Body
The request body must contain an array of shipping addresses in JSON format. Below is the list of fields that you need to provide for each address:
| Field | Type | Description |
|---|---|---|
companyName | string | Company name of this recipient (Optional). |
companyEmail | string | Company email of the recipient (Optional) |
firstName | string | The first name of the recipient. (required) |
lastName | string | The last name of the recipient. (optional) |
address1 | string | Primary address line. (required) |
address2 | string | Secondary address line. (optional, can be null or empty) |
phoneNumber | string | Contact phone number for the address. (optional, can be null or empty) |
city | string | City of the address. (required) |
state | string | State of the address. (required) |
country | string | Country of the address. (required) |
zipcode | string | Postal code of the address. (required) |
metaFields | array | Array of custom meta-information fields related to the address. (optional) |
id | string | The unique ID of the existing shipping address to update (optional for new addresses) |
MetaField Object (metaFields[])
The metaFields array contains custom metadata for the shipping address. Each object in the array should adhere to the following structure:
| Field | Type | Description |
|---|---|---|
code | string | Unique code identifying the meta field. (required) |
value | mixed | The value of the meta field. Can be a string, number, or array. (optional) |
Sample Request Body
[
{
"id": "66b9b3b166169eecd60e5ba8", // Update existing shipping address
"firstName": "John",
"lastName": "Doe",
"address1": "123 Maple St",
"address2": "Apt 4B",
"phoneNumber": "1234567890",
"city": "New York",
"state": "NY",
"country": "US",
"zipcode": "10001",
"isDefaultAddress": true,
"metaFields": [
{
"code": "buildingType",
"value": "apartment"
},
{
"code": "parking",
"value": true
}
]
},
{
"firstName": "Jane", // Create new shipping address
"lastName": "Smith",
"address1": "456 Oak Ave",
"address2": "Suite 12",
"phoneNumber": "0987654321",
"city": "Los Angeles",
"state": "CA",
"country": "US",
"zipcode": "90001",
"isDefaultAddress": false,
"metaFields": [
{
"code": "deliveryInstructions",
"value": "Leave at front desk"
},
{
"code": "secureBuilding",
"value": false
}
]
}
]
Response
Success Response
| Status Code | Description |
|---|---|
| 200 OK | The request was successful, and the server returns a list of all shipping addresses associated with the company. |
Success Response Body Structure
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates if the request was successful. |
message | string | Message indicating the result of the operation. |
data | array | Contains the list of updated or newly added shipping addresses. |
Sample Response Body
{
"success": true,
"message": "Shipping addresses updated successfully",
"data": [
{
"firstName": "John",
"lastName": "Doe",
"address1": "123 Maple St",
"address2": "Apt 4B",
"phoneNumber": "1234567890",
"city": "New York",
"state": "NY",
"country": "US",
"zipcode": "10001",
"isDefaultAddress": true,
"status": true,
"metaFields": [
{
"code": "buildingType",
"value": "apartment"
},
{
"code": "parking",
"value": true
}
],
"createdAt": "2024-01-10T12:00:00Z",
"updatedAt": "2024-01-12T12:00:00Z",
"company": "5f8d04f2c6071200213a9e5b",
"id": "66b9b3b166169eecd60e5ba8"
},
{
"firstName": "Jane",
"lastName": "Smith",
"address1": "456 Oak Ave",
"address2": "Suite 12",
"phoneNumber": "0987654321",
"city": "Los Angeles",
"state": "CA",
"country": "US",
"zipcode": "90001",
"isDefaultAddress": false,
"status": true,
"metaFields": [
{
"code": "deliveryInstructions",
"value": "Leave at front desk"
},
{
"code": "secureBuilding",
"value": false
}
],
"createdAt": "2024-01-10T12:00:00Z",
"updatedAt": "2024-01-12T12:00:00Z",
"company": "5f8d04f2c6071200213a9e5b",
"id": "66b9b3b166169eecd60e5cd9"
}
]
}
Shipping Address Object (data[])
Each object in the data array represents a shipping address and contains the following fields:
| Field | Type | Description |
|---|---|---|
firstName | string | First name of the recipient. |
lastName | string | Last name of the recipient. |
address1 | string | Primary address line. |
address2 | string | Secondary address line (optional). |
phoneNumber | string | Contact phone number. |
city | string | City of the shipping address. |
state | object | State information (contains name and code). |
country | object | Country information (contains name and code). |
zipcode | string | Postal code of the shipping address. |
isDefaultAddress | boolean | Indicates if this is the default shipping address. |
status | boolean | Status of the address (e.g., active or inactive). |
metaFields | array | Additional meta information associated with the address (optional). |
createdAt | string | Date and time the address was created (ISO format). |
updatedAt | string | Date and time the address was last updated (ISO format). |
company | string | The company associated with the shipping address. |
id | string | Unique identifier for the shipping address. |
Error Responses
| Status Code | Description |
|---|---|
| 400 Bad Request | Invalid request format or missing data. |
| 401 Unauthorized | Invalid or missing access token. |
| 403 Forbidden | Access denied. |
| 404 Not Found | Company or shipping address not found. |
| 500 Internal Server Error | Server encountered an error. |
Notes
- Ensure that the
company_idin the URL corresponds to the actual ID of the company for which the shipping address is being created or updated. - Make sure all required fields are included in the request body to avoid validation errors.
- The API requires a valid access token for authentication to successfully create or update the shipping address.