Webhook

Overview of Webhooks

Webhooks allow extensions to stay in sync with the Fynd Platform data or perform actions after a specific event occurs in a store. Webhooks are a performant alternative to continuously polling for changes to a store’s data.

For example, a webhook can notify your extension when a customer places an order on your website. Your extension can then perform an action when the order is placed. Another example is a webhook notifying your extension when a product goes out of stock, allowing your extension to take action when that happens.

This guide introduces how webhooks work and explains how to configure webhooks for your extension.


Webhook Concepts

  • Event: The action performed by your staff and customers. We support webhook notifications for multiple types of events, such as the creation of a product, deletion of an order, and many more.

  • Payload: The data related to the event you've subscribed to. Generally, the payload which we send is in JSON format.

  • Webhook notification: A single real-time alert. When an event is triggered, the Fynd Platform sends a webhook notification to an extension’s webhook URL. It contains the payload in the body along with some metadata.

  • Webhook URL: Also known as a webhook endpoint, it's the URL on which you want the Fynd Platform to send the payload. Please ensure that your webhook URL adheres to the following criteria:

    • It should be an HTTPS URL.
    • It should be a publicly accessible URL.
    • Authentication is recommended but not mandatory.

  • Webhook subscription: A list of events for which you have chosen to receive webhook notifications on your app or server.

  • Webhook topic: A class of webhook events. Topics control the conditions for creating events and what is included in the payload. For example, orders/placed events are sent whenever an order is created for a store and contain the new order as the payload.

  • Subscribe: The act of picking an event or topic to receive notifications.


Use Cases

Common webhook use cases include the following:

  • Sending WhatsApp notifications to a customer when they place an order.
  • Collecting data for data warehousing.
  • Notifying when a product is out of stock.
  • Removing customer data from a database when the extension is uninstalled.

Polling vs Webhooks

polling vs webhooks


Example flow

The steps below describe an example of how webhook Event flows:

  • The extension subscribes to the orders/placed topic for a store.
  • The extension registers a webhook URL hosted by its server.
  • An order is created on the store.
  • The Event is published to the orders/placed topic.
  • Fynd Platform sends a webhook notification with the order payload to the registered webhook URL.