broccolli.xyz
Blog

Process Automation | Tools

Webhooks: How to Automate Processes in Real Time Between Systems

· 6 min

A customer pays for an order at 10:02. The invoice goes out at 10:14. The confirmation email lands at 10:19. Nobody did anything wrong: each system simply checked for news when its turn came round.

That is how most integrations between systems work when nobody has thought hard about them. It is also exactly the problem webhooks solve. Instead of one system asking another every few minutes whether anything has happened, the system where the event occurs sends a notice the moment it occurs.

This article explains what a webhook is, when it beats the alternative and, more importantly, what a webhook does not guarantee and has to be designed around.

What a webhook is, without the jargon

A webhook is an automatic notice that one system sends to another when an event happens.

Technically, it is an HTTP request, usually a POST carrying JSON, sent to an address the receiving system exposes. That address is the endpoint. The body of the request, the payload, describes what happened: "payment confirmed, customer X, amount Y".

The difference from a conventional API call is the direction.

With an API, your workflow asks: "are there any new orders?". With a webhook, the online shop says: "an order has just come in, here are the details".

It is the difference between walking to the letterbox every fifteen minutes and having a postman who rings the bell.

Webhook vs polling: the default most teams never question

When there is no webhook, the integration polls: it queries the source system at fixed intervals.

Many tools work this way by default. Zapier's developer documentation describes polling triggers as checks that run, per active Zap, every 1 to 15 minutes depending on the plan. The same page describes REST hook triggers, its flavour of webhook, as running in "near realtime".

Polling has two costs that rarely make it into the budget.

The first is delay. With a 15-minute interval, an event waits on average seven and a half minutes before anyone notices it, and fifteen at worst. If a process has three chained steps, each with its own polling, the delays add up.

The second is empty calls. In most processes, most checks find nothing, yet each one uses up the source system's API quota and the resources of the server running the automation.

A worked example

An online shop takes 40 orders a day. Each order must create an invoice in the invoicing software and a shipping request with the carrier.

The figures below are our own estimate, using simple arithmetic. Rerun them with your own volumes.

Polling every 5 minutes:

  • 288 calls a day to the shop (24 hours × 12 per hour).
  • At most 40 of those calls find a new order. At least 248, about 86%, come back empty.
  • Each order waits 2.5 minutes on average to be picked up, 5 at worst. If invoicing and shipping also rely on polling, the worst case reaches 15 minutes.

With webhooks:

  • 40 requests a day, one per order. None empty.
  • The invoice is issued seconds after payment.

For a shop of this size, 15 minutes is rarely a crisis. Apply the same logic to stock shared between your shop and a marketplace, though, and it becomes the difference between selling an item that has just sold out and not.

Where real-time process automation pays off

Not every process needs real time. A bank reconciliation run once a day works perfectly well as a scheduled job.

Webhooks earn their keep when reaction time matters to the customer or to operations:

  • Payment confirmed → invoice issued and sent. The customer gets the document while the tab is still open.
  • Website form → CRM record and an alert to sales. Contact happens while the enquiry is still warm.
  • Contract e-signed → onboarding starts. Access, shared folder and kick-off meeting set up without waiting on anyone.
  • Stock changed in one channel → updated everywhere else. You stop selling what you no longer have.

What a webhook does not guarantee

This is where most integrations fail. Not on day one, but three months later, on a Friday afternoon.

Delivery depends on the sender

A webhook is sent once. If your endpoint is down at that moment, what happens next is entirely up to the source system.

Some handle it well. Stripe's webhook documentation states that, in live mode, failed deliveries are retried for up to three days with exponential back-off. Other systems try once or twice more. Some never retry at all.

Before building a critical process on a vendor's webhooks, ask about their retry policy. If the answer is "there isn't one", you need a fallback.

Duplicates and out-of-order events are normal

The same Stripe documentation is explicit on two points that apply to almost every vendor. The same event can arrive more than once. And delivery order is not guaranteed: "invoice paid" may arrive before "invoice created".

In practice, your workflow must be idempotent: processing the same event twice must produce the same result as processing it once. You get there by storing the ID of every event already handled and writing with upsert rather than create, a technique we cover in detail in our piece on integrating CRM, email and invoicing data without duplicates.

The endpoint must reply quickly

The sender expects a response. If your workflow issues the invoice, sends the email and updates the CRM before replying, the request may time out. The sender assumes failure and retries. Result: two invoices.

The rule is to reply straight away with a success code (2xx) and do the heavy lifting afterwards. Stripe even gives the example: return the 200 before marking the invoice as paid in your accounting system.

A public endpoint is an open door

The webhook address has to be reachable from the internet. Anyone who finds it can send it requests.

Three safeguards cover almost everything:

  • Verify the signature. Serious vendors sign every request with a shared secret (HMAC-SHA256, in Stripe's case). If the signature does not match, the request is rejected.
  • Reject stale requests. The signature includes a timestamp. Stripe's libraries refuse requests older than 5 minutes by default, which stops anyone replaying an intercepted valid request.
  • Restrict the source. Accept requests only from the IP addresses the vendor publishes.

The architecture that holds up: webhook plus reconciliation

The robust answer is not to choose between webhooks and polling. It is to use both, for different jobs.

The webhook handles speed: when everything works, which is nearly always, each event is processed within seconds.

A scheduled job, once a night, handles the guarantee: it queries the source system, compares against what was processed and catches whatever slipped through, because the server was being patched, because the vendor gave up retrying, or because someone edited a record by hand.

This reconciliation is cheap to build. It is what separates an integration you can trust from one somebody has to babysit.

What if the system doesn't send webhooks?

It happens a lot. Many ERPs and invoicing tools offer an API for reading data but emit no outbound events. In that case, polling is back as the only option, and the question becomes what interval the process can tolerate.

If the system has no API at all, that is a different conversation, covered in our guide to API automation, RPA or AI and when to use each.

What it looks like in an n8n workflow

In n8n, the entry point is the Webhook node. According to the official Webhook node documentation, each node has two URLs: a test URL, active only while you are testing in the editor, and a production URL, which starts working once the workflow is published.

The most common mistake on new projects is registering the test URL in the source system. Everything works during testing and stops the next day, with no error message.

Other details worth knowing:

  • The node can respond immediately, before the workflow finishes, which is exactly what the 2xx rule calls for.
  • It supports header, basic and JWT authentication, plus an IP allowlist.
  • The maximum payload is 16 MB by default, adjustable on self-hosted instances.

If n8n runs on your own server, the endpoint must be exposed over HTTPS with a valid certificate. That is something to settle with whoever runs your infrastructure, and one of the self-hosting trade-offs we describe in what n8n is and how it works.

The question to take away

Think of a process in your company where someone, or something, checks every so often whether anything new has happened.

What does that delay cost: nothing, a few minutes of customer impatience, or selling an item you no longer have? If it is the third, the next step is to ask that system's vendor whether it sends webhooks and what its retry policy is. The answer tells you whether you need a webhook with reconciliation or a well-tuned polling interval.