Skip to main content

Attendance API

Endpoints for managing attendance records and punch in/out functionality.

List Attendance Entries

Retrieves attendance records. Admin users see all entries; managers see only subordinate entries.

GET /attendance/

Response: 200 OK

{
"status": "SUCCESS",
"data": [
{
"id": "1",
"employee": "1",
"in_time": "2024-01-15 09:00:00",
"out_time": "2024-01-15 17:30:00",
"note": "Regular workday"
}
]
}

Get Single Attendance Entry

Retrieves a specific attendance entry by ID.

GET /attendance/{id}

Response: 200 OK or 404 Not Found

{
"status": "SUCCESS",
"data": {
"id": "1",
"employee": "1",
"in_time": "2024-01-15 09:00:00",
"out_time": "2024-01-15 17:30:00",
"note": "Regular workday",
"image_in": null,
"image_out": null
}
}

Create Attendance Entry

Creates a new attendance entry. Admins and managers can add entries for subordinates; employees can add their own entries.

POST /attendance/

Request Body:

{
"employee": "1",
"in_time": "2024-01-15 09:00:00",
"out_time": "2024-01-15 17:30:00",
"note": "Regular workday"
}

Response: 201 Created

{
"status": "SUCCESS",
"data": {
"id": "2",
"employee": "1",
"in_time": "2024-01-15 09:00:00",
"out_time": "2024-01-15 17:30:00",
"note": "Regular workday",
"image_in": null,
"image_out": null
}
}

Delete Attendance Entry

Deletes an attendance entry. Admin users only.

DELETE /attendance/{id}

Response: 200 OK

{
"status": "SUCCESS",
"data": {
"id": "1"
}
}

Get Open Punch-In

Retrieves an unclosed attendance entry (punched in but not punched out) for a specific employee and date. Use "today" for the current day.

GET /employee/{employeeId}/open-punch-in/{date}

Parameters:

  • employeeId: Employee ID
  • date: Date in YYYY-MM-DD format or "today"

Response: 200 OK

{
"status": "SUCCESS",
"data": {
"id": "1",
"employee": "1",
"in_time": "2024-01-15 09:00:00",
"out_time": null,
"note": "Morning check-in"
}
}

Returns null in data if no open punch-in exists.

Punch-In

Records an employee punching in. If in_time is omitted, the server's current time is used.

POST /attendance/punch-in

Request Body:

{
"employee": "1",
"in_time": "2024-01-15 09:00:00",
"note": "Morning check-in"
}

Response: 200 OK

{
"status": "SUCCESS",
"data": {
"id": "1",
"employee": "1",
"in_time": "2024-01-15 09:00:00",
"out_time": null,
"note": "Morning check-in"
}
}

Error Response: 400 Bad Request if employee is already punched in.

Punch-Out

Records an employee punching out. If out_time is omitted, the server's current time is used.

POST /attendance/punch-out

Request Body:

{
"employee": "1",
"out_time": "2024-01-15 17:30:00",
"note": "End of day"
}

Response: 200 OK

{
"status": "SUCCESS",
"data": {
"id": "1",
"employee": "1",
"in_time": "2024-01-15 09:00:00",
"out_time": "2024-01-15 17:30:00",
"note": "End of day"
}
}

Error Response: 400 Bad Request if employee is not currently punched in.