WORKFORCEOS
FRONTEND GUIDE FOR AI CODING AGENTS - PART 9 - AttendanceManagement Service
This document is a part of a REST API guide for the workforceos project. It is designed for AI agents that will generate frontend code to consume the project’s backend.
This document provides extensive instruction for the usage of attendanceManagement
Service Access
AttendanceManagement service management is handled through service specific base urls.
AttendanceManagement service may be deployed to the preview server, staging server, or production server. Therefore,it has 3 access URLs. The frontend application must support all deployment environments during development, and the user should be able to select the target API server on the login page (already handled in first part.).
For the attendanceManagement service, the base URLs are:
- Preview:
https://workforceos.prw.mindbricks.com/attendancemanagement-api - Staging:
https://workforceos-stage.mindbricks.co/attendancemanagement-api - Production:
https://workforceos.mindbricks.co/attendancemanagement-api
Tenant URL Prefix and Header Forwarding
Tenant context is resolved by frontend routing strategy:
- preview/test: URL prefix
/{tenantCodename}(example:/babil/products) - production: tenant subdomain (example:
babil.appname...)
Then backend API calls must always claim target tenant with header:
headers["mbx-company-codename"] = tenantCodenameFromUrl;
URL prefix/subdomain is frontend-only tenant selection. Use header forwarding for all tenant-scoped calls to attendanceManagement service.
Scope
AttendanceManagement Service Description
Handles employee attendance logging (check-in/out), attendance rules (lateness/absence/early-leave), real-time & historical logs, and publishes notification events. Enforces company data isolation, strict record uniqueness, and one-per-shift attendance rule.
AttendanceManagement service provides apis and business logic for following data objects in workforceos application. Each data object may be either a central domain of the application data structure or a related helper data object for a central concept. Note that data object concept is equal to table concept in the database, in the service database each data object is represented as a db table scheme and the object instances as table rows.
attendanceRecord Data Object: Records a specific user’s attendance for a shift (check-in/out), with status (present, absent, late, leftEarly, pending), lateness minutes, absence reason, and manager/admin notes. Enforces strict uniqueness (one record per user per shift per day) and company-level data isolation.
AttendanceManagement Service Frontend Description By The Backend Architect
This service provides the core backend for check-in/out operations, attendance history display, late/absent detection, and notification triggers to the notification infrastructure. All APIs are strictly company-scoped and role-based: admins/managers have access to all records, employees only to their own. Date/time displays and filtering should be in the company’s local time (handled by frontend). For employees, self-service: Show check-in/out actions only for active assigned shifts, with clear feedback on status (‘checked in’, ‘late’, ‘absent’ only appears after the shift/day). Manager/admin UI must include tools for reviewing attendance by date/employee/shift with visual cues for late/absent; allow manual absence reason/note edits by authorized roles. Pending (not checked out) states must be highlighted for managers/admins and the user.
API Structure
Object Structure of a Successful Response
When the service processes requests successfully, it wraps the requested resource(s) within a JSON envelope. This envelope includes the data and essential metadata such as configuration details and pagination information, providing context to the client.
HTTP Status Codes:
- 200 OK: Returned for successful GET, LIST, UPDATE, or DELETE operations, indicating that the request was processed successfully.
- 201 Created: Returned for CREATE operations, indicating that the resource was created successfully.
Success Response Format:
For successful operations, the response includes a "status": "OK" property, signaling that the request executed successfully. The structure of a successful response is outlined below:
{
"status":"OK",
"statusCode": 200,
"elapsedMs":126,
"ssoTime":120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName":"products",
"method":"GET",
"action":"list",
"appVersion":"Version",
"rowCount":3,
"products":[{},{},{}],
"paging": {
"pageNumber":1,
"pageRowCount":25,
"totalRowCount":3,
"pageCount":1
},
"filters": [],
"uiPermissions": []
}
products: In this example, this key contains the actual response content, which may be a single object or an array of objects depending on the operation.
Additional Data
Each API may include additional data besides the main data object, depending on the business logic of the API. These will be provided in each API’s response signature.
Error Response
If a request encounters an issue—whether due to a logical fault or a technical problem—the service responds with a standardized JSON error structure. The HTTP status code indicates the nature of the error, using commonly recognized codes for clarity:
- 400 Bad Request: The request was improperly formatted or contained invalid parameters.
- 401 Unauthorized: The request lacked a valid authentication token; login is required.
- 403 Forbidden: The current token does not grant access to the requested resource.
- 404 Not Found: The requested resource was not found on the server.
- 500 Internal Server Error: The server encountered an unexpected condition.
Each error response is structured to provide meaningful insight into the problem, assisting in efficient diagnosis and resolution.
{
"result": "ERR",
"status": 400,
"message": "errMsg_organizationIdisNotAValidID",
"errCode": 400,
"date": "2024-03-19T12:13:54.124Z",
"detail": "String"
}
AttendanceRecord Data Object
Records a specific user’s attendance for a shift (check-in/out), with status (present, absent, late, leftEarly, pending), lateness minutes, absence reason, and manager/admin notes. Enforces strict uniqueness (one record per user per shift per day) and company-level data isolation.
AttendanceRecord Data Object Frontend Description By The Backend Architect
Represents a single attendance event with check-in and checkout. Use ‘status’ to show if user was present, absent, late, leftEarly, or pending (not checked out yet). Display absenceReason and managerNote only to admins/managers. Employees cannot edit records other than own check-in/out. Enforced 1 record per user/shift/day.
AttendanceRecord Data Object Properties
AttendanceRecord data object has got following properties that are represented as table fields in the database scheme. These properties don’t stand just for data storage, but each may have different settings to manage the business logic.
| Property | Type | IsArray | Required | Secret | Description |
|---|---|---|---|---|---|
userId |
ID | false | Yes | No | Referenced user (employee) |
shiftId |
ID | false | Yes | No | Related shift |
checkInTime |
Date | false | Yes | No | User check-in timestamp (set on check-in) |
checkOutTime |
Date | false | No | No | User check-out timestamp (set on check-out) |
status |
Enum | false | Yes | No | Attendance status: present, absent, late, leftEarly, pending (checked in, not yet out) |
lateByMinutes |
Integer | false | No | No | How many minutes late (if late) |
absenceReason |
String | false | No | No | Reason for absence (manager-provided, e.g., sick, leave) |
managerNote |
Text | false | No | No | Manager/admin note (optional for manual absence management) |
companyId |
ID | false | Yes | No | An ID value to represent the tenant id of the company |
- Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.
Enum Properties
Enum properties are defined with a set of allowed values, ensuring that only valid options can be assigned to them. The enum options value will be stored as strings in the database, but when a data object is created an additional property with the same name plus an idx suffix will be created, which will hold the index of the selected enum option. You can use the {fieldName_idx} property to sort by the enum value or when your enum options represent a hiyerarchy of values. In the frontend input components, enum type properties should only accept values from an option component that lists the enum options.
- status: [pending, present, absent, late, leftEarly]
Relation Properties
userId shiftId
Mindbricks supports relations between data objects, allowing you to define how objects are linked together. The relations may reference to a data object either in this service or in another service. Id the reference is remote, backend handles the relations through service communication or elastic search. These relations should be respected in the frontend so that instaead of showing the related objects id, the frontend should list human readable values from other data objects. If the relation points to another service, frontend should use the referenced service api in case it needs related data. The relation logic is montly handled in backend so the api responses feeds the frontend about the relational data. In mmost cases the api response will provide the relational data as well as the main one.
In frontend, please ensure that,
1- instaead of these relational ids you show the main human readable field of the related target data (like name), 2- if this data object needs a user input of these relational ids, you should provide a combobox with the list of possible records or (a searchbox) to select with the realted target data object main human readable field.
- userId: ID
Relation to
user.id
The target object is a sibling object, meaning that the relation is a many-to-one or one-to-one relationship from this object to the target.
Required: Yes
- shiftId: ID
Relation to
shift.id
The target object is a sibling object, meaning that the relation is a many-to-one or one-to-one relationship from this object to the target.
Required: Yes
Filter Properties
userId shiftId status companyId
Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria. These properties are automatically mapped as API parameters in the listing API’s.
-
userId: ID has a filter named
userId -
shiftId: ID has a filter named
shiftId -
status: Enum has a filter named
status -
companyId: ID has a filter named
companyId
Default CRUD APIs
For each data object, the backend architect may designate default APIs for standard operations (create, update, delete, get, list). These are the APIs that frontend CRUD forms and AI agents should use for basic record management. If no default is explicitly set (isDefaultApi), the frontend generator auto-discovers the most general API for each operation.
AttendanceRecord Default APIs
| Operation | API Name | Route | Explicitly Set |
|---|---|---|---|
| Create | checkInAttendance |
/v1/check-in |
Yes |
| Update | checkOutAttendance |
/v1/check-out |
Yes |
| Delete | none | - | Auto |
| Get | getAttendanceRecord |
/v1/attendance-records/:attendanceRecordId |
Yes |
| List | listAttendanceRecords |
/v1/attendance-records |
Yes |
When building CRUD forms for a data object, use the default create/update APIs listed above. The form fields should correspond to the API’s body parameters. For relation fields, render a dropdown loaded from the related object’s list API using the display label property.
API Reference
Check Inattendance API
[Default create API] — This is the designated default create API for the attendanceRecord data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Allows a user to check in for an assigned shift. Enforces strict one-record-per-user/shift/day, automatically determines status (present/late). Records check-in timestamp; only permitted if user assigned to shift.
API Frontend Description By The Backend Architect
Rendered as employee’s check-in button for assigned shift. Shows feedback on result (on-time/late/error). Manager/admin may impersonate check-in (override role checks).
Rest Route
The checkInAttendance API REST controller can be triggered via the following route:
/v1/check-in
Rest Request Parameters
The checkInAttendance api has got 8 regular request parameters
| Parameter | Type | Required | Population |
|---|---|---|---|
| shiftId | ID | true | request.body?.[“shiftId”] |
| userId | ID | true | request.body?.[“userId”] |
| checkInTime | Date | true | request.body?.[“checkInTime”] |
| checkOutTime | Date | false | request.body?.[“checkOutTime”] |
| status | Enum | true | request.body?.[“status”] |
| lateByMinutes | Integer | false | request.body?.[“lateByMinutes”] |
| absenceReason | String | false | request.body?.[“absenceReason”] |
| managerNote | Text | false | request.body?.[“managerNote”] |
| shiftId : ID of the shift for check-in | |||
| userId : Referenced user (employee) | |||
| checkInTime : User check-in timestamp (set on check-in) | |||
| checkOutTime : User check-out timestamp (set on check-out) | |||
| status : Attendance status: present, absent, late, leftEarly, pending (checked in, not yet out) | |||
| lateByMinutes : How many minutes late (if late) | |||
| absenceReason : Reason for absence (manager-provided, e.g., sick, leave) | |||
| managerNote : Manager/admin note (optional for manual absence management) |
REST Request To access the api you can use the REST controller with the path POST /v1/check-in
axios({
method: 'POST',
url: '/v1/check-in',
data: {
shiftId:"ID",
userId:"ID",
checkInTime:"Date",
checkOutTime:"Date",
status:"Enum",
lateByMinutes:"Integer",
absenceReason:"String",
managerNote:"Text",
},
params: {
}
});
REST Response
{
"status": "OK",
"statusCode": "201",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "attendanceRecord",
"method": "POST",
"action": "create",
"appVersion": "Version",
"rowCount": 1,
"attendanceRecord": {
"id": "ID",
"userId": "ID",
"shiftId": "ID",
"checkInTime": "Date",
"checkOutTime": "Date",
"status": "Enum",
"status_idx": "Integer",
"lateByMinutes": "Integer",
"absenceReason": "String",
"managerNote": "Text",
"companyId": "ID",
"isActive": true,
"recordVersion": "Integer",
"createdAt": "Date",
"updatedAt": "Date",
"_owner": "ID"
}
}
Check Outattendance API
[Default update API] — This is the designated default update API for the attendanceRecord data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Sets check-out timestamp and updates status (if left early), allowed only if check-in exists but no check-out. User may only check out own attendance.
API Frontend Description By The Backend Architect
Rendered as check-out button for active shift; shows result or error why not possible (e.g., already checked out, not checked in, not assigned).
Rest Route
The checkOutAttendance API REST controller can be triggered via the following route:
/v1/check-out
Rest Request Parameters
The checkOutAttendance api has got 6 regular request parameters
| Parameter | Type | Required | Population |
|---|---|---|---|
| attendanceRecordId | ID | true | request.body?.[“attendanceRecordId”] |
| checkOutTime | Date | false | request.body?.[“checkOutTime”] |
| status | Enum | true | request.body?.[“status”] |
| lateByMinutes | Integer | false | request.body?.[“lateByMinutes”] |
| absenceReason | String | false | request.body?.[“absenceReason”] |
| managerNote | Text | false | request.body?.[“managerNote”] |
| attendanceRecordId : ID of the attendance record to check out (must be of current user and not already checked out) | |||
| checkOutTime : User check-out timestamp (set on check-out) | |||
| status : Attendance status: present, absent, late, leftEarly, pending (checked in, not yet out) | |||
| lateByMinutes : How many minutes late (if late) | |||
| absenceReason : Reason for absence (manager-provided, e.g., sick, leave) | |||
| managerNote : Manager/admin note (optional for manual absence management) |
REST Request To access the api you can use the REST controller with the path POST /v1/check-out
axios({
method: 'POST',
url: '/v1/check-out',
data: {
attendanceRecordId:"ID",
checkOutTime:"Date",
status:"Enum",
lateByMinutes:"Integer",
absenceReason:"String",
managerNote:"Text",
},
params: {
}
});
REST Response
{
"status": "OK",
"statusCode": "200",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "attendanceRecord",
"method": "POST",
"action": "update",
"appVersion": "Version",
"rowCount": 1,
"attendanceRecord": {
"id": "ID",
"userId": "ID",
"shiftId": "ID",
"checkInTime": "Date",
"checkOutTime": "Date",
"status": "Enum",
"status_idx": "Integer",
"lateByMinutes": "Integer",
"absenceReason": "String",
"managerNote": "Text",
"companyId": "ID",
"isActive": true,
"recordVersion": "Integer",
"createdAt": "Date",
"updatedAt": "Date",
"_owner": "ID"
}
}
Mark Attendanceabsent API
Manager/admin marks an employee as absent for a shift (typically after missed check-in). Can set absenceReason, and adds admin note.
API Frontend Description By The Backend Architect
For managers/admins: select user/shift, set absence reason/note. No employee self-access.
Rest Route
The markAttendanceAbsent API REST controller can be triggered via the following route:
/v1/mark-absent
Rest Request Parameters
The markAttendanceAbsent api has got 7 regular request parameters
| Parameter | Type | Required | Population |
|---|---|---|---|
| userId | ID | true | request.body?.[“userId”] |
| shiftId | ID | true | request.body?.[“shiftId”] |
| absenceReason | String | false | request.body?.[“absenceReason”] |
| managerNote | Text | false | request.body?.[“managerNote”] |
| checkOutTime | Date | false | request.body?.[“checkOutTime”] |
| status | Enum | true | request.body?.[“status”] |
| lateByMinutes | Integer | false | request.body?.[“lateByMinutes”] |
| userId : User to be marked absent | |||
| shiftId : Shift for absence | |||
| absenceReason : Reason for absence | |||
| managerNote : Manager note (internal) | |||
| checkOutTime : User check-out timestamp (set on check-out) | |||
| status : Attendance status: present, absent, late, leftEarly, pending (checked in, not yet out) | |||
| lateByMinutes : How many minutes late (if late) |
REST Request To access the api you can use the REST controller with the path POST /v1/mark-absent
axios({
method: 'POST',
url: '/v1/mark-absent',
data: {
userId:"ID",
shiftId:"ID",
absenceReason:"String",
managerNote:"Text",
checkOutTime:"Date",
status:"Enum",
lateByMinutes:"Integer",
},
params: {
}
});
REST Response
{
"status": "OK",
"statusCode": "200",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "attendanceRecord",
"method": "POST",
"action": "update",
"appVersion": "Version",
"rowCount": 1,
"attendanceRecord": {
"id": "ID",
"userId": "ID",
"shiftId": "ID",
"checkInTime": "Date",
"checkOutTime": "Date",
"status": "Enum",
"status_idx": "Integer",
"lateByMinutes": "Integer",
"absenceReason": "String",
"managerNote": "Text",
"companyId": "ID",
"isActive": true,
"recordVersion": "Integer",
"createdAt": "Date",
"updatedAt": "Date",
"_owner": "ID"
}
}
Get Attendancerecord API
[Default get API] — This is the designated default get API for the attendanceRecord data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Get an attendance record by ID; enrichment with user/shift details. Employees can see only their own; admin/manager can view any in company.
API Frontend Description By The Backend Architect
For employees: show own record only; enriched with shift info. For admins/managers: enriched with user/shift and notes fields.
Rest Route
The getAttendanceRecord API REST controller can be triggered via the following route:
/v1/attendance-records/:attendanceRecordId
Rest Request Parameters
The getAttendanceRecord api has got 1 regular request parameter
| Parameter | Type | Required | Population |
|---|---|---|---|
| attendanceRecordId | ID | true | request.params?.[“attendanceRecordId”] |
| attendanceRecordId : Attendance record ID |
REST Request To access the api you can use the REST controller with the path GET /v1/attendance-records/:attendanceRecordId
axios({
method: 'GET',
url: `/v1/attendance-records/${attendanceRecordId}`,
data: {
},
params: {
}
});
REST Response
{
"status": "OK",
"statusCode": "200",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "attendanceRecord",
"method": "GET",
"action": "get",
"appVersion": "Version",
"rowCount": 1,
"attendanceRecord": {
"id": "ID",
"userId": "ID",
"shiftId": "ID",
"checkInTime": "Date",
"checkOutTime": "Date",
"status": "Enum",
"status_idx": "Integer",
"lateByMinutes": "Integer",
"absenceReason": "String",
"managerNote": "Text",
"companyId": "ID",
"isActive": true,
"recordVersion": "Integer",
"createdAt": "Date",
"updatedAt": "Date",
"_owner": "ID",
"user": {
"email": "String",
"fullname": "String",
"avatar": "String"
},
"shift": {
"shiftDate": "Date",
"startTime": "String",
"endTime": "String",
"location": "String",
"departmentId": "ID"
}
}
}
List Attendancerecords API
[Default list API] — This is the designated default list API for the attendanceRecord data object. Frontend generators and AI agents should use this API for standard CRUD operations.
Lists attendance records, filterable by user, shift, status, date. Employees see only own, admin/manager all for company. Enriches with user & shift info.
API Frontend Description By The Backend Architect
Paged list for quick view of attendance, filter/search by user, shift, status, date. Show basic status; enrich row with user & shift as appropriate. Employee may only see own.
Rest Route
The listAttendanceRecords API REST controller can be triggered via the following route:
/v1/attendance-records
Rest Request Parameters
Filter Parameters
The listAttendanceRecords api supports 3 optional filter parameters for filtering list results:
userId (ID): Referenced user (employee)
- Single:
?userId=<value> - Multiple:
?userId=<value1>&userId=<value2> - Null:
?userId=null
shiftId (ID): Related shift
- Single:
?shiftId=<value> - Multiple:
?shiftId=<value1>&shiftId=<value2> - Null:
?shiftId=null
status (Enum): Attendance status: present, absent, late, leftEarly, pending (checked in, not yet out)
- Single:
?status=<value>(case-insensitive) - Multiple:
?status=<value1>&status=<value2> - Null:
?status=null
REST Request To access the api you can use the REST controller with the path GET /v1/attendance-records
axios({
method: 'GET',
url: '/v1/attendance-records',
data: {
},
params: {
// Filter parameters (see Filter Parameters section above)
// userId: '<value>' // Filter by userId
// shiftId: '<value>' // Filter by shiftId
// status: '<value>' // Filter by status
}
});
REST Response
{
"status": "OK",
"statusCode": "200",
"elapsedMs": 126,
"ssoTime": 120,
"source": "db",
"cacheKey": "hexCode",
"userId": "ID",
"sessionId": "ID",
"requestId": "ID",
"dataName": "attendanceRecords",
"method": "GET",
"action": "list",
"appVersion": "Version",
"rowCount": "\"Number\"",
"attendanceRecords": [
{
"id": "ID",
"userId": "ID",
"shiftId": "ID",
"checkInTime": "Date",
"checkOutTime": "Date",
"status": "Enum",
"status_idx": "Integer",
"lateByMinutes": "Integer",
"absenceReason": "String",
"managerNote": "Text",
"companyId": "ID",
"isActive": true,
"recordVersion": "Integer",
"createdAt": "Date",
"updatedAt": "Date",
"_owner": "ID",
"user": [
{
"email": "String",
"fullname": "String",
"avatar": "String"
},
{},
{}
],
"shift": [
{
"shiftDate": "Date",
"startTime": "String",
"endTime": "String",
"location": "String",
"departmentId": "ID"
},
{},
{}
]
},
{},
{}
],
"paging": {
"pageNumber": "Number",
"pageRowCount": "NUmber",
"totalRowCount": "Number",
"pageCount": "Number"
},
"filters": [],
"uiPermissions": []
}
After this prompt, the user may give you new instructions to update the output of this prompt or provide subsequent prompts about the project.