This api returns reward progress for a customer
Introduction
This API enable you to know the reward progress of a customer for action based or referral campaign against it's target actions to be achieved by a customer to get the applicable reward.
for example: Get 100 points on placing 10 successful orders. customer gets reward when they completed 10 order_success event. In this case target action is 10 orders and number of order placed will be completed tasks.
API details
API Endpoint: https://api.rehook.ai/campaigns/reward-progress
HTTP Method: GET
Prerequisites
- API Key and Secret Key for your application
- If you don't know the API key and secret key, please go to setting module on admin panel to view API details for your application. To know more about application setting, please visit Application setting
- API key and secret key are auto generated and cannot be changed.
- Configure campaigns.
Limitations
- Reward progress API is applicable for only referral campaign and action based campaign
- Reward progress details will be available for following action types - 'Real time actions' and 'Actions with time'
Action type | definition | example |
---|---|---|
Real time actions | Customer will get reward as soon as defined actions are completed | Place a cumulative order worth of $200 and Get 50% coupon |
Action with time | Time bound actions, each rule will have a benchmark event X and trigger event Y. user has to complete the event Y within defined time duration of event X. | Place an order worth of $200 within 2 days from signup. |
Authentication
You need to provide the API key and Secret key of your application in every new request as Authorization. Rehook uses Basic authentication method to authenticate the API calls.
Authorization | Value |
---|---|
Username | API key of your application |
Password | Secret key of your application |
Parameters
query parameters
You have to provide following query parameters.
Parameter | Definition | value |
---|---|---|
source_id | optional Rehook id or source id of your customer | KMN@123 |
campaign_id | optional campaign_id assigned by rehook for a campaign created on rehook dashboard | campaign_123 |
campaign_type | optional type of campaign name | loyalty/referral |
Body Parameters
This API doesn't requires any body parameters.
Sample request and response
request
URL = https://api.rehook.ai/campaigns/reward-progress
query parameters:
Key | Value |
---|---|
source_id | KMN@123 |
campaign_type | loyalty |
campaign_id | camp_1I7vOuIsPbyL4fB0Kck2K |
response - for real time actions
Response body will have array of objects. each array has the campaign details participated by a given customer and it's reward progress details.
{
"campaign_id": "camp_1I7vOuIsPbyL4fB0Kck2K",
"campaign_name": "Real time action campaign",
"campaign_type": "loyalty",
"rules": [
{
"rule_id": "valr_P8lM0Vag8l2Z5CpnMhNo4",
"rule_name": "Rule 1",
"action_type": "RTA",
"actions": [
{
"event_id": "even_zPE2bLkbUH80jc663ep6E",
"event_name": "money_deposited",
"progress": 50,
"trigger": false,
"status": "active",
"current": 500,
"target": 1000
},
{
"event_id": "even_BZswDL0TV4ZRuiuoy7RmP",
"event_name": "order_success",
"progress":100,
"trigger": false,
"status": "completed",
"current":1,
"target": 1
}
]
},
{
"rule_id": "valr_DgUrJ2lIFm1WsaqEMkHzZ",
"rule_name": "Rule 2",
"action_type": "RTA",
"actions": [
{
"event_id": "even_zPE2bLkbUH80jc663ep6E",
"event_name": "complete_KYC_Verification",
"progress": 0,
"trigger": false,
"status": "active",
"current": 0,
"target": 1
}
]
}
]
}
]
Definition of response
Without object
Field | Definition | response value |
---|---|---|
campaign_type | type of campaign | loyalty/referral |
campaign_name | name of the campaign configured | Real time action campaign |
campaign_id | campaign_id assigned by rehook for a campaign created | camp_OjDaps3B7GIGs4uZQ0QhN |
Rules object (for action type = Real time actions)
Field | Definition | response value |
---|---|---|
rule_id | rule_id assigned for each rule defined in a given campaign | valr_u99SxdyMvZBCL5hfG12qE |
rule_name | name of the rule configured in a given campaign | Place 1st order within 3 days |
action_type | type of actions defined in the campaign | RTA - Real time actions AWT - Action with time |
actions (array) | ||
event_id | event_id assigned to an action defined in a rule within a campaign | even_09e9lH1qOJNy7j3Yo79ql |
event_name | name of event selected in a rule within a campaign | order_success |
progress | Shows progress of expected actions in percentage (current / target) | 100% |
trigger | Indicates if an intended event is triggered or not (applicable for only Actions with time campaigns) | true - Indicates event is received false - Indicates event is not received |
status | status of intended action | completed/active |
current | count of completed tasks currently | 2 |
target | number of tasks to be completed by a customer to get reward | 10 |
Example: Real time actions
Rule definition:
Rule 1 --> event 1: make a deposit of cumulative amount of $1000.AND event 2: Complete your first
purchaseRule 2 --> Complete your KYC verification and Get 100 loyalty points
Progress
Rule event Target Current Progress Rule1 event1 $1000 as user have to make a cumulative deposit amount of $1000 $500 50% as user have completed only $500 of target value $1000 Rule1 event2 1 as user has to make only one purchase 1 100% as user have completed the first purchase Rule2 event1 1 as user has to complete the KYC verification only 1 time 0 0% as user have not completed the KYC verification
response - Actions with time
{
"campaign_id": "camp_D01sluPJ3NBv82cpWQbs1",
"campaign_name": "Action with time",
"campaign_type": "loyalty",
"rules": [
{
"rule_id": "valr_2mvsVY2amxKjgZxuwQzKo",
"rule_name": "Place a min order worth of $200 within 2 days of signup and get a 20% coupon",
"action_type": "AWT",
"actions": [
{
"event_id": "even_WoPKAqCWhTOkJ2UGLRLbS",
"event_name": "signup",
"progress": 100,
"trigger": true,
"status": "completed",
"current": 1,
"target": 1,
"start_time": 1708664771
},
{
"event_id": "even_zPE2bLkbUH80jc663ep6E",
"event_name": "order_success",
"progress": 100,
"trigger": false,
"status": "completed",
"current": 1,
"target": 1,
"start_time": 1708664771,
"end_time": 1708837571,
"time_duration": 172800,
"time_left": 172784
}
]
}
]
}
Rules object (for action type = Actions with time)
Field | Definition | response value |
---|---|---|
rule_id | rule_id assigned for each rule defined in a given campaign | valr_u99SxdyMvZBCL5hfG12qE |
rule_name | name of the rule configured in a given campaign | Place 1st order within 3 days |
action_type | type of actions defined in the campaign | RTA - Real time actions |
actions (array) - for event X | ||
event_id | event_id assigned to an action defined in a rule within a campaign | even_WoPKAqCWhTOkJ2UGLRLbS |
event_name | name of event selected in a rule within a campaign | signup |
progress | Shows progress of expected actions in percentage | 100% |
trigger | Indicates if event X is triggered or not | true - Indicates event X is received false - Indicates event X is not received |
status | status of intended action | active/completed |
current | count of completed tasks currently | 1 |
target | number of tasks to be completed by a customer to get reward | 1 |
start_time | Timestamp when event X is triggered | |
actions (array) - for event Y | All response data fields will remain same as event X except followings: | |
trigger | Indicates if event Y is triggered or not | true - Indicates event Y is received false - Indicates event Y is not received |
start_time | Timestamp when event X is triggered | 1708664771 (format: Unix epoch) |
end_time | Timestamp when event Y is to be triggered | 1708837571 (format: Unix epoch) |
time_duration | time taken to complete the Yth event. | 172800 (format: Unix epoch) |
time_left | remaining time left to complete the Yth event. case 1: if status is completed this value is redundant as user have already completed the event. case 2: if status is active, trigger is false and time left is 0, that means user have exhausted time limit to complete the intended action. | 172784 (format: Unix epoch) |
Example: Actions with time
Rule definition
place a min order worth of $200 within 2 days of signup and get 0% coupon
Event X (Benchmark event): signup
Event Y (Trigger event): order_success
Rule timer:
System will start the timer when signup event is received and user is expected to complete the order_success event within 2 days from start_time of event X
Rule progress
Event Target Current Timer Progress signup (event X) 1 1 start_time: 1708664771
signup is completed on 21st feb100% as user have completed the event X order_success (event Y) 1 1 start_time: same as event x
end_time: 1708837571
time_duration: 172800
time_left: 172784100% as user have completed the event Y within 2 days of signup.
Success Response:
If API call is successful, then Rehook will return the following HTTP success code with response body as given above.
HTTP Code | Message |
---|---|
200 | Ok |
Error Responses
If API call is failed, then Rehook will return the following HTTP success code with response body as given below:
HTTP Code | Message |
---|---|
400 | bad request |
error response body
field name | description | example |
---|---|---|
Code | Error code | 400 |
details | Error details | Cannot find customer with source id source_id |
message | error message | coupon_code not found |
request_id | API request Id assigned by Rehook | abc_123 |
**when source_id is wrong or not passed in the URL
{
"code": 404,
"key": "not_found",
"message": "Resource not found",
"details": "Cannot find customer with source id source_id",
"request_id": "9c0003f4-0443-9101-bb13-245b8ddd0070"
}