Create Company
This POST endpoint creates a new company record with specified details, including addresses and metadata fields.
Endpoint
- URL:
/companies - Method:
POST
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Request Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be application/json. |
accessToken | string | Access token for authentication. (required) |
Request Body
The request body should be a JSON object containing details for the new company.
| Field | Type | Description |
|---|---|---|
name | string | The name of the company. Required. |
email | string | The email address associated with the company. Required. |
phoneNumber | string | The primary contact number for the company. Required. |
status | string | Current status of the company (e.g., "active"). Required. |
shippingAddress | array | An array of objects representing the company's shipping addresses. |
billingAddress | array | An array of objects representing the company's billing addresses. |
paymentMethods | Array | An array containing ids of payment method. |
isTaxExempt | Boolean | Does company is Tax Exempt |
paymentTerms | Array | An array containing details of payment terms. |
metaFields | array | An array of meta-information fields for the company. |
notes | string | Optional field for additional notes on the company. |
Address Structure
For both shippingAddress and billingAddress:
| Field | Type | Description |
|---|---|---|
companyName | string | Company name of this contact (Optional). |
companyEmail | string | Company email of the contact (Optional) |
firstName | string | First name of the contact person at this address. |
lastName | string | Last name of the contact person at this address. |
address1 | string | Primary address line. |
address2 | string | Secondary address line. Optional. |
city | string | City of the address. |
state | string | State code of the address (e.g., "NJ"). |
country | string | Country code of the address (e.g., "US"). |
zipcode | string | Postal code of the address. |
phoneNumber | string | Contact phone number for the address. |
isDefaultAddress | boolean | Indicates whether this address is the default for shipping addresses. |
metaFields | array | Meta-information related to the address, such as p21_shipto_id. |
Payment Terms
| Field | Type | Description |
|---|---|---|
paymentTerm | id | Id of payment Term. |
depositRequired | boolean | Is deposit required for placing order |
depositPercentage | number | Deposit percentage need to place order |
Sample Request Body
{
"name": "spruce",
"email": "John@aximcommerce.com",
"phoneNumber": "65161861",
"status": "active",
"shippingAddress": [
{
"firstName": "John",
"lastName": "Don",
"phoneNumber": "65161861",
"address1": "12/4, test st",
"address2": "",
"city": "Elizabeth",
"state": "NJ",
"country": "US",
"zipcode": "07202",
"isDefaultAddress": false,
"metaFields": [
{
"code": "p21_shipto_id",
"value": 100
}
]
}
],
"billingAddress": [
{
"firstName": "Prashanth",
"lastName": "Viru",
"phoneNumber": "65161861",
"address1": "12/4, test st",
"address2": "",
"city": "Elizabeth",
"state": "NJ",
"country": "US",
"zipcode": "07202"
}
],
"metaFields": [
{
"code": "p21_customer_id",
"value": "12543"
}
],
"notes": "NOTE AREA"
}
Response
- Status Code: 200 Created
Success Response Body
A successful response will confirm the creation of the company and include its ID.
{
"success": true,
"message": "Company created successfully",
"data": {
"id": "new_company_id"
// other company details...
}
}
Success Response Body
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates the success status of the request, typically true for a successful operation. |
message | string | A message conveying the outcome of the operation, e.g., "Company created Successfully". |
data | object | Contains the company object detailing the product information just added. |
Error Responses
| Status Code | Description |
|---|---|
| 400 Bad Request | The request body contains invalid data or is missing required fields. |
| 401 Unauthorized | The access token is invalid or missing. |
| 500 Internal Server Error | An error occurred on the server. |
Notes
- Ensure all required fields are provided and correctly formatted.
- Confirm the access token is active and valid for authenticating the request.