Skip to main content
Question

How do I create multiple multi-line invoices in Xero

  • August 20, 2025
  • 3 replies
  • 51 views

Hello all,

I am trying to bulk Create Sales Invoice in Xero.

My Zap utilizes a Catch Hook as the trigger and receives the data in JSON format. (In my test, there are 2 invoices. First invoice has 2 line tems and second invoice has 3 line items).

My JSON:

{

  "invoices": [

     {

       "contactName": "1A Test Company ABN:111 111 1111",

       "dueDate":"2025-09-15",

       "reference":1020,

       "status":"AUTHORISED",

       "lineItems": [

          {"description":"Item 1","quantity":1,"unitAmount":840,"discountRate":0,"accountCode":202},

          {"description":"Item 2","quantity":1,"unitAmount":104,"discountRate":0,"accountCode":202}

     ]

    },

    {

       "contactName": "3A Test Company ABN:333 333 3333",

       "type":"ACCREC",

       "dueDate":"2025-09-15",

       "reference":1021,

       "status":"AUTHORISED",

       "lineItems": [

          {"description":"Item 1","quantity":2,"unitAmount":840,"discountRate":0,"accountCode":202},

          {"description":"item 2","quantity":1,"unitAmount":104,"discountRate":0,"accountCode":202},

          {"description":"Item 4","quantity":1,"unitAmount":300,"discountRate":0,"accountCode":203}

       ]

    }

  ]

}

 

As can be seen in the screenshot below, Zapier recognized that there are 2 invoices as well as the line items in my JSON payload.

Next I used a Formatter (Line Itemizer) on the line items. However, it is aggregating the line items between the 2 invoices.

When I try to run the Create Sales Invoice action it failed but will work if there is only 1 invoice in my JSON.

I have tried adding Looping before the formatter to separate my invoices but I am not sure how to get it to work properly? Do I add all fields in the loop or just the Contact name which is what separates each invoice.

Ultimately, my problem is not being able to separate the invoices. Can I please ask if I need to structure the JSON differently or what actions should be in my Zap to get this to work.

Thanks!

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • 34066 replies
  • August 20, 2025

Hi ​@ayio 

Issue is because you have nested arrays, so the nested array items get flattened.

Level 1: Invoices

Level 2: Invoice Line Items

 

The workaround is to use custom Code.

https://zapier.com/apps/code/integrations#help

 

Try these Zap steps:

  1. Trigger: Webhook - Catch RAW Hook
    1. This will return the RAW JSON
  2. Action: Code - Run Javascript
    1. Parse the raw JSON to output 2 array items that are the raw JSON for each invoice
  3. Action: Looping - Create Loop from Line Items
    1. Iterate thru each Invoice
  4. Action: Code - Run Javascript
    1. Parse the raw JSON for the individual invoice
  5. Action: [APP] - [EVENT]
    1. Proceed as needed

 

Help links for how to parse raw JSON: 

 

If you need to hire help, there is a directory of Zapier Partners: https://zapier.com/partnerdirectory


  • Author
  • Beginner
  • 1 reply
  • August 20, 2025

@Troy Tessalone Thank you for your advice. Will give it a go.


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • 9723 replies
  • September 22, 2025

Hey ​@ayio 👋

Just wanted to check how you got on with Troy’s suggested approach here - were you able to get those invoices created correctly?

Keep us posted on how it went. Want to make sure everything’s all sorted here! 🙂