Departments API
v1.0 • REST • JSON
Full CRUD management for department accounts. Create, retrieve, update, and delete department records with built-in pagination and role-based access control support.
Quick Reference
/api/departments
200 OK
Get All Departments
Retrieves a paginated list of all departments in the system. Use the pageNumber
and pageSize query parameters to navigate large result sets.
The response envelope includes total count and page metadata.
| Parameter | Type | Default | Description |
|---|---|---|---|
pageNumber |
integer | 1 |
Page number, 1-based index. Values below 1 are treated as 1. |
pageSize |
integer | 10 |
Number of records per page, from 1 to 100. Values outside this range are clamped. |
/api/departments/{id}
200 OK
Get Single Department
Fetch the full profile for a specific department using their numeric ID. Returns all department fields including assigned role names and account metadata.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer | Required | Unique department identifier |
/api/departments/{id}
404 Not Found
Department Not Found
Returned when the requested department ID does not exist in the system. Use this example to test error-handling logic and build graceful fallback UI for missing department resources.
/api/departments
201 Created
Create Department
Creates a new department in an existing organisation. On success, returns 201 Created with the new department. Returns 400 Bad Request if the organisation does not exist.
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Required | Name |
organisationId |
integer | Required | Organisation id |
/api/departments/{id}
200 OK
Update Department
Fully replaces an existing department's data with the values in the request body. A successful update returns 200 OK with response body.
| Field | Type | Required | Description |
|---|---|---|---|
name |
string | Required | Name |
organisationId |
integer | Required | Organisation id |
/api/departments/{id}
204 No Content
Delete Department
Permanently removes a department by its ID, together with its teams. Returns 409 Conflict while the department still has employees; delete or move them first. This action cannot be undone.
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer | Required | ID of the department to delete |