Create Customer
This API endpoint allows creating a new customer.
Method
POST
URL Path
/api/customers
Request Body
- The request body should include the customer's information.
Headers
appId
: The application ID.appSecret
: The application secret.
Request Body Example
{
"Metadata": {
"key": "value"
}
// other customer fields
}
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
- Create a new customer with user properties or referral code
- 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
- 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 settings, please visit Application setting
- API key and secret key are auto generated and cannot be changed.
- 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.
Authorization | Value |
---|---|
Username | API Key of your application |
Password | Secrete 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 name | Definition | example |
---|---|---|
referral_code | optional referral code assigned to the customer | KMN |
source_id | required 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 name | meta data value |
---|---|
Key 1 | value 1 |
Key 2 | value 2 |
Example:
meta data key name | meta data value |
---|---|
Name | Krishnananda |
Phone | 123456789 |
Sample request body and response
Below table shows the sample cases with request body and expected response.
Sample case | Request body should have | Response body |
---|---|---|
New customer is signed up | 1. 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 changed | 1. 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 Code | Message |
---|---|
400 | bad request |
error response body
field name | description | example |
---|---|---|
Code | Error code | 400 |
details | Error details | Given resource Id is wrong |
message | error message | Resource Id not found |
request_id | API request Id assigned by Rehook | abc_123 |
Case | Message |
---|---|
referral code already exists | message: referral code already exists |