Add Addresses
Adds one or more addresses to a company. The request body is a JSON array, and each item can be a billing or a shipping address.
HTTP Request
- URL:
/address/company/{companyId} - Method:
POST - 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 to add the addresses to. |
Request Body
Send a JSON array with at least one address object.
| Field | Type | Required | Description |
|---|---|---|---|
type | String | No | shipping or billing. Default is shipping. |
address1 | String | Yes | Address line 1. |
city | String | Yes | City. |
state | String | Yes | State code, for example NJ. |
country | String | Yes | Country code, for example US. |
zipcode | String | Yes | Postal code. |
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 default address of its type. Only one per type. |
metaFields | Array | No | Custom field values as code and value. See Metafields. |
cURL Example
curl --location '<BASE_URL>/address/company/66b9b3b166169eecd60e5ba8' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '[
{
"type": "shipping",
"firstName": "John",
"lastName": "Doe",
"address1": "3700 Old Seward Hwy",
"city": "Anchorage",
"state": "AK",
"country": "US",
"zipcode": "99503",
"isDefaultAddress": true
},
{
"type": "billing",
"companyName": "Keystone Building Supply",
"address1": "102 East Green Milton Road",
"city": "Elizabeth",
"state": "NJ",
"country": "US",
"zipcode": "07202"
}
]'
Response
- 200 OK: The addresses were added 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 of the same type is marked as default.
Sample JSON Response
{
"success": true,
"message": "Addresses added successfully",
"data": [
{
"id": "66b9b3b166169eecd60e5baa",
"company": "66b9b3b166169eecd60e5ba8",
"type": "shipping",
"firstName": "John",
"lastName": "Doe",
"address1": "3700 Old Seward Hwy",
"city": "Anchorage",
"state": { "code": "AK", "name": "Alaska" },
"country": { "code": "US", "name": "United States" },
"zipcode": "99503",
"isDefaultAddress": true,
"status": true,
"metaFields": [],
"createdAt": "2024-08-23T13:27:13.715Z",
"updatedAt": "2024-08-23T13:27:13.715Z"
},
{
"id": "66b9b3b166169eecd60e5bab",
"company": "66b9b3b166169eecd60e5ba8",
"type": "billing",
"companyName": "Keystone Building Supply",
"address1": "102 East Green Milton Road",
"city": "Elizabeth",
"state": { "code": "NJ", "name": "New Jersey" },
"country": { "code": "US", "name": "United States" },
"zipcode": "07202",
"isDefaultAddress": false,
"status": true,
"metaFields": [],
"createdAt": "2024-08-23T13:27:13.715Z",
"updatedAt": "2024-08-23T13:27:13.715Z"
}
]
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request succeeded. |
message | String | Result message. |
data | Array | The new addresses. |
Address Data
Each item in data has the same fields as the address returned by Get Address by ID.
Notes
- When an address is marked as default, the company's previous default address of that type is no longer the default.