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

Create or update customer API will enable you to do the followings

  1. Create a new customer with user properties or referral code
  2. Update existing customer user properties or referral code

Your application should consume this API whenever a new customer sign up on your application or Existing user properties have been changed.

API details

API Endpoint: https://api.rehook.ai/customers

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.
  4. Custom referral code setting to assign custom referral codes to the new users. To know more about this, plese visit Application setting

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

{
  "metadata": {
      "Name": "krishnananda",
      "Phone": "123456789",
      "location": "Bangalore",
      "Gender":"Male"
  },
  "referral_code": "KMN",
  "source_id": "KMN@2531"
}
Field nameDefinitionexample
referral_codeoptional
referral code assigned to the customer
KMN
source_idrequired
Unique customer id of your application
krishna@123

You can pass the user properties in 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
NameKrishnananda
Phone123456789

Sample request body and response

Below table shows the sample cases with request body and expected response.

Sample caseRequest body should haveResponse body
New customer is signed up1. source_id (mandatory)

2. Meta data object (optional) : pass the user properties in meta data object.

3. referral code (optional): You may pass the referral code while creating a new customer, otherwise Rehook will assign a custom referral code configured on Rehook.
Rehook will create a new user with given user properties and assign a referral code.
Existing user referral code or user property is changed1. source_id (mandatory)

2. metadata object : pass the user property name and value to be updated as key-value pair in the meta data object. (example: customer have changed the phone number from 1 to 2)

3. referral code : pass the updated referral code if any changes done at your end.
Rehook will update the customer user properties and referral code.

Case 1: New customer is signed up

{
  "metadata": {
      "Name": "krishnananda",
      "Phone": "123456789",
      "location": "Bangalore",
      "Gender":"Male"
  },
  "referral_code": "",
  "source_id": "KMN@2531"
}

response body

{
    "message": "Customer Created",
    "requestId": "374c3ba4-c0b2-9e13-9375-1ec4df5efa21"
}

case 2: Updating existing customer properties

In this case, user 'KMN@2531' phone number will updated from '123456789' to '5389559'

{
  "metadata": {
      "Name": "krishnananda",
      "Phone": "5389559",
      "location": "Bangalore",
      "Gender":"Male"
  },
  "referral_code": "",
  "source_id": "KMN@2531"
}

response body

{
    "message": "Request processed sucessfully",
    "requestId": "57e539bf-01e5-9327-aad2-a4466714fad2"
}

Error cases:

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
CaseMessage
referral code already existsmessage: referral code already exists
Language
Authorization
Basic
base64
:
Click Try It! to start a request and see the response here!