Skip to main content

List Departments API

Overview

Retrieves a paginated list of departments for a company.

  • Endpoint: /api/departments/list
  • Method: GET
  • Access: Corporate Admin / Manager

Query Parameters (req.query)

ParameterTypeRequiredDescription
companyIdString (UUID)YesTarget company ID
searchStringNoSearch filter by department name or cost code
pageNumberNoPage number (Default: 1)
limitNumberNoItems per page (Default: 10, Max: 100)

Query Example

GET /api/departments/list?companyId=c478a846-993d-4c8d-bf8d-d77cb3370e01&search=Marketing&page=1&limit=10

Success Response (200 OK)

{
"success": true,
"message": "Departments retrieved successfully",
"data": [
{
"id": "d1234567-89ab-cdef-0123-456789abcdef",
"name": "Marketing",
"budget": "500000.00",
"costCode": "MKT-01",
"_count": {
"users": 15
}
}
],
"pagination": {
"totalItems": 1,
"currentPage": 1,
"totalPages": 1,
"pageSize": 10,
"hasNextPage": false,
"hasPreviousPage": false
}
}

Database Impact

  • Table: departments
  • Operations: SELECT with findMany and count.