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 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)
}

Last updated