Create Company
Creates a new company. In the same request you can add its billing and shipping addresses, assign it to a company group, set its payment options, and add users to it.
HTTP Request
- URL:
/companies - Method:
POST - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_WRITE_COMPANY
Request Body
Send a JSON object with the company details.
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Name of the company. |
email | String | No | Email address of the company. |
phoneNumber | String | No | Phone number of the company. |
status | String | No | pending, active or inactive. Default is pending. |
notes | String | No | Internal notes about the company. |
logo | String | No | URL of the company logo. |
isTaxExempt | Boolean | No | Whether the company is tax exempt. Default is false. |
taxExemptCode | String | No | Tax exemption code. |
taxExemptFileUrl | String | No | URL of the tax exemption certificate. |
companyGroup | String | No | ID of the company group to assign the company to. |
priceLists | Array | No | IDs of price lists. See Price Lists. |
productGroups | Object | No | Product visibility rules. See below. |
paymentMethods | Array | No | IDs of the payment methods the company may use. |
paymentAccess | Object | No | Payment method access rule. See below. |
paymentTerms | Array | No | Payment terms. See below. |
metaFields | Array | No | Custom field values as code and value. See Metafields. |
billingAddress | Array | No | Billing addresses. At least one item if sent. See below. |
shippingAddress | Array | No | Shipping addresses. See below. |
userIds | Array | No | IDs of existing customers to add to the company. |
users | Array | No | New users to create in the company. Used when userIds is not sent. See below. |
Product Groups Object
| Field | Type | Required | Description |
|---|---|---|---|
groups | Array | No | Product group rules. Each item has productGroup (ID) and type (include or exclude), both required. See Product Groups. |
restrictStoreProductVisibility | Boolean | No | When true, the company only sees products allowed by these rules. Default is false. |
Payment Access Object
| Field | Type | Required | Description |
|---|---|---|---|
mode | String | Yes | inherit uses the company group or store setting. selected allows only the listed methods. |
methods | Array | No | Allowed payment methods when mode is selected. See below. |
Payment Access Method Object
| Field | Type | Required | Description |
|---|---|---|---|
method | String | Yes | ID of the payment method. See Payment Methods. |
types | Array | No | Allowed payment types, such as card or us_bank_account. Leave empty to allow all types. |
Payment Terms Object
| Field | Type | Required | Description |
|---|---|---|---|
paymentTerm | String | Yes | ID of the payment term. See Payment Terms. |
depositRequired | Boolean | No | Whether a deposit is required. Default is false. |
depositPercentage | Number | No | Deposit percentage. Default is 0. |
Address Object
Used for both billingAddress and shippingAddress.
| Field | Type | Required | Description |
|---|---|---|---|
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 | Whether this is the default address. Default is false. |
status | Boolean | No | Whether the address is active. Default is true. |
metaFields | Array | No | Custom field values as code and value. |
addressId | String | No | ID to use for the new address. |
User Object
| Field | Type | Required | Description |
|---|---|---|---|
firstName | String | Yes | First name of the user. |
lastName | String | Yes | Last name of the user. Can be empty. |
email | String | Yes | Email address of the user. |
phoneNumber | String | No | Phone number of the user. |
notes | String | No | Notes about the user. |
metaFields | Array | No | Custom field values as code and value. |
cURL Example
curl --location '<BASE_URL>/companies' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Keystone Building Supply",
"email": "purchasing@keystonebuild.com",
"phoneNumber": "9085551234",
"status": "active",
"companyGroup": "66a6dd927d6c18df2d9eb836",
"paymentAccess": {
"mode": "selected",
"methods": [
{ "method": "6650a1c2e4b0a1b2c3d4e5f6", "types": ["card", "us_bank_account"] }
]
},
"paymentTerms": [
{ "paymentTerm": "6650a2d3e4b0a1b2c3d4e5f7", "depositRequired": false }
],
"billingAddress": [
{
"firstName": "John",
"lastName": "Doe",
"address1": "102 East Green Milton Road",
"city": "Elizabeth",
"state": "NJ",
"country": "US",
"zipcode": "07202",
"isDefaultAddress": true
}
],
"shippingAddress": [
{
"firstName": "John",
"lastName": "Doe",
"address1": "3700 Old Seward Hwy",
"city": "Anchorage",
"state": "AK",
"country": "US",
"zipcode": "99503",
"isDefaultAddress": true
}
],
"metaFields": [{ "code": "erp_customer_id", "value": "12543" }],
"userIds": ["66c81e2ed484025cfe9bca3c"]
}'
Response
- 200 OK: The company was created successfully.
- 400 Bad Request: The access token is missing or invalid, the body is empty, or a field is missing or not valid.
Sample JSON Response
{
"success": true,
"message": "Company created successfully",
"data": {
"id": "66b9b3b166169eecd60e5ba8",
"entityId": 22,
"name": "Keystone Building Supply",
"email": "purchasing@keystonebuild.com",
"phoneNumber": "9085551234",
"status": "active",
"logo": null,
"isLock": false,
"priceLists": [],
"companyGroup": "66a6dd927d6c18df2d9eb836",
"shippingMethods": [],
"paymentMethods": ["6650a1c2e4b0a1b2c3d4e5f6"],
"paymentAccess": {
"mode": "selected",
"methods": [
{ "method": "6650a1c2e4b0a1b2c3d4e5f6", "types": ["card", "us_bank_account"] }
]
},
"paymentTerms": [
{
"paymentTerm": "6650a2d3e4b0a1b2c3d4e5f7",
"depositRequired": false,
"depositPercentage": 0
}
],
"isSubCompany": false,
"parents": [],
"isTaxExempt": false,
"taxExemptFileUrl": null,
"warehouses": [],
"metaFields": [
{
"metaFieldId": "6643a1f2e4b0a1b2c3d4e600",
"code": "erp_customer_id",
"label": "ERP Customer ID",
"displayStorefront": false,
"value": "12543",
"valueType": "text"
}
],
"createdBy": {
"id": "64f0a70c6212cdcbe89a2402",
"name": "ERP integration",
"type": "api"
},
"createdAt": "2024-08-12T07:03:13.111Z",
"updatedAt": "2024-08-12T07:03:13.111Z"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request succeeded. |
message | String | Result message. |
data | Object | The new company. See below. |
Company Data
data has the same company fields as Get Company, except that companyGroup is the group ID and the addresses are not included. Use Get Company Addresses to read the addresses.
Notes
- If you send
paymentAccess,paymentMethodsis set to the methods in it. If you send onlypaymentMethods, the company is limited to those methods. - Customers listed in
userIdsare moved into the new company. Any per-user access those customers had in another parent company's sub-companies is removed. - New users in
usersare created with the admin role. - A company's parents can't be set when creating it.
parents,parentId,parentIdsandisSubCompanyare rejected ("<field>" is not allowed). To link it afterwards, useparentCompanieson Update Company, or the Corporate endpoints.parentId(deprecated) andparentIdsare returned by the Get endpoints and by Update Company. This response has theparentsarray.