Skip to main content

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

ParameterTypeDescription
company_idstringThe 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

HeaderTypeDescription
Content-TypestringMust be set to application/json.
accessTokenstringA 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:

FieldTypeDescription
companyNamestringCompany name of this recipient (Optional).
companyEmailstringCompany email of the recipient (Optional)
firstNamestringThe first name of the recipient. (required)
lastNamestringThe last name of the recipient. (optional)
address1stringPrimary address line. (required)
address2stringSecondary address line. (optional, can be null or empty)
phoneNumberstringContact phone number for the address. (optional, can be null or empty)
citystringCity of the address. (required)
statestringState of the address. (required)
countrystringCountry of the address. (required)
zipcodestringPostal code of the address. (required)
isDefaultAddressbooleanIndicates whether this is the default address. (required)
metaFieldsarrayArray 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:

FieldTypeDescription
codestringUnique code identifying the meta field. (required)
valuemixedThe 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 CodeDescription
200 OKThe request was successful and the server will return a list of all the addresses associated with the company.

Success Response Body Structure

FieldTypeDescription
successbooleanIndicates if the request was successful.
messagestringMessage indicating the result of the operation.
dataobjectContains 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:

FieldTypeDescription
firstNameStringFirst name of the recipient.
lastNameStringLast name of the recipient.
address1StringPrimary address line.
address2StringSecondary address line (optional).
phoneNumberStringContact phone number.
cityStringCity of the shipping address.
stateObjectState information (contains name and code).
countryObjectCountry information (contains name and code).
zipcodeStringPostal code of the shipping address.
isDefaultAddressBooleanIndicates if this is the default shipping address.
statusBooleanStatus of the address (e.g., active or inactive).
metaFieldsArrayAdditional meta information associated with the address (optional).
createdAtStringDate and time the address was created (ISO format).
updatedAtStringDate and time the address was last updated (ISO format).
companyStringThe company associated with the shipping address.
idStringUnique identifier for the shipping address.

Error Responses

Status CodeDescription
400 Bad RequestInvalid request format or missing data.
401 UnauthorizedInvalid or missing access token.
403 ForbiddenAccess denied.
404 Not FoundCompany or shipping address not found.
500 Internal Server ErrorServer encountered an error.

Notes

  • Ensure that the company_id in 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.