Create Shipping Address
This POST API allows you to create new shipping addresses for a specific company. This endpoint also supports adding custom meta fields for additional address information.
Endpoint Details
- URL:
/shippingAddress/{company_id} - Method:
POST - Authentication: Bearer Token (required)
Path Parameters
| Parameter | Type | Description |
|---|---|---|
company_id | string | The unique identifier of the company for which shipping addresses are being 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) |
isDefaultAddress | boolean | Indicates whether this is the default address. (required) |
metaFields | array | Array of custom meta-information fields related to the address. (optional) |
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
[
{
"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
}
]
}
]
Response
Success Response
| Status Code | Description |
|---|---|
| 200 OK | The request was successful and the server will return a list of all the 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 | object | Contains the list of newly created shipping addresses. |
Sample Response Body
{
"success": true,
"message": "Shipping address created successfully",
"data": [
{
"firstName": "John",
"lastName": "Doe",
"address1": "123 Maple St",
"address2": "Apt 4B",
"phoneNumber": "1234567890",
"city": "New York",
"state": {
"name": "New York",
"code": "NY"
},
"country": {
"name": "United States",
"code": "US"
},
"zipcode": "10001",
"isDefaultAddress": true,
"status": true,
"metaFields": [],
"createdAt": "2024-01-10T12:00:00Z",
"updatedAt": "2024-01-12T12:00:00Z",
"company": "5f8d04f2c6071200213a9e5b",
"id": "66b9b3b166169eecd60e5ba8"
}
]
}
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 under which the shipping address is being created. - 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 the shipping address.