API Reference

Inserts/Pushes any system or custom events into the rehook system. This API triggers the Rule-Engine, validates all the rules (if any) associated with the event and distributes rewards accordingly.

Rehook Platform API provides resource oriented URLs to work with your business data. Our API uses JSON for request and response. API errors are returned using standard HTTP response codes.

Introduction

Trigger event API will help you to insert/pushes any system (events defined by Rehook) or custom events (events created by your application) into Rehook system. Successful API Call will trigger the rule engine and validate all the rules associated with a given event and distribute rewards to the customer accordingly.

Your application should consume this API whenever a customer performs intended action on your application.

API details

API Endpoint: https://api.rehook.ai/events/invoke

HTTP Method: POST

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 settings, please visit Application setting
  3. API key and secret key are auto generated and cannot be changed.

Authentication

You need to provide the API key and Secret of your application in every new request as Authorisation. Rehook use Basic authentication method to authenticate the API calls.

AuthorizationValue
UsernameAPI Key of your application
PasswordSecrete key of your application

Parameters

Query Parameters

This API doesn't requires any query parameters. you have to provide the details in API body only.

Body Parameters - Custom events

{
  "metadata": {
    "Payment_mode": "UPI",
    "total_amount": "250"
  },
  "event_name": "order_success",
  "source_id": "krishna@123"
}

Body Parameters - Signup event

{
  "metadata": {
    "referral_code": "KBLGPN"
  },
  "event_name": "signup",
  "source_id":"KMN@123"
}

Please refer to the below table to understand the definition of body parameters

Field nameDefinitionexample
event_namerequired
name of the event to be triggered
order_success, signup
source_idrequired
Unique customer id of your application
krishna@123
referral_coderequired
valid referral code entered by the friend. referral_code is required for only signup done through referral, you can send value for referral_code field as empty for direct signup.
KBLGPN

Meta data (optional)

You can provide the event properties in the meta data object as key value pair

meta data key namemeta data value
Key 1value 1
Key 2value 2

Example:

meta data key namemeta data value
Payment_modeUPI
total_amount250

Sample request body & response

Below table shows what details to be shared in the request body in a given case.

caserequest bodyexpected outcome
New customer is signed in using a referral code1. Source_id (mandatory)

2. event_name (mandatory) : pass conversion event for sign up

3. metadata (optional): You may pass event properties of conversion event if required.

4. referral_code to be shared in the meta data object
1. Rehook will assign the event against given source_id and run the rule engine to validate all the rules associated with a given event and distribute rewards to the customer accordingly
2. if source_id is not found, then rehook will create a new customer.
3. Rehook will add the referral count for the advocate
New customer is signed in without using a referral code1. Source_id (mandatory)

2. event_name (mandatory) : pass conversion event for sign up3.

3. metadata (optional): You may pass event properties of conversion event if required.
1. Rehook will assign the event against given source_id and run the rule engine to validate all the rules associated with a given event and distribute rewards to the customer accordingly

2. if source_id is not found, then rehook will create a new customer.
Existing customer is completing an intended action on your application1. Source_id (mandantory)

2. event_name (mandatory) : pass intended completed action as an event (example: order_placed)

3. metadata (optional): You may pass event properties of an event if required.
1. Rehook will save the event against given source_id

2. Rehook will trigger the rule engine to validate all the rules associated with a given event and distribute rewards to the customer accordingly.

Request body

case 1: Action based event

{
  "metadata": {
    "Payment_mode": "UPI",
    "total_amount": "250"
  },
  "event_name": "order_success",
  "source_id": "krishna@123"
}

case 2: Sign up event

{
  "metadata": {
    "referral_code": "KMN6457"
  },
  "event_name": "signup",
  "source_id": "krishna@123"
}

Response

{
    "message": "Request processed sucessfully",
    "requestId": "6df44043-ce67-914a-9242-2806afa05a86"
}

📘

API Behaviour

  1. Source_id is mandatory to trigger an event
  2. You can pass the event properties in meta data object as key-value pair
  3. event_name passed in the request body can be a system event or custom event as per required by your application
  4. If you're triggering an event for a new customer, we suggest you to first call our create customer API to create the source id. as a fall back mechanism, however Rehook will create customer Id if source_id passed in the request body is not found on rehook dashboard.
  5. Successful API Call will trigger the rule engine and validate all the rules associated with a given event and distribute rewards to the customer accordingly. (Example: Customer will get 50 points on order place)
  6. If user is signing up using a referral code, then please send the conversion event name and referral code in the meta data object.

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 detailsGiven resource Id is wrong
messageerror messageResource Id not found
request_idAPI request Id assigned by Rehookabc_123

Sample error cases

  1. when mandatory fields (event name or source_id) are empty in the payload.
{
    "code": 401,
    "key": "event_name",
    "message": "event_name field is required",
    "details": "event_name field is required",
    "request_id": "22df9ba9-560c-99fd-a63d-44871aeb4081"
}
{
    "code": 401,
    "key": "source_id",
    "message": "source_id field is required",
    "details": "source_id field is required",
    "request_id": "faf53ecf-c373-96ec-8b55-5f5602791f12"
}
Language
Credentials
Basic
base64
:
Click Try It! to start a request and see the response here!