Get All Company Groups
The GET endpoint retrieves all company groups available in the system.
Endpoint
- URL:
/companyGroup/all - Method:
GET
Authentication
- Header:
accessToken - Type: Bearer Token
- Value:
<ACCESS-TOKEN>
Request Headers
| Header | Type | Description |
|---|---|---|
accessToken | string | Access token for authentication. (required) |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit | int | The maximum number of results to return. |
page | int | The page number of results to retrieve. |
Response
- Status Code: 200 OK
Sample Response Body
{
"success": true,
"data": [
{
"_id": "66a6dd927d6c18df2d9eb836",
"name": "BBC",
"company": [],
"priceList": "66ad153dbf8641f96544341d",
"status": true,
"createdAt": "2024-07-29T00:08:50.416Z",
"updatedAt": "2024-10-03T11:07:39.111Z",
"id": "66a6dd927d6c18df2d9eb836"
},
{
"_id": "66c823f1d484025cfe9bcd52",
"name": "Test one",
"company": [],
"priceList": "66d0f6973560dad7cf821e95",
"status": true,
"createdAt": "2024-08-23T05:53:53.984Z",
"updatedAt": "2024-08-31T18:18:04.335Z",
"productGroups": {
"type": "include",
"productGroups": [],
"_id": "66cd8dc390ea1908a25e2c63"
},
"id": "66c823f1d484025cfe9bcd52"
}
],
"pagination": {
"page": 1,
"total": 2,
"count": 2
}
}
Success Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Indicates the success status of the request, typically true. |
data | array | A list of company group objects. Each object contains detailed info. |
pagination | object | Pagination details of the retrieved company groups. |
Data Array:
Each item in the data array represents a company group and can include the following fields:
| Field | Type | Description |
|---|---|---|
_id | string | Unique identifier of the company group. |
name | string | The name of the company group. |
company | array | List of company IDs linked to this group. |
priceList | string | ID of the associated price list, if any. |
productGroups | object | Object detailing product group associations. |
status | boolean | Active status of the company group (default true). |
createdAt | string | Timestamp when the company group was created. |
updatedAt | string | Timestamp when the company group was last updated. |
id | string | Duplicate of _id, unique identifier. |
ProductGroups Object:
| Field | Type | Description |
|---|---|---|
type | string | Type of association, either "include" or "exclude". |
productGroups | array | List of product group references. |
Pagination Object:
| Field | Type | Description |
|---|---|---|
page | int | Current page number. |
total | int | Total number of company groups. |
count | int | Number of company groups on this page. |
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request: Invalid input data. |
| 401 | Unauthorized: Access token is invalid or missing. |
| 500 | Internal Server Error: An error occurred on the server. |
Notes
- Ensure you provide a valid and active access token in the request header to authenticate your request.
- The response includes pagination details for handling large sets of data.
- The
productGroupsfield can specify whether products are included or excluded via associations.