Skip to main content

Update Company Group

The PUT endpoint updates the details of an existing company group specified by companyGroup_id.

Endpoint

  • URL: /companyGroup/update/{companyGroup_id}
  • Method: PUT

Authentication

  • Header: accessToken
  • Type: Bearer Token
  • Value: <ACCESS-TOKEN>

Path Parameters

ParameterTypeDescription
companyGroup_idstringThe unique identifier of the company group to update.

Request Headers

HeaderTypeDescription
Content-TypestringMust be application/json.
accessTokenstringAccess token for authentication. (required)

Request Body

The request body should include the updated details for the company group. Below are the fields that can be updated:

FieldTypeDescription
namestringThe updated name of the company group.
companyarrayList of company IDs to be added to this group.
removeCompaniesarrayList of company IDs to be removed from this group.
priceListstringThe ID of the associated price list, if applicable.
statusbooleanActive status of the company group (e.g., true).
productGroupsobjectSpecifies how product groups are associated.

ProductGroups Object:

FieldTypeDescription
typestringType of association: either "include" or "exclude".
productGroupsarrayList of product group IDs linked to this association.

Sample Request Body

Example 1: Basic Update with Adding Companies

{
"name": "company group api update",
"company": ["654b42c9fc6b6ac13911e818"],
"priceList": "66e2e8566e19a7f9d9a11360",
"status": true,
"productGroups": {
"type": "include",
"productGroups": ["66cda944ee801563b8eec563", "66430b9b11217fd086e1d1a5"]
}
}

Example 2: Removing Companies from Group

{
"removeCompanies": ["654b42c9fc6b6ac13911e818", "654b42c9fc6b6ac13911e819"]
}

Example 3: Adding and Removing Companies in Same Request

{
"name": "Updated Premium Group",
"company": ["654b42c9fc6b6ac13911e820"],
"removeCompanies": ["654b42c9fc6b6ac13911e818"],
"status": true
}

Response

  • Status Code: 200 OK

Sample Response Body

{
"success": true,
"message": "Company group updated successfully",
"data": {
// Details of the updated company group, e.g., ID, name, etc.
}
}

Success Response Fields

FieldTypeDescription
successbooleanIndicates the success status of the request, typically true for a successful operation.
messagestringA message conveying the outcome of the operation, e.g., "Company group updated successfully".
dataobjectContains details of the updated company group, such as its ID and attributes.

Error Responses

Status CodeDescription
400Bad Request: Invalid input data.
401Unauthorized: Access token is invalid or missing.
404Not Found: The specified company group could not be found.
500Internal Server Error: An error occurred on the server.

Notes

  • Ensure you replace {companyGroup_id} in the URL with the actual unique identifier of the company group being updated.
  • Provide a valid and active access token in the request header to authenticate your request.
  • The productGroups field allows you to specify whether to include or exclude specific product groups.
  • Company Management:
    • Use the company field to add new companies to the group
    • Use the removeCompanies field to remove existing companies from the group
    • Both fields can be used in the same request to add and remove companies simultaneously
    • Companies in the removeCompanies array will only be removed if they currently belong to this specific company group
    • Invalid company IDs in either field will be silently ignored
    • The operation order is: first add companies, then remove companies