API Reference

Introduction

This doc helps you understand how to setup the webhook configuration. The reward webhook allows Rehook to send real time information about rewards earned by your customers to your system.

Webhook Configuration

Please follow the below steps to configure the webhook for your applications.

  1. Click on '+Add New' CTA against application for which webhook to be configured.

  2. System will open the webhook configuration modal as given below

  1. In End Point URL enter the destination url where you want to receive reward information.
  2. Click Test to validate if end point URL is working. You will receive a HTTP Status 200 OK response.
  3. (Optional) To add basic authorization, enter the user id and password.
  4. (Optional) You can add header parameters to the webhook payload if required. Click +Add Another to add as many key value pairs.
  5. Select the webhook events you want to receive
  6. Click Save Webhook to configure the reward webhook.

Webhook event definition

eventwebhook is triggered
customer.rewardedwhen a customer is rewarded or to be rewarded
order_successwhen a customer successfully placed an order
signupwhen user is signup
coupon.rewardedwhen coupon is assinged to a customer
coupon.createdwhen a coupon is created
coupon.redeemedwhen customer redeems a coupon code
customer.meta.updatedwhen user properties of a customer is updated
customer.referredwhen friend is logged in using a advocate referral code. this event is associated with a friend.
customer.referral.successful.advocatewhen a friend signup using advocate referral code and completes the intended action defined in advocate earning rule. this event is associated with an advocate
customer.referral.successful.friendwhen a friend signup using advocate referral code and rewarded by completing an intended action defined in friend earning rule. This event is associated with a friend.
customer.leaderboard.awardedwhen leaderboard participants are rewarded or to be rewarded once recurrence of leaderboard is ended and next recurrence is started.
customer.createdwhen a new customer is created
coupon.redemption.rollbackwhen a redeemed coupon is rolled back
customer.updatedwhen customer details are updated
customer.segment.enteredwhen a customer eligible for a segment created
customer.segment.leftwhen a eligible customer have left the segment

Webhook events

Followings are the list of system events and it's webhook response body.

  1. customer.rewarded

This event is triggered when customer have rewarded based on campaign earning rule condition is met.

{
  "event_name": "customer.rewarded",
  "metadata": {
    "campaign": {
      "id": "camp_0pe3HDtdFYgf1P5vryaXk",
      "type": "loyalty"
    },
    "coupon": null,
    "custom_fields": null,
    "points": 10,
    "reward": {
      "activation": {
        "days": 1,
        "is_immediate": true,
        "start_date": null
      },
      "expiration": {
        "days": 1,
        "expiration_date": null,
        "never_expires": true
      },
      "name": "order success reward",
      "redemption_date": "2023-09-21T07:46:56.8421482Z",
      "redemption_id": "redm_4RAUHTR8mGqoWn3QmtTqS",
      "reward_id": "rewd_C1BnYHxmlmF1fi3lQk7Ud"
    },
    "source_id": "KMN@123",
    "wallet": {
      "created_at": "0001-01-01T00:00:00Z",
      "description": "Wallet points have been successfully credited to your account.",
      "points": 10,
      "transaction_id": "trhi_9PO542v74DMGDkBkgLHtf",
      "updated_at": "0001-01-01T00:00:00Z"
    }
  },
  "source": "rehook",
  "source_id": "KMN@123"
}

Definition of webhook event body

ObjectarrayFieldDefinitionexample
NANAevent.namename of the eventcustomer.rewarded
NANAsourcename of the source from which event is triggeredrehook
NANAsource_idsource_id of your customerKMN@123
Metadatacampaignidunique campaign_id assigned by rehookcamp_0pe3HDtdFYgf1P5vryaXk
Metadatacampaigntypetype of the campaignloyalty/referral/distribution/leaderboard
MetadataNAcouponcoupon code distributed to the customerDIWALI123
MetadataNAcustom_fields
MetadataNApointswebhook points to be rewarded to the customer from your end20
Metadata-rewardactivationis_immediateindicates whether reward to be activated immediately or notboolean
Metadata-rewardactivationstart_datestart date of the reward to be activated2023-09-21T07:46:56.8421482Z
Metadata-rewardexpirationexpiration_dateindicates when reward to be expired2023-09-21T07:46:56.8421482Z"
Metadata-rewardexpirationnever_expiresindicates reward will never expiresboolean
Metadata-rewardNAnamename of the rewardwebhook points reward
Metadata-rewardNAredemption_dateredemption date of reward2023-09-21T07:46:56.8421482Z"
Metadata-rewardNAredemption_idredemption id of reward is redeemedredm_4RAUHTR8mGqoWn3QmtTqS
Metadata-rewardNAreward_idreward idrewd_C1BnYHxmlmF1fi3lQk7Ud
Metadata-rewardNAsource_idsource id of your customerKMN@123
metadatawalletcreated_atwallet created date023-09-21T07:46:56.8421482Z
metadatawalletdescriptiondescription of wallet transactionWallet points have been successfully credited to your account
metadatawalletpointspoints rewarded to the customer wallet20
metadatawallettransaction_idtransaction id of wallet transactiontrhi_9PO542v74DMGDkBkgLHtf
metadatawalletupdated_atupdated date of wallet transaction2023-09-21T07:46:56.8421482Z

📘

Webhook event behaviour

  1. Above webhook event is triggered when customer is rewarded with application wallet based on campaign earning rule condition is met.
  2. This event data is passed in the webook event body only for campaigns having reward as points in wallet. (Rehook will distribute the reward to customer)
  3. In this event body, event type = loyalty points. that means, rehook have already rewarded the customer.
  4. Event body has campaign details and reward details credited to the customer.
  5. On above event received, your application can call Get wallet API for given source_id to confirm the credited reward
  6. On above event received, your application doesn't have to take any action as customer is already rewarded.
  1. Customer.rewarded : webhook reward

This event is triggered when customer is to be rewarded from your end based on campaign earning rule condition is met. your application have to reward the customer on your application hosted wallet based on reward details received in the event body.

{
  "event_name": "customer.rewarded",
  "metadata": {
    "campaign": {
      "id": "camp_wfzCvil55m05zpxafISmc",
      "type": "loyalty"
    },
    "coupon": null,
    "custom_fields": null,
    "points": 100,
    "reward": {
      "activation": {
        "days": 1,
        "is_immediate": true,
        "start_date": null
      },
      "expiration": {
        "days": 1,
        "expiration_date": null,
        "never_expires": true
      },
      "name": "Webhook points",
      "redemption_date": "2023-09-21T10:08:06.614367478Z",
      "redemption_id": "redm_pVRReQyxgFEr3MsSQIYBF",
      "reward_id": "rewd_cYjMQ9495B3HIWduEv9qp"
    },
    "source_id": "KMN@123",
    "wallet": {
      "points": 0
    }
  },
  "source": "rehook",
  "source_id": "KMN@123"
}

📘

Webhook event behaviour - for webhook reward

  1. when this event is triggered, your application have to reward the customer on your application hosted wallet based on reward details received in the event body.
  2. Event body has reward details, campaign details and customer details
  3. To identify whether it is a webhook reward or not , you have to refer to event type = webhook or wallet object data will be empty.
  4. This events are associated with a customer and campaign. you will receive webhook events for each customers separately. for example: If you have configured a distribution campaign to distribute 20 points to 30 eligible customers, then system will trigger 30 reward events.
  1. order_success

This event is triggered when customer placed order is success.

{
  "event_name": "order_success",
  "metadata": {
    "cart": [
      {
        "brand": "Apple",
        "category": "smartphones",
        "description": "An apple mobile which is nothing like apple",
        "discountPercentage": 12.96,
        "id": 1,
        "images": [
          "https://i.dummyjson.com/data/products/1/1.jpg",
          "https://i.dummyjson.com/data/products/1/2.jpg",
          "https://i.dummyjson.com/data/products/1/3.jpg",
          "https://i.dummyjson.com/data/products/1/4.jpg",
          "https://i.dummyjson.com/data/products/1/thumbnail.jpg"
        ],
        "price": 549,
        "quantity": 1,
        "rating": 4.69,
        "selected": false,
        "stock": 94,
        "thumbnail": "https://i.dummyjson.com/data/products/1/thumbnail.jpg",
        "title": "iPhone 9"
      }
    ],
    "mode": "CARD",
    "total": 549
  },
  "source": "rehook",
  "source_id": "KMN@123"
}
  1. customer.referral.successful.advocate

This event is triggered when advocate have received the reward.

{
  "event_name": "customer.referral.successfull.advocate",
  "metadata": {
    "AdvocateId": "cust_IaU3FtThmRR9PQR3dlg3G",
    "CampaignID": "camp_lEnxQA6GOOYPQIms0ZEk5",
    "CampaignName": "",
    "CampaignType": "referral",
    "Code": "",
    "ConnectedCustomerId": "cust_gNF2L20gWx71vGQ7dVPGW",
    "CustomerId": "cust_IaU3FtThmRR9PQR3dlg3G",
    "PointsRewarded": 10,
    "RedemptionId": "redm_TqOJroirusQu8W7f6YxAB",
    "RewardId": "rewd_CI0DV1xKAGt9sqpPgKiQc",
    "RewardType": "webhook",
    "RuleId": "valr_v4Sqvq1Nblny8Qt6WkWdR",
    "Type": "referral_advocate"
  },
  "source": "rehook",
  "source_id": "KRISH@123"
}
  1. customer.referral.successful.friend

This event is triggered when friend is earned the reward after completing the intended earning rule action.

{
  "event_name": "customer.referral.successfull.friend",
  "metadata": {
    "AdvocateId": "NA",
    "CampaignID": "camp_lEnxQA6GOOYPQIms0ZEk5",
    "CampaignName": "",
    "CampaignType": "referral",
    "Code": "",
    "ConnectedCustomerId": "NA",
    "CustomerId": "cust_gNF2L20gWx71vGQ7dVPGW",
    "PointsRewarded": 10,
    "RedemptionId": "redm_jhtWjrmCjdH7Ko7TTYIIB",
    "RewardId": "rewd_oXodQ9ZkiFqJhKpkh8mcR",
    "RewardType": "webhook",
    "RuleId": "valr_ct1DiY2d2aWll50b4Wo1b",
    "Type": "referral_friend"
  },
  "source": "rehook",
  "source_id": "New_customer24"
}

📘

Note: webhook reward for referral events

  1. If you have mapped a webhook reward to the referral campaign, you will also receive customer.reward event when above two events are successful which indicates that, you have to reward the customer wallet on your application.
  2. In above two events, rehook have passed pointsrewarded to the customer, that means, referral campaign spend is updated with reward points to be given to the customer but customer wallet to be updated from your end.
  1. customer created

This event is triggered when a new customer is created.

{
  "event_name": "customer.created",
  "metadata": {
    "CustomerID": "cust_rQgkYNzPVgye5RKUy9l30"
  },
  "source": "rehook",
  "source_id": "New_customer20"
}
  1. wallet.credited

This event is triggered when customer wallet is credited

{
  "event_name": "wallet.credited",
  "metadata": {
    "points": 10,
    "wallet": {
      "created_at": "2023-09-22T10:12:48.68849339Z",
      "description": "Wallet points have been successfully credited to your account.",
      "points": 10,
      "transaction_id": "trhi_JfW8QKvD5SxfOfIqWRSe3",
      "type": "credit",
      "updated_at": "2023-09-22T10:12:48.68849339Z"
    }
  },
  "source": "rehook",
  "source_id": "New_customer1"
}
  1. wallet.debited

This event is triggered when customer wallet is debited

{
  "event_name": "wallet.debited",
  "metadata": {
    "points": 10,
    "wallet": {
      "created_at": "2023-09-22T10:12:48.68849339Z",
      "description": "Wallet points have been successfully credited to your account.",
      "points": 10,
      "transaction_id": "trhi_JfW8QKvD5SxfOfIqWRSe3",
      "type": "credit",
      "updated_at": "2023-09-22T10:12:48.68849339Z"
    }
  },
  "source": "rehook",
  "source_id": "New_customer1"
}