Webhook
Overview of Webhooks
Webhooks allow extensions to stay in sync with the Fynd Commerce 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 page 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 events, such as the creation of a product and deletion of an order.
- Payload: The data related to the event you have subscribed to. Generally, the payload which we send is in JSON format.
- Webhook notification: A single real-time alert. When an event is triggered, Fynd Commerce 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 Commerce 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 made 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 customers 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
Example Flow
The steps below describe an example of how a 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 in the store.
- The Event is published on the
orders/placed
topic. - Fynd Commerce sends a webhook notification with the order payload to the registered webhook URL.
Was this section helpful?