# Xero

## Prerequisites

To connect Xero to Omnata, you need a Xero account with Adviser or Standard user role.

## Authentication

There are 2 ways to authenticate with Xero:

* Custom Connection (Client ID / Client Secret)

> Currently only available in New Zealand, Australia, and the United Kingdom.

* OAuth 2.0 (Web App)

#### Custom Connection (Client ID / Client Secret)

1. Log in to \`the Xero Developer portal:

* Click on `My Apps`
* Select `New App` to create a new integration.

2. Choose Integration Type:

* Give your integration a name (eg. `Omnata Snowflake Sync`)
* Select `Custom connection` as the integration type.

3. Select Scopes and Authorizing User:

* Choose the `API scopes` your integration requires.
* Specify who will authorize the connection.
* The authorized user will receive an email with a link for authorization.

4. Authorize the Connection:

* The authorizing user will see a consent screen displaying the requested scopes.
* They can select the organization to connect.

> Note that the organization must have purchased a subscription with sufficient Custom Connections.

5. Retrieve `Client ID` and `Client Secret`:

* Once authorized, the `client ID` will be available on the `app details page`.
* Generate the `client secret` (keep it private).

#### OAuth 2.0 (Web App)

1. Log in to \`the Xero Developer portal:

* Click on `My Apps`
* Select `New App` to create a new integration.

2. Create Webapp:

* Give your integration a name (eg. `Omnata Snowflake Sync`)

* Select `Web app` as the integration type.

* In the `Company or application URL` field, enter your company URL.

* In the `Redirect URI` field, enter the value returned from running this Snowflake query:

  ```
  select 'https://'||get(parse_json(SYSTEM$allowlist()),0):"host"::varchar||'/oauth/complete-secret' as REDIRECT_URL;
  ```

  #### &#x20; <a href="#zendesk-plan-for-api-rate-limits" id="zendesk-plan-for-api-rate-limits"></a>

* Click `Create App`.

3. Retrieve `Client ID` and `Client Secret`:

* Once authorized, the `client ID` will be available on the `app details page`.
* Generate the `client secret` (keep it private).

## Scopes

You should request the minimum scopes required for whatever action that user is performing. For example, if a user is doing single sign on you should only request the OpenID scopes. Later, if they want to connect to their Xero organisation you can request the additional scopes (e.g. accounting.transactions) by sending them through the OAuth flow again. Each subsequent time your app sends a user through the flow, any new scopes will be added to previously consented scopes

> It's not possible to remove scopes from an existing access token. The only way to reduce consented scopes is to revoke the token and start again.

[View Available Scopes](https://developer.xero.com/documentation/oauth2/scopes)

Depending on what you want to do with Xero, you will need to select the appropriate scopes. By Default, we have selected the accounting Scopes, but you can add more scopes as required when you setup your connection.

The following scopes are available to add into the connection setup:

| API        | Scopes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Accounting | <ul><li>accounting.invoices</li><li>accounting.payments</li><li>accounting.banktransactions</li><li>accounting.manualjournals</li><li>accounting.invoices.read</li><li>accounting.payments.read</li><li>accounting.banktransactions.read</li><li>accounting.manualjournals.read</li><li>accounting.reports.aged.read</li><li>accounting.reports.balancesheet.read</li><li>accounting.reports.banksummary.read</li><li>accounting.reports.budgetsummary.read</li><li>accounting.reports.executivesummary.read</li><li>accounting.reports.profitandloss.read</li><li>accounting.reports.trialbalance.read</li><li>accounting.reports.taxreports.read</li><li>accounting.settings</li><li>accounting.contacts</li><li>accounting.attachments.read</li><li>accounting.budgets.read</li></ul> |
| Assets     | <ul><li>assets</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Payroll    | <ul><li>payroll.employees</li><li>payroll.payruns</li><li>payroll.settings</li><li>payroll.payslip</li><li>payroll.timesheets</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Projects   | <ul><li>projects</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

### Inbound Syncs

The following streams are supported:

#### Accounting

* [Accounts](https://developer.xero.com/documentation/api/accounting/accounts)
* [Bank Transactions](https://developer.xero.com/documentation/api/accounting/banktransactions)
* [Bank Transfers](https://developer.xero.com/documentation/api/accounting/banktransfers)
* [Batch Payments](https://developer.xero.com/documentation/api/banktransactions)
* [Budgets](https://developer.xero.com/documentation/api/accounting/budgets)
* [Branding Themes](https://developer.xero.com/documentation/api/accounting/batchpayments)
* [Contact Groups](https://developer.xero.com/documentation/api/accounting/contactgroups)
* [Contacts](https://developer.xero.com/documentation/api/accounting/contacts)
* [Credit Notes](https://developer.xero.com/documentation/api/accounting/creditnotes)
* [Currencies](https://developer.xero.com/documentation/api/accounting/currencies)
* [Employees](https://developer.xero.com/documentation/api/accounting/employees)
* [Expense Claims (Deprecated)](https://developer.xero.com/documentation/api/banktransactions)
* [Invoices](https://developer.xero.com/documentation/api/accounting/invoices)
* [Items](https://developer.xero.com/documentation/api/accounting/items)
* [Journals](https://developer.xero.com/documentation/api/accounting/journals)
* [Linked Transactions](https://developer.xero.com/documentation/api/accounting/linkedtransactions)
* [Manual Journals](https://developer.xero.com/documentation/api/accounting/manualjournals)
* [Organisations](https://developer.xero.com/documentation/api/accounting/organisation)
* [Overpayments](https://developer.xero.com/documentation/api/accounting/overpayments)
* [Payments](https://developer.xero.com/documentation/api/accounting/payments)
* [Prepayments](https://developer.xero.com/documentation/api/accounting/prepayments)
* [Purchase Orders](https://developer.xero.com/documentation/api/accounting/purchaseorders)
* [Quotes](https://developer.xero.com/documentation/api/accounting/quotes)
* [Receipts (Deprecated)](https://developer.xero.com/documentation/api/accounting/receipts)
* [Repeating Invoices](https://developer.xero.com/documentation/api/accounting/repeatinginvoices)
* [Tax Rates](https://developer.xero.com/documentation/api/accounting/taxrates)
* [Tracking Categories](https://developer.xero.com/documentation/api/accounting/trackingcategories)
* [Users](https://developer.xero.com/documentation/api/accounting/users)

#### Assets

* [Asset Types](https://developer.xero.com/documentation/api/assets/assettypes)
* [Assets](https://developer.xero.com/documentation/api/assets/assets)

#### Projects (Coming Soon)

* [Projects](https://developer.xero.com/documentation/api/projects/projects)
* [Project Tasks](https://developer.xero.com/documentation/api/projects/tasks)
* [Project Time](https://developer.xero.com/documentation/api/projects/time)
* [Project Users](https://developer.xero.com/documentation/api/projects/users)

#### Payroll

**AU (Coming Soon)**

* [Employees](https://developer.xero.com/documentation/api/payrollau/employees)
* [Leave Applications](https://developer.xero.com/documentation/api/payrollau/leaveapplications)
* [Pay Items](https://developer.xero.com/documentation/api/payrollau/payitems)
* [Pay Runs](https://developer.xero.com/documentation/api/payrollau/payruns)
* [Pay Slips](https://developer.xero.com/documentation/api/payrollau/payslips)
* [Timesheets](https://developer.xero.com/documentation/api/payrollau/timesheets)
* [Super Funds](https://developer.xero.com/documentation/api/payrollau/superfunds)
* [Super Fund Products](https://developer.xero.com/documentation/api/payrollau/superfundproducts)

**NZ (Coming Soon)**

* [Deductions](https://developer.xero.com/documentation/api/payrollnz/deductions)
* [Earnings Rates](https://developer.xero.com/documentation/api/payrollnz/earningsrates)
* [Employees](https://developer.xero.com/documentation/api/payrollnz/employees)
* [Employee Leave](https://developer.xero.com/documentation/api/payrollnz/employeeleave)
* [Employee Leave Types](https://developer.xero.com/documentation/api/payrollnz/employeeleavetypes)
* [Employee Tax](https://developer.xero.com/documentation/api/payrollnz/employeetax)
* [Employment](https://developer.xero.com/documentation/api/payrollnz/employment)
* [Leave Balances](https://developer.xero.com/documentation/api/payrollnz/leavebalances)
* [Pay Items](https://developer.xero.com/documentation/api/payrollnz/payitems)
* [Pay Run Calendars](https://developer.xero.com/documentation/api/payrollnz/payruncalendars)
* [Payment Methods](https://developer.xero.com/documentation/api/payrollnz/paymentmethods)
* [Pay Runs](https://developer.xero.com/documentation/api/payrollnz/payruns)
* [Pay Slips](https://developer.xero.com/documentation/api/payrollnz/payslips)
* [Reimbursements](https://developer.xero.com/documentation/api/payrollnz/reimbursements)
* [Salary and Wages](https://developer.xero.com/documentation/api/payrollnz/salaryandwages)
* [Statutory Deductions](https://developer.xero.com/documentation/api/payrollnz/statutorydeductions)
* [Superannuation](https://developer.xero.com/documentation/api/payrollnz/superannuation)
* [Tax Codes](https://developer.xero.com/documentation/api/payrollnz/taxcodes)
* [Timesheets](https://developer.xero.com/documentation/api/payrollnz/timesheets)
* [Tracking Categories](https://developer.xero.com/documentation/api/payrollnz/trackingcategories)

**UK (Coming Soon)**

* [Deductions](https://developer.xero.com/documentation/api/payrolluk/deductions)
* [Earnigs Rates](https://developer.xero.com/documentation/api/payrolluk/earningsrates)
* [Earning Orders](https://developer.xero.com/documentation/api/payrolluk/earningorders)
* [Employees](https://developer.xero.com/documentation/api/payrolluk/employees)
* [Employee Leave](https://developer.xero.com/documentation/api/payrolluk/employeeleave)
* [Employee Leave Balances](https://developer.xero.com/documentation/api/payrolluk/employeeleavebalances)
* [Employee Leave Periods](https://developer.xero.com/documentation/api/payrolluk/employeeleaveperiods)
* [Employee Leave Types](https://developer.xero.com/documentation/api/payrolluk/employeeleavetypes)

\\

## Outbound Syncs

There is currenly no Outbound syncing support for this App, but please let us know if you have a use case in mind.
