Skip to main content

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

HeaderTypeDescription
accessTokenstringAccess token for authentication. (required)

Query Parameters

ParameterTypeDescription
limitintThe maximum number of results to return.
pageintThe 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

FieldTypeDescription
successbooleanIndicates the success status of the request, typically true.
dataarrayA list of company group objects. Each object contains detailed info.
paginationobjectPagination details of the retrieved company groups.

Data Array:

Each item in the data array represents a company group and can include the following fields:

FieldTypeDescription
_idstringUnique identifier of the company group.
namestringThe name of the company group.
companyarrayList of company IDs linked to this group.
priceListstringID of the associated price list, if any.
productGroupsobjectObject detailing product group associations.
statusbooleanActive status of the company group (default true).
createdAtstringTimestamp when the company group was created.
updatedAtstringTimestamp when the company group was last updated.
idstringDuplicate of _id, unique identifier.

ProductGroups Object:

FieldTypeDescription
typestringType of association, either "include" or "exclude".
productGroupsarrayList of product group references.

Pagination Object:

FieldTypeDescription
pageintCurrent page number.
totalintTotal number of company groups.
countintNumber of company groups on this page.

Error Responses

Status CodeDescription
400Bad Request: Invalid input data.
401Unauthorized: Access token is invalid or missing.
500Internal 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 productGroups field can specify whether products are included or excluded via associations.