xero-api

Unable to get list of past employees in Payroll AU API Employees


I need to be able to extract past/terminated employees from Xero.

The documentation (https://developer.xero.com/documentation/api/payrollau/employees) states that "By default using GET Employees will return a summarised list of active employees." There are no Optional Parameters documented that allow access to past/terminated employees, however these can be seen on the web page Payroll->Employees->Past.

How are past employees accessible through the API?


Solution

  • A bit of a scroll down the page you've linked shows just how you can accomplish that:

    Example of retrieving terminated employees

    Using a where filter you can specify a status of TERMINATED. e.g. Status=="TERMINATED"

    This translates to the following URL once percent encoded: https://api.xero.com/payroll.xro/1.0/Employees?where=Status%3D%3D%22TERMINATED%22

    {
      "Employees": [
        {
          "EmployeeID": "30b19d1e-afc6-4df9-bb17-b8ab247730fa",
          "FirstName": "Adam",
          "LastName": "Sumo",
          "Status": "TERMINATED",
          "DateOfBirth": "/Date(-786931200000+0000)/",
          "StartDate": "/Date(1527897600000+0000)/",
          "TerminationDate": "/Date(1572825600000+0000)/",
        "TerminationReason": "R",
          "PayrollCalendarID": "d4a9437d-3b27-476c-ac15-db6439fac720",
          "UpdatedDateUTC": "/Date(1572911939000+0000)/"
        }
      ]
    }