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.
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Yes | Name of the company group. |
company | Array | No | IDs of companies to add to the group. |
priceList | String | No | ID of the price list for the group. See Price Lists. |
productGroups | Object | No | Product visibility rules. See below. |
paymentAccess | Object | No | Payment method access rule. See below. |
status | Boolean | No | Whether the group is active. Default is true. |
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, member companies only see products allowed by these rules. Default is false. |
Payment Access Object
| Field | Type | Required | Description |
|---|---|---|---|
mode | String | Yes | inherit uses the store setting. selected allows only the listed methods. |
methods | Array | No | Allowed 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
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request succeeded. |
message | String | Result message. |
data | Object | The 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
companyare moved into this group. Unknown company IDs are skipped. - To list the companies in the group, use Get All Companies with the
companyGroupfilter. - 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.