Skip to main content

Leave API

Endpoints for managing leave requests.

List All Leave Requests

Retrieves all leave requests.

GET /leave

Response: 200 OK

{
"status": "SUCCESS",
"data": [
{
"id": "1",
"employee": "1",
"leave_type": "Annual Leave",
"date_start": "2024-02-01",
"date_end": "2024-02-03",
"status": "Approved",
"total": 3,
"details": "Family vacation"
}
]
}

Apply for Leave

Submits a new leave request.

POST /leave/apply

Request Body:

{
"leave_type": "1",
"start": "2024-02-01",
"end": "2024-02-03",
"details": "Family vacation",
"attachment": null,
"days": {
"2024-02-01": "Full Day",
"2024-02-02": "Full Day",
"2024-02-03": "Full Day"
}
}

Request Fields:

  • leave_type: Leave type ID
  • start: Start date (YYYY-MM-DD)
  • end: End date (YYYY-MM-DD)
  • details: Reason for leave
  • attachment: Optional file attachment
  • days: Object with dates as keys and leave duration as values ("Full Day", "Half Day - Morning", "Half Day - Afternoon")

Response: 200 OK

{
"status": "SUCCESS",
"data": {
"id": "2",
"employee": "1",
"leave_type": "1",
"date_start": "2024-02-01",
"date_end": "2024-02-03",
"status": "Pending",
"total": 3,
"details": "Family vacation",
"event_ids": ["101", "102", "103"]
}
}

Leave Status Values

Leave requests can have the following status values:

  • Pending: Awaiting approval
  • Approved: Leave request approved
  • Rejected: Leave request rejected
  • Cancelled: Leave request cancelled by employee

Leave Day Types

When specifying the days object, use one of these values:

  • Full Day: Entire day off
  • Half Day - Morning: Morning half-day leave
  • Half Day - Afternoon: Afternoon half-day leave