How can I register for webhook events in the Fynd platform and what steps should I follow to set up a webhook configuration?
The configuration of a webhook on the Fynd platform involves several steps:
-
Creating an endpoint: You need to create an endpoint that will receive events published to the webhook topic and then specify this endpoint as the webhook subscription’s destination.
-
Registering for webhook events: To handle tasks when certain events occur on the Fynd platform, you can subscribe to such events. This subscription process involves passing webhook_config in the setupFdk function. This function provides you with key details for your webhook configuration.
-
Creating an API endpoint for the webhook to listen: On the given API path, there should be view to receive webhook calls. This should be a POST API path. The API view should call the processWebhook method of the webhookRegistry object available under fdkClient.
-
Configuring your webhook settings: If you set your
subscribed_saleschannel
as ‘specific’, it denotes that you’ll need to manually subscribe to sales channel/website level events individually. By default, the value is ‘all’, which means the event will be subscribed for all sales channels. You can manually manage these settings using functions like enableSalesChannelWebhook and disableSalesChannelWebhook. -
Webhook Registry Subscription: When the webhook configuration is passed to setupFdk, as an extension is launched to a company where it’s installed or to be installed, the webhook config data is utilized to create a webhook subscriber on the Fynd Platform for that company.
Please note that any updates to the webhook configuration will not automatically update the subscriber data on the Fynd Platform for a company until the extension is opened at least once after the update. You can manually update the webhook configuration by calling the syncEvents function of the webhookRegistry.
You can learn more about the specifics here.