In this guide, we will look at how to register and consume webhooks to integrate your app with BetterCommerce. With webhooks, your app can know when something happens in BetterCommerce, such as someone sending a message or adding a contact.

Registering webhooks

To register a new webhook, you need to have a URL in your app that BetterCommerce can call. You can configure a new webhook from the BetterCommerce dashboard under API settings. Give your webhook a name, pick the events you want to listen for, and add your URL.

Now, whenever the respective event is fired within BetterCommerce, a webhook is fired off and the data is posted to the URL configured for respective webhook. You can setup multiple webhooks for the same event to enable you to receive the entity+event data into different applications. You can customize the complete body of the webhook using the entity variables for the respective entity.

Consuming webhooks

When your app receives a webhook request from BetterCommerce, you can parse the request body based on the configured webhook body. The webhook posted will contain the evntity specific data in the format that has been setup by yourself.

Sample Webhook

Following is a sample webhook body that can be configured to be fired on order entity and created event. The platform offers lot more than vanilla body messages and allows you to create logic & customize the body within the message. It eliminates the need of creating another layer to transform the vanilla entity into something useful for a 3rd party system.

Example webhook message body

    "id": "{{Id}}",
    "displayOrderNumber": "{{CustomNo}}",
    "orderDate": "{{OrderDate | DateFormat}}",
    "orderStatus": "{{StatusCode}}",
    "sla": "{{DueDate | DateFormat}}",
    "orderPrice": {
        "currency": "{{CurrencyCode}}",
        "totalCashOnDeliveryCharges": {{PaymentAdditionalCharge}},
        "totalDiscount": {{DiscountAmt}},
        "totalGiftCharges": 0,
        "totalShippingCharges": {{ShippingCharges}}
    "orderItems": [ {% for ItemLine in OrderLines -%}  
						{% if forloop.index != 1 %}
   						{% endif %}  
					"orderItemId": "{{ItemLine.Id}}",
					"status": "CREATED",
					"productId": "{{ItemLine.Sku}}",
					"variantId": "{{ItemLine.ExternalRefNo}}",
					"sku": "{{ItemLine.ProductStockCode}}",
					"title": "{{ItemLine.Name}}",
					"orderItemPrice": {
						"sellingPrice": {{ItemLine.SellPricePerUnit}},
						"totalPrice": {{ItemLine.LineTotal}},
						"transferPrice": 0,
						"currency": "{{CurrencyCode}}"
					"quantity": {{ItemLine.Qty}},
					"onHold": false,
					"packetNumber": 1
		{% endfor -%} 
    "taxExempted": false,
    "cFormProvided": false,
    "thirdPartyShipping": false,
    "shippingAddress": {
        "addressLine1": "{{ShippingAddress.Address1}}",
        "addressLine2": "{{ShippingAddress.Address2}}",
        "city": "{{ShippingAddress.City}}",
        "country": "{{ShippingAddress.CountryCode}}",
        "email": "{{UserEmail}}",
        "name": "{{ShippingAddress.FirstName}} {{ShippingAddress.LastName}}",
        "phone": "{{ShippingAddress.PhoneNo}}",
        "pincode": "{{ShippingAddress.PostCode}}",
        "state": "{{ShippingAddress.State}}"
    "additionalInfo": ""