Coupon Webhook

This article describes how you can integrate coupon webhooks to receive coupon creation requests generated from Growlytics.

Introduction

You can use webhook subscriptions to receive coupon creation notifications when coupon is generated for a given customer by Growlytics. After you've subscribed to coupon creation webhook, you can let your app execute code immediately after for given coupon.

Considerations

  • Coupon webhook is a POST request. All the data will be passed in JSON format in the HTTP post body.

  • With each webhook request, you will receive customer id, coupon id (of Growlytics), and discount rules that you have specified in Growlytics dashboard.

Webhook Property

Data Type

Description

id

string

Growlytics Coupon id

customerId

string

Customer id of your system, if customer is identified. If coupon is sent and customer is not identified, this field will remain null.

code

string

Coupon code sent to customer.

name

string

Coupon name specified in growlytics.

couponType

string

'fixedAmount' or 'percentage' or 'freeShipping'

discountValue

number

If coupon type is "fixedAmount", then this value represents amount of discount. If coupon type is "percentage", this value will be percentage of discount. If coupon type is "freeShipping", you can ignore this field.

applicableOn

string

"Order" if discount is on entire order. "product" if discount to be applied on specific products. "collection" if discount to be applied on specific collections.

applicableFilters

Array Of String

If applicableOn is "product", this field will be array of products. If applicableOn is "collection", this field will be array of collections. For rest, you can ignore this field.

minOrderAmount

number

Minimum order amount for discount to be applicable.

usageLimitType

string

"once" or "multiple"

expiryType

string

"relative" or "date". Right now only relative is supported by Growlytics. "date" is coming soon.

expiryUnit

string

Unit of expiry. It will be one of "hour" or "day".

expiryValue

number

number of hours or days. Depending on expiryUnit specified.

Webhook Examples

Let's take a few examples and understand what input you will get in http call for different scenarios.

Example 1: $100 off on entire order, if order amount is greater than $1500, coupon expires in 15 days

JSON IN HTTP POST BODY
{
// General props
"id": "coupon-id",
"customerId": "customer-id",
"name": "coupon-name",
"code": "coupon-code",
// Rules
"couponType": "fixedAmount", // Fixed Amount Discount on Entire Order
"discountValue": 100, // $100 Off
"applicableOn": "order", // Apply discount on entier order
"applicableFilters": null, // not applicable
"usageLimitType": "once", // Customer can use this coupon only once
"minOrderAmount": 1500, // coupon will be only applicable if amount > 100
// Expiry Settings
"expiryType": "relative", // Expiry relative to when coupon is generated
"expiryValue": 15, // # of hours
"expiryUnit": "day" // Expiry in days (you can mention hours or days)
}

Example 2: 10% OFF on selected products, If order amount is greater than 10k, coupon expires in 48 hours

JSON IN HTTP POST BODY
{
// General props
"id": "coupon-id",
"customerId": "customer-id",
"name": "coupon-name",
"code": "coupon-code",
// Rules
"couponType": "percentage", // Discount in percentage
"discountValue": 10, // 10% off
"applicableOn": "prdouct", // Apply discount on specific products
"applicableFilters": ['a','b'],// List of prdouct ids on which discounts are applicable
"usageLimitType": "once", // Customer can use this coupon only once
"minOrderAmount": 10000, // coupon will be only applicable if amount > 100
// Expiry Settings
"expiryType": "relative", // Expiry relative to when coupon is generated
"expiryValue": 48, // # of hours
"expiryUnit": "hour" // Expiry in hours (you can mention hours or days)
}

Example 3: Free Shipping, If order amount is greater than 10k and shipping amount is more than $500, coupon expires in 48 hours

JSON IN HTTP POST BODY
{
// General props
"id": "coupon-id",
"customerId": "customer-id",
"name": "coupon-name",
"code": "coupon-code",
// Rules
"couponType": "freeShipping", // Discount in percentage
"discountValue": '<any>', // Not applicable
"applicableOn": "order", // Not Applicable
"applicableFilters": null, // Not Applicable
"usageLimitType": "once", // Customer can use this coupon only once
"minOrderAmount": 500, // coupon will be only applicable if amount > 100
// Expiry Settings
"expiryType": "relative", // Expiry relative to when coupon is generated
"expiryValue": 48, // # of hours
"expiryUnit": "hour" // Expiry in hours (you can mention hours or days)
}