Below we will cover how to configure your first webhook. Follow along or create your own based on the example below.
Step 1.
Create your new webhook
Description: This is a free form field where you can name your webhook.
Include object record: If the event has information related to it, then you will receive that object record as part of the payload of the webhook. For example, if you subscribe to the "order update" event then you will get the order object including all the order details in the payload of the webhook. This is handy as it may help to prevent you from needing to make another call to the evoX API to retrieve this information. Not all event's have and object record payload.
Endpoint URL: This is the endpoint that you would like the post request to be sent to when the webhook fires.
Headers/Query parameters: Enter the headers and query parameters that should be sent along with the post request.
Events: Choose which events you want to subscribe to. For each event that you choose, when that event occurs the webhook will fire a post request to your chosen endpoint. You can choose to subscribe to multiple events or just one.
Testing
Once you have saved your event. Test fire the event by interacting with the admin or store based on the event that you have subscribed. For example, if you subscribed to the create order event then put in a test order on the system.
Where to see your webhook detail
Go to the event's screen and you will see your webhook has fired. Click on it to get the detail.
Scroll to the bottom of the page and you will see a link for the request and response detail. This page will give you the entire payload that was sent to the endpoint and any response that was received.
Anatomy of the Webhook post request
The post request will look like the below. Let's walk through some of the attributes to clarify.
Event_data: This determines the user or customer that the object relates. For example, if an order was created this would be the customer(Account) and user that the order was for. It is not necessarily who initiated the event.
Event_object_id: An example of this would be the order id, if you subscribed to the create order event.
Event_object_type: This tells you what type of object the event contains.
Source_user_id: This is the user that initiated the action that caused this event. For example, if the order was created on the admin then this would be the Admin user's id. If it was created on the storefront then this would be the customer user id.
Source_user_type: This tell you what type of user initiated the event. For example, a storefront user or an admin user.
Previous_attribute: This contains the previous setting for a given attribute before the event was initiated. This object is not used in all events.
Event data vs Object: You will receive some attribute information with all webhooks posts. See below.