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.
-
-
Click on '+Add New' CTA against application for which webhook to be configured.
-
System will open the webhook configuration modal as given below
- In End Point URL enter the destination url where you want to receive reward information.
- Click Test to validate if end point URL is working. You will receive a HTTP Status 200 OK response.
- (Optional) To add basic authorization, enter the user id and password.
- (Optional) You can add header parameters to the webhook payload if required. Click +Add Another to add as many key value pairs.
- Select the webhook events you want to receive
- Click Save Webhook to configure the reward webhook.
Webhook event definition
event | webhook is triggered |
---|---|
customer.rewarded | when a customer is rewarded or to be rewarded |
order_success | when a customer successfully placed an order |
signup | when user is signup |
coupon.rewarded | when coupon is assinged to a customer |
coupon.created | when a coupon is created |
coupon.redeemed | when customer redeems a coupon code |
customer.meta.updated | when user properties of a customer is updated |
customer.referred | when friend is logged in using a advocate referral code. this event is associated with a friend. |
customer.referral.successful.advocate | when 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.friend | when 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.awarded | when leaderboard participants are rewarded or to be rewarded once recurrence of leaderboard is ended and next recurrence is started. |
customer.created | when a new customer is created |
coupon.redemption.rollback | when a redeemed coupon is rolled back |
customer.updated | when customer details are updated |
customer.segment.entered | when a customer eligible for a segment created |
customer.segment.left | when a eligible customer have left the segment |
Webhook events
Followings are the list of system events and it's webhook response body.
- 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
Object | array | Field | Definition | example |
---|---|---|---|---|
NA | NA | event.name | name of the event | customer.rewarded |
NA | NA | source | name of the source from which event is triggered | rehook |
NA | NA | source_id | source_id of your customer | KMN@123 |
Metadata | campaign | id | unique campaign_id assigned by rehook | camp_0pe3HDtdFYgf1P5vryaXk |
Metadata | campaign | type | type of the campaign | loyalty/referral/distribution/leaderboard |
Metadata | NA | coupon | coupon code distributed to the customer | DIWALI123 |
Metadata | NA | custom_fields | ||
Metadata | NA | points | webhook points to be rewarded to the customer from your end | 20 |
Metadata-reward | activation | is_immediate | indicates whether reward to be activated immediately or not | boolean |
Metadata-reward | activation | start_date | start date of the reward to be activated | 2023-09-21T07:46:56.8421482Z |
Metadata-reward | expiration | expiration_date | indicates when reward to be expired | 2023-09-21T07:46:56.8421482Z" |
Metadata-reward | expiration | never_expires | indicates reward will never expires | boolean |
Metadata-reward | NA | name | name of the reward | webhook points reward |
Metadata-reward | NA | redemption_date | redemption date of reward | 2023-09-21T07:46:56.8421482Z" |
Metadata-reward | NA | redemption_id | redemption id of reward is redeemed | redm_4RAUHTR8mGqoWn3QmtTqS |
Metadata-reward | NA | reward_id | reward id | rewd_C1BnYHxmlmF1fi3lQk7Ud |
Metadata-reward | NA | source_id | source id of your customer | KMN@123 |
metadata | wallet | created_at | wallet created date | 023-09-21T07:46:56.8421482Z |
metadata | wallet | description | description of wallet transaction | Wallet points have been successfully credited to your account |
metadata | wallet | points | points rewarded to the customer wallet | 20 |
metadata | wallet | transaction_id | transaction id of wallet transaction | trhi_9PO542v74DMGDkBkgLHtf |
metadata | wallet | updated_at | updated date of wallet transaction | 2023-09-21T07:46:56.8421482Z |
Webhook event behaviour
- Above webhook event is triggered when customer is rewarded with application wallet based on campaign earning rule condition is met.
- 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)
- In this event body, event type = loyalty points. that means, rehook have already rewarded the customer.
- Event body has campaign details and reward details credited to the customer.
- On above event received, your application can call Get wallet API for given source_id to confirm the credited reward
- On above event received, your application doesn't have to take any action as customer is already rewarded.
- 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
- 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.
- Event body has reward details, campaign details and customer details
- 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.
- 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.
- 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"
}
- 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"
}
- 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
- 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.
- 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.
- 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"
}
- 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"
}
- 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"
}