Leave

Authentication: All endpoints require an Authorization: Bearer <access token> header.

Most endpoints require an X-Company-ID: <company_id> header to scope requests to a specific company. This is the recommended header for most API operations.

Some endpoints require an X-Location-ID: <location_id> header when the query doesn't accept a locationId parameter.

See Authentication for details on how to obtain and use these headers.

Query Leave Balance

GraphQL Query

query LeaveBalance($employeeId: ID!, $asOf: Date) {
  leaveBalance(employeeId: $employeeId, asOf: $asOf) {
    employeeId
    leaveType {
      id
      name
    }
    amount
    unit
  }
}

Example Variables

{
  "employeeId": "21",
  "asOf": "2024-01-01"
}

Example Response

{
  "data": {
    "leaveBalance": [
      {
        "employeeId": "21",
        "leaveType": {
          "id": "4708",
          "name": "Annual Leave"
        },
        "amount": 45,
        "unit": "Hours"
      },
      {
        "employeeId": "21",
        "leaveType": {
          "id": "4599",
          "name": "Annual Leave (Weeks)"
        },
        "amount": 99,
        "unit": "Days"
      }
    ]
  }
}

Query Leave Requests

GraphQL Query

query LeaveRequests($startTime: DateTime, $endTime: DateTime, $approved: Boolean, $leaveTypeId: String, $strictRange: Boolean) {
  leaveRequests(startTime: $startTime, endTime: $endTime, approved: $approved, leaveTypeId: $leaveTypeId, strictRange: $strictRange) {
    id
    employee {
      id
      fullName
    }
    leaveType {
      id
      name
    }
    modifiedAt
    modifiedBy {
      fullName
    }
    startTime
    endTime
    hours
    approved
    note
    reason
  }
}

Example Variables (Approved Requests)

{
  "startTime": "2024-04-01",
  "endTime": "2024-04-30",
  "approved": true,
  "leaveTypeId": null,
  "strictRange": false
}

Example Response

{
  "data": {
    "leaveRequests": [
      {
        "id": "502607",
        "employee": {
          "id": "73542",
          "fullName": "Kate Mallone"
        },
        "leaveType": {
          "id": "4579",
          "name": "Annual Leave"
        },
        "modifiedAt": "2024-06-05T05:41:23.114Z",
        "modifiedBy": {
          "fullName": "Roubler Support"
        },
        "startTime": "2024-04-04T14:00:00.000Z",
        "endTime": "2024-04-06T13:59:00.000Z",
        "hours": 15.2,
        "approved": true,
        "note": "AL",
        "reason": null
      }
    ]
  }
}

Add Leave Request

GraphQL Mutation

mutation AddLeaveRequest($input: AddLeaveRequestInput!) {
  addLeaveRequest(input: $input) {
    id
    employeeId
    leaveTypeId
    note
    startTime
    endTime
  }
}

Example Variables

{
  "input": {
    "employeeId": "73543",
    "leaveTypeId": "4579",
    "notes": "Interstate travel",
    "startTime": "2024-05-07T14:00:00.000Z",
    "endTime": "2024-05-10T13:59:59.999Z",
    "attachmentId": null
  }
}

Example Response

{
  "data": {
    "addLeaveRequest": {
      "id": "502644",
      "employeeId": "73543",
      "leaveTypeId": "4579",
      "note": "Interstate travel",
      "startTime": "2024-05-07T14:00:00.000Z",
      "endTime": "2024-05-10T13:59:00.999Z"
    }
  }
}

Update Leave Request

GraphQL Mutation

mutation UpdateLeaveRequest($input: UpdateLeaveRequestInput!) {
  updateLeaveRequest(input: $input) {
    id
    employeeId
    leaveTypeId
    note
    startTime
    endTime
  }
}

Example Variables

{
  "input": {
    "id": "502644",
    "employeeId": "73543",
    "leaveTypeId": "4579",
    "notes": "Interstate travel + adding additional day",
    "startTime": "2024-05-07T14:00:00.000Z",
    "endTime": "2024-05-11T13:59:59.999Z",
    "attachmentId": null
  }
}

Example Response

{
  "data": {
    "updateLeaveRequest": {
      "id": "502644",
      "employeeId": "73543",
      "leaveTypeId": "4579",
      "note": "Interstate travel + adding additional day",
      "startTime": "2024-05-07T14:00:00.000Z",
      "endTime": "2024-05-11T13:59:00.999Z"
    }
  }
}

Query Leave Types

GraphQL Query

query LeaveTypes {
  leaveTypes {
    id
    name
    displayBalance
    minimumBalance
    autoApprove
    createTimesheet
    available
    serviceKey
  }
}

Example Variables

{}

Example Response

{
  "data": {
    "leaveTypes": [
      {
        "id": "4579",
        "name": "Annual Leave",
        "displayBalance": true,
        "minimumBalance": null,
        "autoApprove": false,
        "createTimesheet": true,
        "available": true,
        "serviceKey": null
      },
      {
        "id": "4581",
        "name": "LWOP",
        "displayBalance": false,
        "minimumBalance": null,
        "autoApprove": true,
        "createTimesheet": false,
        "available": true,
        "serviceKey": null
      },
      {
        "id": "4580",
        "name": "Personal/Carers Leave",
        "displayBalance": true,
        "minimumBalance": null,
        "autoApprove": false,
        "createTimesheet": true,
        "available": true,
        "serviceKey": null
      }
    ]
  }
}