Skip to main content

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.

FieldTypeRequiredDescription
nameStringYesName of the company.
emailStringNoEmail address of the company.
phoneNumberStringNoPhone number of the company.
statusStringNopending, active or inactive. Default is pending.
notesStringNoInternal notes about the company.
logoStringNoURL of the company logo.
isTaxExemptBooleanNoWhether the company is tax exempt. Default is false.
taxExemptCodeStringNoTax exemption code.
taxExemptFileUrlStringNoURL of the tax exemption certificate.
companyGroupStringNoID of the company group to assign the company to.
priceListsArrayNoIDs of price lists. See Price Lists.
productGroupsObjectNoProduct visibility rules. See below.
paymentMethodsArrayNoIDs of the payment methods the company may use.
paymentAccessObjectNoPayment method access rule. See below.
paymentTermsArrayNoPayment terms. See below.
metaFieldsArrayNoCustom field values as code and value. See Metafields.
billingAddressArrayNoBilling addresses. At least one item if sent. See below.
shippingAddressArrayNoShipping addresses. See below.
userIdsArrayNoIDs of existing customers to add to the company.
usersArrayNoNew users to create in the company. Used when userIds is not sent. See below.

Product Groups Object​

FieldTypeRequiredDescription
groupsArrayNoProduct group rules. Each item has productGroup (ID) and type (include or exclude), both required. See Product Groups.
restrictStoreProductVisibilityBooleanNoWhen true, the company only sees products allowed by these rules. Default is false.

Payment Access Object​

FieldTypeRequiredDescription
modeStringYesinherit uses the company group or store setting. selected allows only the listed methods.
methodsArrayNoAllowed payment methods when mode is selected. See below.

Payment Access Method Object​

FieldTypeRequiredDescription
methodStringYesID of the payment method. See Payment Methods.
typesArrayNoAllowed payment types, such as card or us_bank_account. Leave empty to allow all types.

Payment Terms Object​

FieldTypeRequiredDescription
paymentTermStringYesID of the payment term. See Payment Terms.
depositRequiredBooleanNoWhether a deposit is required. Default is false.
depositPercentageNumberNoDeposit percentage. Default is 0.

Address Object​

Used for both billingAddress and shippingAddress.

FieldTypeRequiredDescription
address1StringYesAddress line 1.
cityStringYesCity.
stateStringYesState code, for example NJ.
countryStringYesCountry code, for example US.
zipcodeStringYesPostal code.
firstNameStringNoFirst name of the contact.
lastNameStringNoLast name of the contact.
companyNameStringNoCompany name shown on the address.
companyEmailStringNoEmail address for the address.
address2StringNoAddress line 2.
phoneNumberStringNoPhone number of the contact.
isDefaultAddressBooleanNoWhether this is the default address. Default is false.
statusBooleanNoWhether the address is active. Default is true.
metaFieldsArrayNoCustom field values as code and value.
addressIdStringNoID to use for the new address.

User Object​

FieldTypeRequiredDescription
firstNameStringYesFirst name of the user.
lastNameStringYesLast name of the user. Can be empty.
emailStringYesEmail address of the user.
phoneNumberStringNoPhone number of the user.
notesStringNoNotes about the user.
metaFieldsArrayNoCustom 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​

FieldTypeDescription
successBooleanWhether the request succeeded.
messageStringResult message.
dataObjectThe 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, paymentMethods is set to the methods in it. If you send only paymentMethods, the company is limited to those methods.
  • Customers listed in userIds are moved into the new company. Any per-user access those customers had in another parent company's sub-companies is removed.
  • New users in users are created with the admin role.
  • A company's parents can't be set when creating it. parents, parentId, parentIds and isSubCompany are rejected ("<field>" is not allowed). To link it afterwards, use parentCompanies on Update Company, or the Corporate endpoints. parentId (deprecated) and parentIds are returned by the Get endpoints and by Update Company. This response has the parents array.