Skip to main content

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​

ParameterTypeDescription
idStringThe 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.

FieldTypeRequiredDescription
nameStringNoName of the company group.
companyArrayNoIDs of companies to add to the group.
removeCompaniesArrayNoIDs of companies to remove from the group.
priceListStringNoID of the price list for the group. Send null to remove it.
productGroupsObjectNoProduct visibility rules. Replaces the current rules. Same format as in Create Company Group.
paymentAccessObjectNoPayment method access rule. Replaces the current rule. Same format as in Create Company Group.
statusBooleanNoWhether 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 success to 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​

FieldTypeDescription
successBooleanWhether the request succeeded.
messageStringResult message.
dataObjectThe 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, success is false and message is CompanyGroup not found.
  • Companies added with company are 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.