# XERO Webhook Workflow Examples?

**URL:** <https://community.hubspot.com/t/xero-webhook-workflow-examples/63885>\
**Category:** 💬 RevOps Discussions\
**Tags:** integrations, workflows\
**Created:** [August 27, 2022, 5:22am UTC](https://community.hubspot.com/t/xero-webhook-workflow-examples/63885 "2022-08-27T05:22:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apainter](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@apainter](https://community.hubspot.com/u/apainter)\
**Post date:** [August 27, 2022, 5:22am UTC](https://community.hubspot.com/t/xero-webhook-workflow-examples/63885/1 "2022-08-27T05:22:54Z")

</div>

Hi all,

for purpose of data integrity, I would like to be able to create the following workflow:

Trigger:

Deal stage becomes closed won.

Action:

webhook and initialize a XERO Invoice, then immediately send back the XERO Invoice\_ID and \*\*add\*\* it into a HubSpot multiline field.

It will also send back a repeating Invoice\_ID into HubSpot as a separate field for subscriptions and \*\*add\*\* it into a HubSpot multiline field.

A second workflow will always run and will trigger when either:

XERO Invoice\_ID, or repeating Invoice\_ID is added or updated on any deal by only a workflow.

Then a webhook would find that Invoice\_ID in XERO and push the associated HubSpot Deal\_ID into the notes field of the invoice.

I have extensive javascript experience but I’ve never worked with APIs.

Where would I begin here?

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [August 30, 2022, 2:17pm UTC](https://community.hubspot.com/t/xero-webhook-workflow-examples/63885/2 "2022-08-30T14:17:06Z")

</div>

At a basic level you would create a custom code workflow action in your workflow to interface with the XERO API and create an invoice. You may have to first also grab some data from HubSpot to send to XERO. Some might be avaialable in the workflow, but some you might have to interfafce with HubSpot’s API. I would assume the response to that creation would be the ID of the invoice.

You probably don’t need a second workflow. As a second action in the first workflow, you could do your other step which is to add the deal data to the notes. You could even do it in a single action, but I’d do it in two different actions so it’s easier to test.

When you define an action, you can configure which properties from the deal should be available in the workflow and how you want them named. You can also configure “secrets” which would be your XERO API keys so they aren’t visible in the action code. Lastly you can configure data you want returned out of the action using the callback in case you want to use that data in other actions.

Example you might want to return out the invoice ID so then you can use the set property action to set a deal property to the value of that invoice ID.

Hopefully that is enough to get your started.

---

<div class="post-metadata">

**Author:** ![Nagarjoon](https://avatars.discourse-cdn.com/v4/letter/n/e5b9ba/32.png) [@Nagarjoon](https://community.hubspot.com/u/Nagarjoon)\
**Post date:** [June 11, 2025, 6:23pm UTC](https://community.hubspot.com/t/xero-webhook-workflow-examples/63885/3 "2025-06-11T18:23:34Z")

</div>

You’re on the right track with the workflow logic — it’s a great use case for maintaining data integrity between HubSpot and Xero. Since you have JavaScript experience, you’ll mostly be working with HubSpot workflows and custom-coded webhook actions, along with Xero’s API to create and update invoices.

First, you’d start by setting up a custom webhook action in HubSpot. When a deal moves to the **“Closed Won”** stage, the workflow will trigger a webhook (you can use a middleware like an Express.js server or a serverless function in something like AWS Lambda or Vercel). This webhook will handle authentication with Xero (via OAuth 2.0), then call the Xero API to create an invoice. Once the invoice is created, you’ll get back the `InvoiceID` from Xero. Then, use HubSpot’s API (specifically, the CRM API for deals) to patch the deal and populate the multi-line fields with the `InvoiceID` and, if applicable, the repeating `InvoiceID`.

For the **second workflow** , you’ll want to make sure that it only triggers on updates _by a workflow_, not manual changes. When the `InvoiceID` or `RepeatingInvoiceID` is updated, HubSpot can again fire a webhook that hits your backend. Your backend script should then use the Xero API to find the relevant invoice and update its notes section with the `DealID` (you already have this in the webhook payload or can fetch it with HubSpot’s API).

I suggest this [Hubspot Xero integration](https://ecosystem.hubspot.com/marketplace/apps/xero-sync-3387409) app helps me create custom workflows for my business processes.Just give a try…  
[https://ecosystem.hubspot.com/marketplace/apps/xero-sync-3387409](https://ecosystem.hubspot.com/marketplace/apps/xero-sync-3387409)
