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
| Parameter | Type | Description |
|---|---|---|
companyGroup_id | string | The unique identifier of the company group to update. |
Request Headers
| Header | Type | Description |
|---|---|---|
Content-Type | string | Must be application/json. |
accessToken | string | Access 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:
| Field | Type | Description |
|---|---|---|
name | string | The updated name of the company group. |
company | array | List of company IDs to be added to this group. |
removeCompanies | array | List of company IDs to be removed from this group. |
priceList | string | The ID of the associated price list, if applicable. |
status | boolean | Active status of the company group (e.g., true). |
productGroups | object | Specifies how product groups are associated. |
ProductGroups Object:
| Field | Type | Description |
|---|---|---|
type | string | Type of association: either "include" or "exclude". |
productGroups | array | List 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
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates the success status of the request, typically true for a successful operation. |
message | string | A message conveying the outcome of the operation, e.g., "Company group updated successfully". |
data | object | Contains details of the updated company group, such as its ID and attributes. |
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request: Invalid input data. |
| 401 | Unauthorized: Access token is invalid or missing. |
| 404 | Not Found: The specified company group could not be found. |
| 500 | Internal 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
productGroupsfield allows you to specify whether to include or exclude specific product groups. - Company Management:
- Use the
companyfield to add new companies to the group - Use the
removeCompaniesfield 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
removeCompaniesarray 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
- Use the