Introduction

This documentation provides a comprehensive guide to using the Laravel Xero package, which allows you to integrate your Laravel application with the Xero accounting system.

Xero API documentation can be found at: https://developer.xero.com/documentation/

Usage

Route using middleware, if the user does not have a valid token, then automatically redirect to get authenticated:

//Authenticated
Route::middleware('XeroAuthenticated')->group(function(){
    Route::get('xero', function() {
        return Xero::getTenantName();
    });
});

//Not authenticated
Route::get('xero/connect', function() {
    return Xero::connect();
});

Direct Requests

Once authenticated, you can call Xero:: with the following verbs:

// GET request
Xero::get($endpoint = '', $data = [], $sendRawRequest = false, $accept = 'application/json', $headers = []);

// POST request
Xero::post($endpoint= '', $data = [], $sendRawRequest = false, $accept = 'application/json', $headers = []);

// PUT request
Xero::put($endpoint= '', $data = [], $sendRawRequest = false, $accept = 'application/json', $headers = []);

// PATCH request
Xero::patch($endpoint= '', $data = [], $sendRawRequest = false, $accept = 'application/json', $headers = []);

// DELETE request
Xero::delete($endpoint= '', $data = [], $sendRawRequest = false, $accept = 'application/json', $headers = []);

Parameters

$endpoint = string '/contacts'

$data = array ['key' => 'value']

$sendRawRequest = bool false (when true send a body payload otherwise send JSON)

$accept = string 'application/json'

$headers = array ['key' => 'value']

These expect the API endpoints to be passed, the URL https://api.xero.com/api.xro/2.0/ is provided, only endpoints after this should be used:

Xero::get('contacts');

Copyright © 2006 - 2025 DC Blog - All rights reserved.