Skip to main content

Create Company Group

Creates a new company group. You can set a price list, product visibility rules and payment options for the group, and add companies to it.

HTTP Request​

  • URL: /companyGroup/create
  • Method: POST
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: READ_WRITE_COMPANYGROUP

Request Body​

Send a JSON object with the company group details.

FieldTypeRequiredDescription
nameStringYesName of the company group.
companyArrayNoIDs of companies to add to the group.
priceListStringNoID of the price list for the group. See Price Lists.
productGroupsObjectNoProduct visibility rules. See below.
paymentAccessObjectNoPayment method access rule. See below.
statusBooleanNoWhether the group is active. Default is true.

Product Groups Object​

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

Payment Access Object​

FieldTypeRequiredDescription
modeStringYesinherit uses the store setting. selected allows only the listed methods.
methodsArrayNoAllowed payment methods when mode is selected. Each item has method (payment method ID, required) and types (allowed payment types such as card; empty for all). See Payment Methods.

cURL Example​

curl --location '<BASE_URL>/companyGroup/create' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Wholesale",
"company": ["66b9b3b166169eecd60e5ba8", "66c81e2ed484025cfe9bca3b"],
"priceList": "66ad153dbf8641f96544341d",
"status": true,
"productGroups": {
"groups": [{ "productGroup": "66cda944ee801563b8eec563", "type": "include" }],
"restrictStoreProductVisibility": true
},
"paymentAccess": {
"mode": "selected",
"methods": [{ "method": "6650a1c2e4b0a1b2c3d4e5f6", "types": [] }]
}
}'

Response​

  • 200 OK: The company group was created successfully.
  • 400 Bad Request: The access token is missing or invalid, the body is empty, a field is not valid, or the price list or a product group does not exist.

Sample JSON Response​

{
"success": true,
"message": "CompanyGroup created Successfully",
"data": {
"_id": "66a6dd927d6c18df2d9eb836",
"name": "Wholesale",
"company": [],
"priceList": "66ad153dbf8641f96544341d",
"productGroups": {
"groups": [
{
"productGroup": "66cda944ee801563b8eec563",
"type": "include"
}
],
"restrictStoreProductVisibility": true
},
"status": true,
"taxZones": [],
"paymentAccess": {
"mode": "selected",
"methods": [{ "method": "6650a1c2e4b0a1b2c3d4e5f6", "types": [] }]
},
"createdAt": "2024-07-29T00:08:50.416Z",
"updatedAt": "2024-07-29T00:08:50.416Z"
}
}

Response Details​

FieldTypeDescription
successBooleanWhether the request succeeded.
messageStringResult message.
dataObjectThe new company group.

Company Group Data​

data has the same fields as Get Company Group. The group ID is returned as _id.

Notes​

  • Companies listed in company are moved into this group. Unknown company IDs are skipped.
  • To list the companies in the group, use Get All Companies with the companyGroup filter.
  • A company's group, and the price lists and payment access it brings, apply to that company only. They are not inherited from or shared with its parent or sub-companies. See Corporate Hierarchy and Access.