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
1
{
2
// General props
3
"id": "coupon-id",
4
"customerId": "customer-id",
5
"name": "coupon-name",
6
"code": "coupon-code",
7
8
// Rules
9
"couponType": "fixedAmount", // Fixed Amount Discount on Entire Order
10
"discountValue": 100, // $100 Off
11
"applicableOn": "order", // Apply discount on entier order
12
"applicableFilters": null, // not applicable
13
"usageLimitType": "once", // Customer can use this coupon only once
14
"minOrderAmount": 1500, // coupon will be only applicable if amount > 100
15
16
// Expiry Settings
17
"expiryType": "relative", // Expiry relative to when coupon is generated
18
"expiryValue": 15, // # of hours
19
"expiryUnit": "day" // Expiry in days (you can mention hours or days)
20
}
Copied!

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

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

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
1
{
2
// General props
3
"id": "coupon-id",
4
"customerId": "customer-id",
5
"name": "coupon-name",
6
"code": "coupon-code",
7
8
// Rules
9
"couponType": "freeShipping", // Discount in percentage
10
"discountValue": '<any>', // Not applicable
11
"applicableOn": "order", // Not Applicable
12
"applicableFilters": null, // Not Applicable
13
"usageLimitType": "once", // Customer can use this coupon only once
14
"minOrderAmount": 500, // coupon will be only applicable if amount > 100
15
16
// Expiry Settings
17
"expiryType": "relative", // Expiry relative to when coupon is generated
18
"expiryValue": 48, // # of hours
19
"expiryUnit": "hour" // Expiry in hours (you can mention hours or days)
20
}
Copied!