Salesforce and Xero Integration in 2024 : Vimera

Salesforce and Xero Integration in 2024
by: Vimera
blow post content copied from  Forcetalks
click here to view original post

Xero is a cloud-based accounting software for small and medium-sized businesses. This system gives the ability to work with bank feeds, invoicing, accounts payable, expense claims, fixed asset depreciation, purchase orders, bank reconciliations, and standard business and management reporting.

There are two options on how you can try out Xero:

1. Trial organization, where everything can be set up from scratch.

2. Demo Company with predefined data with almost all Xero features except for automatic bank feeds and the ability to invite other users.

We can establish a connection between Salesforce and Xero to migrate records of different objects, email invoices to the client, etc.

For establishing connections we need to create a connected app. There are 3 types of integrations provided during creation:

  • Web app with (standard auth code).
  • Mobile or desktop app (auth code with PKCE).
  • Connected app (premium one-to-one integration that utilizes the client credentials grant type and is available only to Xero organizations in the UK, Australia, and New Zealand).

One of the things that I’ve found is that for one tenant you can have only 2 active web apps. In the next steps, you will see how we can connect Xero and Salesforce using a web app.

  • Xero Side (app creation)
  • Open the following link:
  • Click the New App button.
  • Specify App Name, Company or Application URL, Redirect URI. In the first step Redirect URI can be any.
  • After Auth Provider creation in Salesforce this value will be replaced with a callback URL.

After the app is created, open Configuration on the left panel and click Generate Secret.

Copy Client Id and Client Secret, save them somewhere, because you will need them in the next step.

dont miss out iconDon't forget to check out: Salesforce CRM, NetSuite ERP Integration: Benefits, Guide, Best Practices

Authorized Provider Creation

In Setup find Auth Providers and create a new one with the type Open ID Connect. Specify necessary information and save.

  • Authorize Endpoint URL:
  • Token Endpoint URL:
  • Copy Callback URL from created auth provider and replace Redirect URIs in Xero app with it.

Named Credentials Creation

In Setup find Named Credentials. Use the drop-down menu next to the New button, choose New Legacy. Specify all parameters like on the screen below:

  • Scope: offline_access accounting.settings openid profile email accounting.transactions accounting.contacts.
  • URL:

* Before saving the named credential be sure that you logged in to the Xero.

Click Save. After that you will be redirected to a new page where you need to choose the Xero Organization to which your application will be connected. After choosing organization click Allow Access.

After establishing a connection we need to get a tenant-id, which is used for making callouts. To do this, open anonymous apex and run the following code:

HTTPRequest request = new HTTPRequest();
request.setMethod( 'GET' );
request.setEndpoint( 'callout:Xero_Named_Credential/'+'connections' );
request.setHeader( 'Accept', 'application/json' );
request.setHeader( 'xero-tenant-id', '' );
HTTPResponse response = new HTTPResponse();
HTTP objHTTP = new HTTP(); 
response = objHTTP.send( request );

In the response body you’ll find a tenant-id, which can be stored in a custom setting. This is how tenant-id is used during request to Xero:

request.setHeader('xero-tenant-id', tenantIdValueFromCustomSetting);

In the next part I will tell you about interesting facts and issues which you might face during Salesforce/Xero integration.

One of the things that needs to be remembered is that Xero API like Salesforce has limits:

  • Concurrent Limit: 5 calls in progress at one time
  • Minute Limit: 60 calls per minute
  • Daily Limit: 5000 calls per day

There is also a limit to the number of API calls your app can make per minute across all tenants.

  • App Minute Limit: 10,000 calls per minute

dont miss out iconCheck out another amazing blog here by Vimera: How to Integrate Data from Third-party Systems with your Salesforce Org?

If a limit is reached, you can use the Retry-After header which will show how long to wait before making another call.


During integration we can make GET, POST, PUT, DELETE requests, but not each object supports all of them. For example Invoice object doesn’t include DELETE request, instead to remove record we need to use POST. Depending on the status there will be 2 ways, how it can be implemented:

  • If invoice status is DRAFT or SUBMITTED we set it to DELETED in the request body.

2) If invoice status is AUTHORISED we set it to VOIDED.

This article is prepared by our Salesforce Developer Lisa Vasilieva.

To read about interesting lifehacks that were found during integration with Xero, please visit our website.

The post Salesforce and Xero Integration in 2024 appeared first on Forcetalks.

December 13, 2023 at 03:58PM
Click here for more details...

The original post is available in Forcetalks by Vimera
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.