Update Company Group
Updates an existing company group. Only the fields you send are changed. Use company to add companies to the group and removeCompanies to remove them.
HTTP Request
- URL:
/companyGroup/update/{id} - Method:
PUT - Headers:
accessToken: Required. Your API access token.Content-Type:application/json
- Required scope:
READ_WRITE_COMPANYGROUP
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | String | The ID of the company group to update. |
Request Body
Send a JSON object with the fields to update. All fields are optional, but the body cannot be empty.
| Field | Type | Required | Description |
|---|---|---|---|
name | String | No | Name of the company group. |
company | Array | No | IDs of companies to add to the group. |
removeCompanies | Array | No | IDs of companies to remove from the group. |
priceList | String | No | ID of the price list for the group. Send null to remove it. |
productGroups | Object | No | Product visibility rules. Replaces the current rules. Same format as in Create Company Group. |
paymentAccess | Object | No | Payment method access rule. Replaces the current rule. Same format as in Create Company Group. |
status | Boolean | No | Whether the group is active. |
cURL Example
curl --location --request PUT '<BASE_URL>/companyGroup/update/66a6dd927d6c18df2d9eb836' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"name": "Wholesale Tier 1",
"company": ["66d0f6973560dad7cf821e95"],
"removeCompanies": ["66c81e2ed484025cfe9bca3b"],
"paymentAccess": { "mode": "inherit" }
}'
Response
- 200 OK: The request was processed. Check
successto confirm the group was updated. - 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 updated Successfully",
"data": {
"_id": "66a6dd927d6c18df2d9eb836",
"id": "66a6dd927d6c18df2d9eb836",
"name": "Wholesale Tier 1",
"company": ["66d0f6973560dad7cf821e95"],
"priceList": "66ad153dbf8641f96544341d",
"status": true,
"taxZones": [],
"paymentAccess": { "mode": "inherit", "methods": [] },
"createdAt": "2024-07-29T00:08:50.416Z",
"updatedAt": "2024-10-03T11:07:39.111Z"
}
}
Response Details
| Field | Type | Description |
|---|---|---|
success | Boolean | Whether the request succeeded. |
message | String | Result message. |
data | Object | The updated company group. |
Company Group Data
data has the same fields as Get Company Group. The company field lists the companies added in this request.
Notes
- If no company group matches the ID,
successisfalseandmessageisCompanyGroup not found. - Companies added with
companyare moved out of any other group. - Unknown company IDs are skipped.
- 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.