Webhook lifecycle, system logs and database sync

Hi, I’m starting to use Invoice Ninja latest hosted version (v5) and I have configured 2 webhooks for creating and updating an invoice that call a REST api made by me to store all invoices in another database for audit purposes, so I need both sides to be “strongly” synced.

The problem: At some moment, an invoice could be created or updated at the same time my api is unavailable for maintenance reasons (i.e. deploying a new version, or timeout…)

I noticed in the system logs when a call to a rest api by a webhook fails, it’s doing 5 retries, in time ranges from 10, 30, 60 and 180 seconds. Does this workflow end here?
I’ve been having a look at this forum, developer and user guides, github issues, and can’t find anything.
Questions:

  • how can I ensure my other database will be synced with Invoice Ninja?
  • Any way to get the system logs programmatically?
  • Any way to execute failed webhooks related to specific invoice creation/edition?
  • How can I extend Invoice Ninja functionalities and become a platform integrator such as Zapier, Make…
  • How can I implement a similar mechanism as Stripe Webhooks can self heal any transactions that are incomplete?

I was wondering in my mind:

  • If I could extract and read system log and check for this kind of errors automatically, maybe I could trigger the webhook call that failed by executing it again somehow, maybe trhough ninja api?
  • If there was a webhook for error handling maybe I could handle this problem with a different approach

any ideas?
Thanks

@leonardox

As you’ve noted we retry webhooks up to 5 times with escalating backoff times

backoff times in seconds

        return [10, 30, 60, 180, 3600];

As long as you don’t plan maintenance greater than an hour you shouldn’t have to worry about not receiving the webhook.

We do have an API endpoint where you can retry webhooks

POST
webhooks/{webhook}/retry

request body

'entity' => client,credit,invoice,product,task,payment,quote,purchase_order,expense,project,vendor
'entity_id' => id of entity

We do have a system logs endpoint

/api/v1/system_logs

category_id for webhooks is 3
event_id for webhook failures 42

How can I extend Invoice Ninja functionalities and become a platform integrator such as Zapier, Make…

Both of these use very different approaches to the integration with Invoice Ninja.

With Zapier we define a javascript library which interacts with our API
With Make they spent a lot of time integrating directly with the Invoice Ninja API directly.

One alternative is n8n which a community member spent a significant time implementing

1 Like

Hi @david, thanks so much for your quick response and the clarification.
But I can’t see api definition for webhooks/retry in https://api-docs.invoicing.co Is there another documentation?

Thanks
Regards

@leonardox

we developed this particular endpoint after a similar request in the forum here, so we have not yet documented this route.