API: Auto Pay Reoccurring Invoice based on Payment reference

Hi there,

I’ve developed a system using Python and the Invoice Ninja API. It processes payment references from my business bank’s email notifications (which are essentially invoice numbers) by querying Invoice Ninja for the respective invoice number. Then, based on the amount received, it automatically records a payment against that invoice number and client ID. This setup works perfectly for standard invoices.

However, I’ve encountered a challenge with recurring invoices, as they generate a new invoice number each time. To address this, I’m planning to assign a unique “Client Code” to each client. The idea is that when a payment reference matches a client code, the system will query a database to retrieve the corresponding Invoice Ninja Client ID. The next step – and this is where I need some assistance – is to fetch the latest invoice number and amount for that client ID. I’ve reviewed the API documentation, particularly under ‘show client’, but I can’t seem to find the relevant information to retrieve the latest invoice details for a client.

Could anyone offer advice, pointers, or suggest an alternative approach? For instance, does Invoice Ninja have its own “Client Code” or “Payment Code” system for handling recurring invoices?

Any help or insights would be greatly appreciated!

Hi,

The query params for /invoices is available here. I assume you can filter by client and reverse sort by date.

https://api-docs.invoicing.co/#get-/api/v1/invoices

Note: from your description I believe using webhooks may be a better solution.