API version 2 Employee Availability

1. Create New Employee Availability (api2/employee_availabilities)

This method allows employees to register availability, holidays, or sick leave. It validates input parameters, handles scheduling conflicts, and ensures proper updates to linked appointments when necessary. Responses may include success confirmation, conflict warnings requiring user confirmation, or validation errors.

URL
Server URL HTTP type
UAT https://api-ca-uat.iinsightonline.com/api2/employee_availabilities POST
PRODUCTION https://api-ca.iinsightonline.com/api2/employee_availabilities POST
Authorization
Parameter Value Mandatory
Type Bearer Token Yes
Token The token is generated using the /auth/login method Yes
Query Params
Parameter Value Mandatory
employee_id Employee ID. (i.e.: 131) Yes
date_from Start date. (i.e.: 01-04-2025) Yes
date_to End date. (i.e.: 30-04-2025) Yes
leave_type Leave type. (options: holiday, sick, availability) Yes
frequency Frequency of availability. (options: Weekly, One Off, Fortnightly) Yes (if leave_type = availability)
availabilities

This is an array of objects that define the availability schedule. Each object represents a day and includes the following properties:

  • day: The day of the week (e.g., "Monday", "Tuesday")
  • session_1: The start and end times for the first session (e.g., {"start": "07:00 am", "end": "03:00 pm"})
  • break: The break time (e.g., {"start": "03:00 pm", "end": "03:30 pm"})
  • session_2: The start and end times for the second session (e.g., {"start": "03:30 pm", "end": "06:00 pm"})
  • location_session_1: Locations for the first session (e.g., "all" for all locations, or specific location IDs)
  • location_session_2: Locations for the second session (e.g., "all" for all locations, or specific location IDs)
Example:
            [
              {
                "day": "Monday",
                "session_1": {"start": "07:00 am", "end": "03:00 pm"},
                "break": {"start": "03:00 pm", "end": "03:30 pm"},
                "session_2": {"start": "03:30 pm", "end": "06:00 pm"},
                "location_session_1": "all",
                "location_session_2": "all"
              },
              {
                "day": "Tuesday",
                "session_1": {"start": "07:30 am", "end": "03:30 pm"},
                "break": {"start": "03:30 pm", "end": "04:00 pm"},
                "session_2": {"start": "04:00 pm", "end": "06:30 pm"},
                "location_session_1": "2,3",
                "location_session_2": "4,5,6"
              },
              {
                ...
              }
            ]
            
Note: The "location_session_1" and "location_session_2" properties can be a comma-separated list of location IDs or the value "all" to indicate that the session is available in all locations. The array can include more days as needed.

Yes (if leave_type = availability)
confirm_replaced Confirm replacement. (options: Yes/No) No
confirm_update_appointments Confirm update of appointments. (options: Yes/No) No
Response
✔️ Success Response

{
  "status": "true",
  "message": "Sick Leave has been successfully created",
  "employee_availability_id": 132,
  "app_log_id": 80209,
  "notification_summary": "0 notifications created",
  "case_notifications": "0 case notifications created",
  "released_appointments": "0 appointment released"
}
⚠️ Schedule Overlap Confirmation

{
  "status": false,
  "confirm": "confirm_replaced",
  "error": "Conflict: Schedule Overlap",
  "message": "This schedule overlaps an existing schedule.",
  "details": "Availability between 01-04-2025 and 30-04-2025 will be replaced by the new schedule.\nAre you sure you wish to proceed?"
}
⚠️ Release Linked Appointment Confirmation

{
  "status": false,
  "error": "Warning: Schedule Overlap",
  "confirm": "confirm_update_appointments",
  "message": [
    "Roster overwrite will update appointments below:",
    "Appointment Summary",
    "Scheduled Appointments that will be released to 'Unassigned': 1",
    "Scheduled Appointments that will be 'Deleted': 1",
    "Are you sure you wish to proceed?"
  ]
}
❌ Date Validation Error

{
  "status": false,
  "error": "Date From should be earlier than Date To"
}

2. Get Unavailability Periods (api2/employee_availabilities/unavailabilities)

This method retrieves the unavailability periods for the logged-in user (employee) based on a selected date.
The unavailability periods are returned in JSON format and are filtered according to the provided parameters.

URL
Environment URL HTTP Method
UAT https://api-ca-uat.iinsightonline.com/api2/employee_availabilities/unavailabilities GET
PRODUCTION https://api-ca.iinsightonline.com/api2/employee_availabilities/unavailabilities GET
Authorization
Parameter Value Mandatory
Type Bearer Token Yes
Token The token is generated using the /auth/login method. Yes
Query Params
Parameter Value Mandatory
selected_date The date for which the unavailability periods are requested (e.g., 12-04-2025). Yes
Response
 {
    "status": true,
    "message": "Unavailability Periods retrieved successfully",
    "total_records": 1,
    "data": [
              {
                  "id": 0,
                  "name": "Staff Member Unavailable",
                  "employee_id": "210",
                  "date_from": "06-04-2025 00:00",
                  "date_to": "26-04-2025 23:59",
                  "type": "unavailable"
              }
            ]
}
Error Responses

If there is an error in the request or an issue with the server, the response may look like:

 {
    "status": false,
    "message": "An error occurred while fetching the Unavailability Periods.",
    "error": "Internal Server Error"
}