Xero Payroll AU API 2.0

PayrollAuV2

approveTimesheet

Approves a specific timesheet


/Timesheets/{TimesheetID}/Approve

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$timesheetID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
$idempotencyKey = "KEY_VALUE";

try {
  $result = $apiInstance->approveTimesheet($xeroTenantId, $timesheetID, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->approveTimesheet: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets

Parameters

Path parameters
Name Description
TimesheetID*
UUID (uuid)
Identifier for the timesheet
Required
Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.

createTimesheet

Creates a new timesheet


/Timesheets

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$idempotencyKey = "KEY_VALUE";
$startDate = new DateTime('2020-10-28');
$endDate = new DateTime('2020-10-30');

$timesheet = new XeroAPI\XeroPHP\Models\PayrollAuV2\Timesheet;
$timesheet->setPayrollCalendarID('00000000-0000-0000-0000-000000000000');
$timesheet->setEmployeeID('00000000-0000-0000-0000-000000000000');
$timesheet->setStartDate($startDate);
$timesheet->setEndDate($endDate);

try {
  $result = $apiInstance->createTimesheet($xeroTenantId, $timesheet, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->createTimesheet: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets

Parameters

Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Body parameters
Name Description
timesheet *
Timesheet
Required

createTimesheetLine

Creates a new timesheet line for a specific timesheet using a unique timesheet ID


/Timesheets/{TimesheetID}/Lines

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$timesheetID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
$idempotencyKey = "KEY_VALUE";
$date = new DateTime('2020-10-28');

$timesheetLine = new XeroAPI\XeroPHP\Models\PayrollAuV2\TimesheetLine;
$timesheetLine->setTimesheetLineID('00000000-0000-0000-0000-000000000000');
$timesheetLine->setDate($date);
$timesheetLine->setEarningsRateID('00000000-0000-0000-0000-000000000000');
$timesheetLine->setTrackingItemID('00000000-0000-0000-0000-000000000000');
$timesheetLine->setNumberOfUnits(6);

try {
  $result = $apiInstance->createTimesheetLine($xeroTenantId, $timesheetID, $timesheetLine, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->createTimesheetLine: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets

Parameters

Path parameters
Name Description
TimesheetID*
UUID (uuid)
Identifier for the timesheet
Required
Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Body parameters
Name Description
timesheetLine *
TimesheetLine
Required

deleteTimesheet

Deletes a specific timesheet


/Timesheets/{TimesheetID}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$timesheetID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";

try {
  $result = $apiInstance->deleteTimesheet($xeroTenantId, $timesheetID);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->deleteTimesheet: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets

Parameters

Path parameters
Name Description
TimesheetID*
UUID (uuid)
Identifier for the timesheet
Required
Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required

deleteTimesheetLine

Deletes a specific timesheet line


/Timesheets/{TimesheetID}/Lines/{TimesheetLineID}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$timesheetID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
$timesheetLineID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";

try {
  $result = $apiInstance->deleteTimesheetLine($xeroTenantId, $timesheetID, $timesheetLineID);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->deleteTimesheetLine: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets

Parameters

Path parameters
Name Description
TimesheetID*
UUID (uuid)
Identifier for the timesheet
Required
TimesheetLineID*
UUID (uuid)
Identifier for the timesheet line
Required
Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required

getTimesheet

Retrieve a specific timesheet by using a unique timesheet ID


/Timesheets/{TimesheetID}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$timesheetID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";

try {
  $result = $apiInstance->getTimesheet($xeroTenantId, $timesheetID);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->getTimesheet: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets
payroll.timesheets.read Grant read-only access to payroll timesheets

Parameters

Path parameters
Name Description
TimesheetID*
UUID (uuid)
Identifier for the timesheet
Required
Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required

getTimesheets

Retrieves timesheets


/Timesheets

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$page = 5;
$filter = "employeeId==00000000-0000-0000-0000-000000000000,payrollCalendarId==00000000-0000-0000-0000-000000000000";
$status = "Draft";
$startDate = "2019-01-02";
$endDate = "2020-01-02";
$sort = "startDate";

try {
  $result = $apiInstance->getTimesheets($xeroTenantId, $page, $filter, $status, $startDate, $endDate, $sort);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->getTimesheets: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets
payroll.timesheets.read Grant read-only access to payroll timesheets

Parameters

Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required
Query parameters
Name Description
page
Integer
Page number which specifies the set of records to retrieve. By default the number of the records per set is 100.
filter
String
Filter by employeeId and/or payrollCalendarId
status
String
filter results by any timesheets with a matching timesheet status
startDate
String
filter results by any timesheets with a startDate on or after the provided date
endDate
String
filter results by any timesheets with a endDate on or before the provided date
sort
String
sort the order of timesheets returned. The default is based on the timesheets createdDate, sorted oldest to newest. Currently, the only other option is to reverse the order based on the timesheets startDate, sorted newest to oldest.

revertTimesheet

Reverts a specific timesheet to draft


/Timesheets/{TimesheetID}/RevertToDraft

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$timesheetID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
$idempotencyKey = "KEY_VALUE";

try {
  $result = $apiInstance->revertTimesheet($xeroTenantId, $timesheetID, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->revertTimesheet: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets

Parameters

Path parameters
Name Description
TimesheetID*
UUID (uuid)
Identifier for the timesheet
Required
Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.

updateTimesheetLine

Updates a specific timesheet line for a specific timesheet


/Timesheets/{TimesheetID}/Lines/{TimesheetLineID}

Usage and SDK Samples

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure OAuth2 access token for authorization: OAuth2
$config = XeroAPI\XeroPHP\Configuration::getDefaultConfiguration()->setAccessToken( 'YOUR_ACCESS_TOKEN' );       

$apiInstance = new XeroAPI\XeroPHP\Api\PayrollAuV2Api(
    new GuzzleHttp\Client(),
    $config
);
$xeroTenantId = "xeroTenantId_example";
$timesheetID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
$timesheetLineID = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
$idempotencyKey = "KEY_VALUE";
$date = new DateTime('2020-10-28');

$timesheetLine = new XeroAPI\XeroPHP\Models\PayrollAuV2\TimesheetLine;
$timesheetLine->setTimesheetLineID('00000000-0000-0000-0000-000000000000');
$timesheetLine->setDate($date);
$timesheetLine->setEarningsRateID('00000000-0000-0000-0000-000000000000');
$timesheetLine->setTrackingItemID('00000000-0000-0000-0000-000000000000');
$timesheetLine->setNumberOfUnits(6);

try {
  $result = $apiInstance->updateTimesheetLine($xeroTenantId, $timesheetID, $timesheetLineID, $timesheetLine, $idempotencyKey);
} catch (Exception $e) {
  echo 'Exception when calling PayrollAuV2Api->updateTimesheetLine: ', $e->getMessage(), PHP_EOL;
}
?>

Scopes

payroll.timesheets Grant read-write access to payroll timesheets

Parameters

Path parameters
Name Description
TimesheetID*
UUID (uuid)
Identifier for the timesheet
Required
TimesheetLineID*
UUID (uuid)
Identifier for the timesheet line
Required
Header parameters
Name Description
Xero-Tenant-Id*
String
Xero identifier for Tenant
Required
Idempotency-Key
String
This allows you to safely retry requests without the risk of duplicate processing. 128 character max.
Body parameters
Name Description
timesheetLine *
TimesheetLine
Required