API Reference

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

  1. API Key and Secret Key for your application
  2. 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
  3. API key and secret key are auto generated and cannot be changed.
  4. Configure campaigns.

Limitations

  1. Reward progress API is applicable for only referral campaign and action based campaign
  2. Reward progress details will be available for following action types - 'Real time actions' and 'Actions with time'
Action typedefinitionexample
Real time actionsCustomer will get reward as soon as defined actions are completedPlace a cumulative order worth of $200 and Get 50% coupon
Action with timeTime 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.

AuthorizationValue
UsernameAPI key of your application
PasswordSecret key of your application

Parameters

query parameters

You have to provide following query parameters.

ParameterDefinitionvalue
source_idoptional
Rehook id or source id of your customer
KMN@123
campaign_idoptional
campaign_id assigned by rehook for a campaign created on rehook dashboard
campaign_123
campaign_typeoptional
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:

KeyValue
source_idKMN@123
campaign_typeloyalty
campaign_idcamp_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

FieldDefinitionresponse value
campaign_typetype of campaignloyalty/referral
campaign_namename of the campaign configuredReal time action campaign
campaign_idcampaign_id assigned by rehook for a campaign createdcamp_OjDaps3B7GIGs4uZQ0QhN

Rules object (for action type = Real time actions)

FieldDefinitionresponse value
rule_idrule_id assigned for each rule defined in a given campaignvalr_u99SxdyMvZBCL5hfG12qE
rule_namename of the rule configured in a given campaignPlace 1st order within 3 days
action_typetype of actions defined in the campaignRTA - Real time actions
AWT - Action with time
actions (array)
event_idevent_id assigned to an action defined in a rule within a campaigneven_09e9lH1qOJNy7j3Yo79ql
event_namename of event selected in a rule within a campaignorder_success
progressShows progress of expected actions in percentage
(current / target)
100%
triggerIndicates 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
statusstatus of intended actioncompleted/active
currentcount of completed tasks currently2
targetnumber of tasks to be completed by a customer to get reward10

📘

Example: Real time actions

Rule definition:

Rule 1 --> event 1: make a deposit of cumulative amount of $1000.AND event 2: Complete your first
purchase

Rule 2 --> Complete your KYC verification and Get 100 loyalty points

Progress

RuleeventTargetCurrentProgress
Rule1event1$1000 as user have to make a cumulative deposit amount of $1000$50050% as user have completed only $500 of target value $1000
Rule1event21 as user has to make only one purchase1100% as user have completed the first purchase
Rule2event11 as user has to complete the KYC verification only 1 time00% 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)

FieldDefinitionresponse value
rule_idrule_id assigned for each rule defined in a given campaignvalr_u99SxdyMvZBCL5hfG12qE
rule_namename of the rule configured in a given campaignPlace 1st order within 3 days
action_typetype of actions defined in the campaignRTA - Real time actions
actions (array) - for event X
event_idevent_id assigned to an action defined in a rule within a campaigneven_WoPKAqCWhTOkJ2UGLRLbS
event_namename of event selected in a rule within a campaignsignup
progressShows progress of expected actions in percentage100%
triggerIndicates if event X is triggered or nottrue - Indicates event X is received
false - Indicates event X is not received
statusstatus of intended actionactive/completed
currentcount of completed tasks currently1
targetnumber of tasks to be completed by a customer to get reward1
start_timeTimestamp when event X is triggered
actions (array) - for event YAll response data fields will remain same as event X except followings:
triggerIndicates if event Y is triggered or nottrue - Indicates event Y is received
false - Indicates event Y is not received
start_timeTimestamp when event X is triggered1708664771 (format: Unix epoch)
end_timeTimestamp when event Y is to be triggered1708837571 (format: Unix epoch)
time_durationtime taken to complete the Yth event. 172800 (format: Unix epoch)
time_leftremaining 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

EventTargetCurrentTimerProgress
signup (event X)11start_time: 1708664771
signup is completed on 21st feb
100% as user have completed the event X
order_success (event Y)1 1start_time: same as event x
end_time: 1708837571
time_duration: 172800
time_left: 172784
100% 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 CodeMessage
200Ok

Error Responses

If API call is failed, then Rehook will return the following HTTP success code with response body as given below:

HTTP CodeMessage
400bad request

error response body

field namedescriptionexample
CodeError code400
detailsError detailsCannot find customer with source id source_id
messageerror messagecoupon_code not found
request_idAPI request Id assigned by Rehookabc_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"
}
Language
Credentials
Basic
base64
:
Click Try It! to start a request and see the response here!