1. Concepts
  2. Webhooks

Concepts

Webhooks

How webhooks work with stubber

A webhook is a way that you can trigger an action on a stub from an external system. A webhook will only be able to execute actions that are "available" in the state of the stub. If the stub has progressed through a state, the actions that were available at that state will not be able to be triggered by a webhook.

Use Cases for Webhooks:

  • Creating Stubs from an External System:

If you have a form on a website where users can submit requests or information. A webhook can be used to automatically create a stub whenever a form submission occurs. This ensures that every user interaction is captured in real-time without manual intervention.

  • Posting Updates on a Stub:

Consider a scenario where your application interacts with a ticketing system (like JIRA or Zendesk). When an update occurs in the ticketing system, such as a change in the ticket status, a webhook can post this update to the corresponding stub. This keeps your records synchronized and up-to-date with external systems.

  • Notifying a Stub When a Payment is Made:

In an e-commerce or subscription-based service, it's crucial to track payments. A webhook can be set up to notify your application whenever a payment is made through an external payment processor (like PayPal or Stripe). This notification can trigger actions on the stub.

  • Indicating Authorization Has Been Granted:

When a user needs to authorize an action by clicking a link (for instance, confirming their email address or granting permission for data access), a webhook can signal your application that the authorization has been granted. This can update the stub to reflect the authorized status and enable subsequent actions based on this authorization.

NOTE

See the action meta webhook section for more information on how to enable webhooks on actions.

Conceptual

Here we have a diagram showing how this works.

An external system makes a POST request to the webhook url. It contains data in the body that is needed by the process.

Templates & Stubs

Practical

Below is an exmaple of enabling a webhook on an action and triggering that action via postman