NAV Navbar
cUrl NodeJS PHP Ruby JavaScript

Introduction

Footprints is the advanced AI marketing platform for behavioral profiling of physical customers, anticipating their next move and improving their customer experience.

Authentication

To authorize, use this code:

    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/token")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request["Authorization"] = 'Basic base64('{{key}}:{{secret}}')'
    request.body = "grant_type=client_credentials&pin=1234567890"
    
    response = http.request(request)
    puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/api/token", 
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "grant_type=client_credentials&pin=1234567890",
    CURLOPT_HTTPHEADER => array(
      "Authorization: Basic base64('{{key}}:{{secret}}')",
      "Content-Type: application/x-www-form-urlencoded"
    ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

curl --request POST \
--url 'http://{{base_url}}/api/token' \
--header 'Authorization: Basic base64('\''{{key}}:{{secret}}'\'')' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials&pin=1234567890
    var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "token"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": "Basic base64('{{key}}:{{secret}}')"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ grant_type: 'client_credentials', pin=1234567890 }));
    req.end();  

The above command returns JSON structured like this:

{
      "access_token": "3a53f15f7382f61564e3b16a3b81a37354c88f391263adf31be953e80b3f3",
      "token_type": "bearer",
      "expires_in": 31535999,
      "refresh_token": "903173e6a53ae2d6c238ed50ccd1db5b42cb967ce408d370b3f3257eh7e0e295",
      "scope": [
          "app_scope",
          "hostess_scope"
      ],
      "hostess_name": "Test Hostess",
      "hostess_id": "5b30cb85e1267446c5784b75" 
}

You can ask for an API key at support@footprintsforretail.com.

Headers

Content-Type application/x-www-form-urlencoded
 Authorization Basic base64('{{key}}:{{secret}}')

HTTP Request

POST {{base_url}}/api/token

Query Parameters

Parameter Description
grant_type values: client_credentials, password, pin
pin string (field used with grant_type = "pin")
username string (field used with grant_type = "password")
password string (field used with grant_type = "password")

Leads

Add Lead

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/lead?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000"
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/lead?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request POST \
    --url 'http://{{base_url}}/api/lead?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory",
        "{{offerCategoryId}}",
        "lead"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ userFirstName: 'Test',
      userLastName: 'Test',
      userEmail: 'test@test.com',
      userPhone: '0700000000' }));
    req.end();

The above command returns JSON structured like this:

 {
      "_id": "6h7adfb9f58363518b370051"
 }

Add new lead method

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/lead

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
offlineCampaignIdoffline campaign id
offerCategoryIdoffer category id
offerIdoffer id
locationIdlocation id
consultantIdconsultant id
channelIdchannel id (please check List Channels method)
userFirstNameuser's first name
userLastNameuser's last name
userEmailuser's email address
userPhoneuser's phone
npsmin:0 max:10 - net promoter score - user's rating
userSexpossible values: male, female
userCityuser's city
userCountyuser's county
userCountryuser's country
userAddressuser's address
userFamilyDetalispossible values: "single","married"
userChildrenuser's number of children
userIndustryuser's industry
userCompanyNameuser's company
userCompanyAddressuser's company address
userJobuser's job
userJobDescriptionuser's job description
userIncomeuser's income
userBirthdayuser's birthday, accepted format Y-m-d
userExternalIduser's id from the primary database
userDistrictuser's district
facebookUrlFacebook user profile
imageUrluser profile picture
tagsarray de strings ['tagName1', 'tagName2']
createdAtdate, accepted format Y-m-d H:i:s
timezonethe IANA time zone identifier, eg. America/Los_Angeles
marketingChannelsarray containing objects like channel ('sms', 'email', 'notification', 'dm', 'socialMedia'), type ('owner', 'group', 'partners'), agreed ("true", "false")
customDetailsoptional object; ex: customDetails[offerDetails] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit' or customDetails[vouchers] = ['shopId'=>1,'shopName'=>'sn', 'amount'=>22, 'currency'=>'RON']
userCommentsstring containing user comments
hasKidspossible values: "true", "false"
noOfKidsnumber of kids
agreeTandcTerms & Conditions Agreement, possible values: "true", "false"
agreePrivacyPrivacy Policy Agreement, possible values: "true", "false"
agreedTargetedMessagesPersonalized Messages Agreement possible values: "true", "false"
isAdultpossible values: "true", "false"
[customVariableName]The names for the custom variables need to be declared first in "Settings > Custom Variables" otherwise they'll be ignored

Update Lead

Use the access token obtained from authentication method:


      require "uri"
      require "net/http"
      
      url = URI("{{base_url}}/api/lead/5ce3b4089d5de975003244d2?access_token={{access_token}}")
      
      http = Net::HTTP.new(url.host, url.port)
      
      request = Net::HTTP::Put.new(url)
      request["Content-Type"] = "application/x-www-form-urlencoded"
      request.body = "status=sale_lead"
      
      response = http.request(request)
      puts response.read_body

  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => "{{base_url}}/api/lead/5ce3b4089d5de975003244d2?access_token={{access_token}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_POSTFIELDS => "status=sale_lead",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  } 
   curl --location --request PUT "{{base_url}}/api/lead/5ce3b4089d5de975003244d2?access_token={{access_token}}" \
  --header "Content-Type: application/x-www-form-urlencoded" \
  --data "status=sale_lead"
   var https = require('https');

  var qs = require('querystring');
  
  var options = {
    'method': 'PUT',
    'hostname': '{{base_url}}',
    'path': '/api/lead/5ce3b4089d5de975003244d2?access_token={{access_token}}',
    'headers': {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  };
  
  var req = https.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function (chunk) {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  
    res.on("error", function (error) {
      console.error(error);
    });
  });
  
  var postData = qs.stringify({
    'status': 'sale_lead'
  });
  
  req.write(postData);
  
  req.end();

The above command returns JSON structured like this:

 {
  "_id": "5ebe9558aea45e10fc094c8b",
  "timestamp": "2020-03-15 16:12:56",
  "createdAt": "2020-03-15 16:12:56",
  "status": "customer",
  "userFirstName": "First Name",
  "userLastName": "Last Name",
  "userPhone": "0700000118",
  "userEmail": "test5557@test.com",
  "locationId": "5cf92039bc79te5cf99e3540",
  "offerCategoryId": "6cf92a83bc790a5cf99e35cd",
  "offerId": "5cf92a83bc790a5cf99e35cf",
  "updatedAt": "2020-03-15 16:12:56",
  "consultantId": "59f8530f0et24a7c9247cuew7",
  "assignedBefore": 1,
  "skuId": "5e6b7be8576e5213f065b23c",
  "contractId": "5ebe97b8d6772218b0a76785",
  "skuExternalId": "123456"
}

Update lead method

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

PUT {{base_url}}/api/lead/{{leadId}}

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userCompanyNameuser's company
userCompanyAddressuser's company address
statuslead status; accepted values: prospect, lead, sale_lead, opportunity, customer, lost
offerCategoryIdnew catalog id assigned (please check List Categories method)
offerIdnew offer id assigned (please check List offers method)
skuIdnew sku id assigned (please check List SKUs method)
channelIdnew channel id assigned (please check List Channels method)
skuExternalIdexternal sku code (not mandatory)
contractNumbercontract number number (only with status customer)
contractValuecontract value (only with status customer)
contractDatecontract date (only with status customer)
contractDescriptioncontract description (only with status customer)
tagsarray de strings ['tagName1', 'tagName2']

Get Leads

Use the access token obtained from authentication method:


        require "uri"
        require "net/http"
        
        url = URI("{{base_url}}/api/lead?access_token={{access_token}}&startDate=2018-11-25&endDate=2018-12-31&pageSize=10&page=1")
        
        http = Net::HTTP.new(url.host, url.port)
        
        request = Net::HTTP::Get.new(url)
        request["Content-Type"] = "application/x-www-form-urlencoded"
        
        response = http.request(request)
        puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "{{base_url}}/api/lead?access_token={{access_token}}&startDate=2018-11-25&endDate=2018-12-31&pageSize=10&page=1",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => false,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --location --request GET "{{base_url}}/api/lead?access_token={{access_token}}&startDate=2018-11-25&endDate=2018-12-31&pageSize=10&page=1" \
    --header "Content-Type: application/x-www-form-urlencoded" \
    --data ""
   var https = require('https');

    var qs = require('querystring');
    
    var options = {
      'method': 'GET',
      'hostname': '{{base_url}}',
      'path': '/api/lead?access_token={{access_token}}&startDate=2018-11-25&endDate=2018-12-31&pageSize=10&page=1',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    
    var req = https.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function (chunk) {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    
      res.on("error", function (error) {
        console.error(error);
      });
    });
    
    var postData = qs.stringify({
    
    });
    
    req.write(postData);
    
    req.end();

The above command returns JSON structured like this:

 [{
    "_id": "5ce3b4089d5de975003244d2",
    "userFirstName": "Kibo",
    "userLastName": "English",
    "userEmail": "Duis.dignissim@vulputate.org",
    "userPhone": "0700000000",
    "offerId": "5aa2082c75d87fbce2e76ada",
    "industryId": "5b8561bd0bb67c30c35df800",
    "offlineCampaignId": "5af77643f09b7f2c2fa3007e",
    "locationId": "86f838e268a157484ba1d658",
    "clientId": "5cs37a5083e3aa47a4a6a03e",
    "status": "sale_lead",
    "userCountry": "Romania",
    "userFamilyDetails": "relationship",
    "userBirthday": "Fri Oct 21 1960 00:00:00 GMT+0000 (UTC)",
    "userIncome": "8004",
    "agreeToCollect": true,
    "agreeTandc": true,
    "isAdult": true,
    "isMultipart": false,
    "isComplete": true,
    "timestamp": "2018-09-24T19:00:00.000Z",
    "timestampStatusChange": "2018-09-24T19:00:00.000Z",
    "createdAt": "2018-09-24T19:00:00.000Z",
    "actionRequired": true,
    "deviceType": "desktop",
    "skuExternalId": "12345",
    "offerCategoryId": "5cf92a83bc790a5cf99e35cd",
    "offerCategory": "Footprints AI",
    "offer": {
      "_id": "5cf92a83bc710a5cf22e35cf",
      "name": "OFFER NAME",
      "price": 800
    },
    "sku": {
        "_id": "5e6b7be8576e5213f065b23c",
        "name": "SKU NAME",
        "price": 400
    },
    "updatedAt": "2019-07-18T12:47:35.847Z",
    "channelId": "2f3e2b658720346d675b441c",
    "consultant": {
      "_id": "51f853626e3f13wc9247c623",
      "name": "Test Test"
    }
}]

Get leads method (will return only the leads with locationId, offerCategoryId, offerId and consultantId asociated)

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/lead

Query Parameters

Parameter Description
access_token access token
startDate start date, accepted format Y-m-d
endDate start date, accepted format Y-m-d
pageSize items per page
page current page
appKey application key

Add Lead Action

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/lead/action?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "leadId=5b73fhfc4f58363318b824431&leadActionTypeId=6d22kaal8378716180494f54&actionDetail=description&date=2021-01-12 06:42:55"
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/lead/action?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "leadId=5b73fhfc4f58363318b824431&leadActionTypeId=6d22kaal8378716180494f54&actionDetail=description&date=2021-01-12 06:42:55",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request POST \
    --url 'http://{{base_url}}/api/lead/action?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'leadId=5b73fhfc4f58363318b824431&leadActionTypeId=6d22kaal8378716180494f54&actionDetail=description&date=2021-01-12 06:42:55'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "lead",
        "action"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ leadId: '5b73fhfc4f58363318b824431',
      leadActionTypeId: '6d22kaal8378716180494f54',
      actionDetail: 'description',
      date: '2021-01-12 06:42:55' }));
    req.end();

The above command returns JSON structured like this:

 {
      "status": "success",
      "_id": "6h7adfb9f58363518b370051"
 }

Add new lead action method

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/lead/action

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
leadIdlead id
leadActionTypeIdaction type id (please check Get Lead Action Types method)
actionDetaildescription
datedate, accepted format Y-m-d H:i:s

Update Lead Action

Use the access token obtained from authentication method:


            require 'uri'
            require 'net/http'
            
            url = URI("https://{{base_url}}/api/lead/action/{{actionId}}?access_token={{access_token}}")
            
            http = Net::HTTP.new(url.host, url.port)
            
            request = Net::HTTP::Put.new(url)
            request["Content-Type"] = 'application/x-www-form-urlencoded'
            request.body = "leadId=5b73fhfc4f58363318b824431&leadActionTypeId=6d22kaal8378716180494f54&actionDetail=description&date=2021-01-12 06:42:55"
            
            response = http.request(request)
            puts response.read_body
        

            $curl = curl_init();
        
            curl_setopt_array($curl, array(
              CURLOPT_URL => "http://{{base_url}}/api/lead/action/{{actionId}}?access_token={{access_token}}",
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_ENCODING => "",
              CURLOPT_MAXREDIRS => 10,
              CURLOPT_TIMEOUT => 30,
              CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
              CURLOPT_CUSTOMREQUEST => "PUT",
              CURLOPT_POSTFIELDS => "leadId=5b73fhfc4f58363318b824431&leadActionTypeId=6d22kaal8378716180494f54&actionDetail=description&date=2021-01-12 06:42:55",
              CURLOPT_HTTPHEADER => array(
                "Content-Type: application/x-www-form-urlencoded"
              ),
            ));
            
            $response = curl_exec($curl);
            $err = curl_error($curl);
            
            curl_close($curl);
            
            if ($err) {
              echo "cURL Error #:" . $err;
            } else {
              echo $response;
            }
        
   curl --request PUT \
            --url 'http://{{base_url}}/api/lead/action/{{actionId}}?access_token={{access_token}}' \
            --header 'Content-Type: application/x-www-form-urlencoded' \
            --data 'leadId=5b73fhfc4f58363318b824431&leadActionTypeId=6d22kaal8378716180494f54&actionDetail=description&date=2021-01-12 06:42:55'
        
   var qs = require("querystring");
            var http = require("http");
            
            var options = {
              "method": "PUT",
              "hostname": [
                "{{base_url}}"
              ],
              "path": [
                "api",
                "lead",
                "action",
                {{actionId}}
              ],
              "headers": {
                "Content-Type": "application/x-www-form-urlencoded"
              }
            };
            
            var req = http.request(options, function (res) {
              var chunks = [];
            
              res.on("data", function (chunk) {
                chunks.push(chunk);
              });
            
              res.on("end", function () {
                var body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });
            
            req.write(qs.stringify({ leadId: '5b73fhfc4f58363318b824431',
              leadActionTypeId: '6d22kaal8378716180494f54',
              actionDetail: 'description',
              date: '2021-01-12 06:42:55' }));
            req.end();
        

The above command returns JSON structured like this:

 {
              "status": "success",
              "_id": "6h7adfb9f58363518b370051"
         }
        

Updates lead action method

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

PUT {{base_url}}/api/lead/action/{{actionId}}

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
leadIdlead id
leadActionTypeIdaction type id (please check Get Lead Action Types method)
actionDetaildescription
datedate, accepted format Y-m-d H:i:s

Get Lead Actions

Use the access token obtained from authentication method:


        require "uri"
        require "net/http"
        
        url = URI("{{base_url}}/api/lead/actions/{{leadId}}?access_token={{access_token}}")
        
        http = Net::HTTP.new(url.host, url.port)
        
        request = Net::HTTP::Get.new(url)
        request["Content-Type"] = "application/x-www-form-urlencoded"
        
        response = http.request(request)
        puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "{{base_url}}/api/lead/actions/{{leadId}}?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => false,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --location --request GET "{{base_url}}/api/lead/actions/{{leadId}}?access_token={{access_token}}" \
    --header "Content-Type: application/x-www-form-urlencoded" \
    --data ""
   var https = require('https');

    var qs = require('querystring');
    
    var options = {
      'method': 'GET',
      'hostname': '{{base_url}}',
      'path': '/api/lead/actions/{{leadId}}?access_token={{access_token}}',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    
    var req = https.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function (chunk) {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    
      res.on("error", function (error) {
        console.error(error);
      });
    });
    
    var postData = qs.stringify({
    
    });
    
    req.write(postData);
    
    req.end();

The above command returns JSON structured like this:

 [
  data: [{
    "_id": "5ce3b4089d5de975003244d2",
    "leadId": "6ee3b4089d5de9750035561",
    "actionDetail": "My description",
    "leadActionTypeId": {
      "_id": "6d23b4089d5de672354dd7878",
      "name": "Test Test"
    },
    "attachments": [],
    "date": "2017-07-18T12:47:35.847Z",
    "createdAt": "2019-07-18T12:47:35.847Z",
    "updatedAt": "2020-08-19T12:57:35.847Z"    
}]

Get all actions associated to a specific lead

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/lead/actions/{{leadId}}

Query Parameters

Parameter Description
access_token access token

Get Lead Action Types

Use the access token obtained from authentication method:


        require "uri"
        require "net/http"
        
        url = URI("{{base_url}}/api/lead/action-types?access_token={{access_token}}")
        
        http = Net::HTTP.new(url.host, url.port)
        
        request = Net::HTTP::Get.new(url)
        request["Content-Type"] = "application/x-www-form-urlencoded"
        
        response = http.request(request)
        puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "{{base_url}}/api/lead/action-types?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => false,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --location --request GET "{{base_url}}/api/lead/actions/{{leadId}}?access_token={{access_token}}" \
    --header "Content-Type: application/x-www-form-urlencoded" \
    --data ""
   var https = require('https');

    var qs = require('querystring');
    
    var options = {
      'method': 'GET',
      'hostname': '{{base_url}}',
      'path': '/api/lead/action-types?access_token={{access_token}}',
      'headers': {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    };
    
    var req = https.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function (chunk) {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    
      res.on("error", function (error) {
        console.error(error);
      });
    });
    
    var postData = qs.stringify({
    
    });
    
    req.write(postData);
    
    req.end();

The above command returns JSON structured like this:

 [
  data: [{
    "_id": "5ce3b4089d5de975003244d2",
    "name": "Type 1",
    "createdAt": "2019-07-18T12:47:35.847Z"  
}]

Get all lead action types declared inside the project

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/lead/action-types

Query Parameters

Parameter Description
access_token access token

Upload Lead Documents

Use the access token obtained from authentication method:


            require "uri"
            require "net/http"
            
            url = URI("{{base_url}}/api/lead/5fbc335fc3972a78dc85d7a0/contracts?access_token={{access_token}}")
            
            http = Net::HTTP.new(url.host, url.port);
            request = Net::HTTP::Put.new(url)
            request["Content-Type"] = "multipart/form-data"
            form_data = [['documents', File.open('C:/MyComputer/Documents/filename1.pdf')],['documents', File.open('C:/MyComputer/Documents/filename2.pdf')]]
            request.set_form form_data, 'multipart/form-data'
            response = http.request(request)
            puts response.read_body
        

            $curl = curl_init();

            curl_setopt_array($curl, array(
              CURLOPT_URL => '{{base_url}}/api/lead/5fbc335fc3972a78dc85d7a0/contracts?access_token={{access_token}}',
              CURLOPT_RETURNTRANSFER => true,
              CURLOPT_ENCODING => '',
              CURLOPT_MAXREDIRS => 10,
              CURLOPT_TIMEOUT => 0,
              CURLOPT_FOLLOWLOCATION => true,
              CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
              CURLOPT_CUSTOMREQUEST => 'PUT',
              CURLOPT_POSTFIELDS => array('documents'=> new CURLFILE('C:/MyComputer/Documents/filename1.pdf'),'documents'=> new CURLFILE('C:/MyComputer/Documents/filename2.pdf')),
              CURLOPT_HTTPHEADER => array(
                'Content-Type: multipart/form-data'
              ),
            ));
            
            $response = curl_exec($curl);
            $err = curl_error($curl);
            
            curl_close($curl);
            
            if ($err) {
              echo "cURL Error #:" . $err;
            } else {
              echo $response;
            }
        
   
          curl --location --request PUT '{{base_url}}/api/lead/5fbc335fc3972a78dc85d7a0/contracts?access_token={{access_token}}' \
          --header 'Content-Type: multipart/form-data' \
          --form 'documents=@"/C:/MyComputer/Documents/filename1.pdf"' \
          --form 'documents=@"/C:/MyComputer/Documents/filename2.pdf"'
        
   var request = require('request');
          var fs = require('fs');
          var options = {
            'method': 'PUT',
            'url': '{{base_url}}/api/lead/5fbc335fc3972a78dc85d7a0/contracts?access_token=b24d050799760977e3884cbbb8d404dfeff778a2bf672b66fd3198998696d0356d9a006a4735a6aae85920b6b6c0bf98801c1dd1a34605cda96c9ce52d50526e',
            'headers': {
              'Content-Type': 'multipart/form-data'
            },
            formData: {
              'documents': {
                'value': fs.createReadStream('/C:/MyComputer/Documents/filename1.pdf'),
                'options': {
                  'filename': '/C:/MyComputer/Documents/filename1.pdf',
                  'contentType': null
                }
              },
              'documents': {
                'value': fs.createReadStream('/C:/MyComputer/Documents/filename2.pdf'),
                'options': {
                  'filename': '/C:/MyComputer/Documents/filename2.pdf',
                  'contentType': null
                }
              }
            }
          };
          request(options, function (error, response) {
            if (error) throw new Error(error);
            console.log(response.body);
          });
        

The above command returns JSON structured like this:

 {
          "status": "ok",
          "uploaded_files": [
              "filename1.pdf",
              "filename2.pdf"
          ]
        }
        

Upload lead documents method. The file data should be attached using standard multipart/form-data. Allowed documentType values are: "contracts","offers","consents" Allowed mimetype: "application/pdf"

Headers

Content-Type multipart/form-data

HTTP Request

PUT {{base_url}}/api/lead/{{leadId}}/{{documentType}}

Query Parameters

Parameter Description
access_token access token

Body formdata

Parameter Description
documentsone or multiple files can be added (max 5 files per upload)
leadActionIdoptional field for associating the document(s) to a lead action

Add prospect

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/prospect?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "avandorUserId=&avandorSession=&userFirstName=Mihai&userLastName=Popescu&userEmail=mihai@popescu.com&userPhone=%2B075364628484&userCountry="
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/prospect?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "avandorUserId=&avandorSession=&userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000&userCountry=",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request POST \
    --url 'http://{{base_url}}/api/prospect?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'avandorUserId=&avandorSession=userFirstName=Test&userLastName=Test&userEmail=test@test.com&userPhone=0700000000&userCountry='
   var qs = require("querystring");
    var http = require("http");
    
    var options = { 
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "prospect"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ avandorUserId: '',
      avandorSession: '',
      userFirstName: 'Test',
      userLastName: 'Test',
      userEmail: 'test@test.com',
      userPhone: '0700000000',
      userCountry: '' }));
    req.end();

The above command returns JSON structured like this:

 {
      "_id": "6e7adfb9f56363518f370151"
 }

Add new prospect method

HTTP Request

POST {{base_url}}/api/prospect

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
avandorUserIdavandor user id
avandorSessionavandor session (can be sent as a JSON object using an application/json request type)
userFirstNameuser's first name
userLastNameuser's last name
companyNameuser's company name
companyTypeuser's company type
userCountryuser's country
userAddressuser's address
userPositionuser's position
userPhoneuser's phone
userEmailuser's email address
companyWebsiteuser's company website
potentialScoreuser's potential score

Update NPS

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/lead/{{lead_id}}/nps?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Put.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "nps=10&comment%20=test"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/lead/{{lead_id}}/nps?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_POSTFIELDS => "nps=10&comment=test",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request PUT \
    --url 'http://{{base_url}}/api/lead/{{lead_id}}/nps?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'nps=10&comment%20=test'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "PUT",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "lead",
        "{{lead_id}}",
        "nps"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ nps: '10', 'comment ': 'test' }));
    req.end();

The above command returns JSON structured like this:


{
  "status": "success"
}

Updates the NPS data for a lead.

HTTP Request

POST {{base_url}}/api/lead/{{lead_id}}/nps

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
nps number min:1, max: 10
comment string

Add/Update Lead Custom Variable

Use the access token obtained from authentication method:


  require 'uri'
  require 'net/http'

  url = URI("#{base_url}/api/lead/#{lead_id}/custom-variable/save?access_token=#{access_token}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Put.new(url)
    request["Content-Type"] = 'multipart/form-data'
    
    # Building the form data
    form_data = [
      ['customVariable 1', 'example'],
      ['customVariable 2', 'example']
    ]

    # Adding the form data to the request
    request.set_form(form_data, 'multipart/form-data')

    response = http.request(request)
    puts response.read_body
   

  $url = "http://{{base_url}}/api/lead/$leadId/custom-variable/save?access_token={{access_token}}"; 
  
  $fields = [
      'customVariable 1' => 'example',
      'customVariable 2' => 'example',
  ];
  
  $curl = curl_init();
  
  curl_setopt_array($curl, [
      CURLOPT_URL => $url,
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_POSTFIELDS => $fields,
      CURLOPT_HTTPHEADER => [
          "Content-Type: multipart/form-data",
      ],
  ]);
  
  $response = curl_exec($curl);
  
  if (curl_errno($curl)) {
      echo "Error: " . curl_error($curl);
  } else {
      echo $response;
  }
  
  curl_close($curl);  
   
  curl --location --request PUT 'http://{{base_url}}/api/lead/{lead_id}/custom-variable/save?access_token={{access_token}}' \
  --form 'customVariable 1="example"' \
  --form 'customVariable 2="example"'
  
   
  const http = require('http');
  const FormData = require('form-data');
  
  const formData = new FormData();
  formData.append('customVariable 1', 'example');
  formData.append('customVariable 2', 'example');
  
  const options = {
    method: 'PUT',
    "method": "PUT",
    "hostname": [
      "{{base_url}}"
    ],
    "path": [
      "api",
      "lead",
      "{{lead_id}}",
      "custom-variable/save"
    ],
    headers: formData.getHeaders(),
  };
  
  const req = http.request(options, (res) => {
    let chunks = [];
  
    res.on('data', (chunk) => {
      chunks.push(chunk);
    });
  
    res.on('end', () => {
      const body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  });
  
  formData.pipe(req);
  
  req.on('error', (error) => {
    console.error(`Error: ${error.message}`);
  });
  
  req.end();  

The above command returns JSON structured like this:


{
  "status": "Custom Variable details are successfully updated with leadId"
}

The Upload Lead Documents method requires the file data to be attached using standard multipart/form-data format for storing Custom Variable data associated with a lead.

HTTP Request

POST {{base_url}}/api/lead/{{lead_id}}/custom-variable/save

Query Parameters

Parameter Description
access_token access token

Example Body

Parameter Description Value Type
comment string This is a sample comment. text
fileVariable file data /Upload/sample.pdf file

Note: The above parameters are dynamic variables, that are created in the custom variable section

Update Lost Lead

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/lead/{{lead_id}}/leadLost?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Put.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "reasonLost=price_too_high&comment%20=test"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/lead/{{lead_id}}/leadLost?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_POSTFIELDS => "reasonLost=price_too_high&comment%20=test",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request PUT \
    --url 'http://{{base_url}}/api/lead/{{lead_id}}/leadLost?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'reasonLost=price_too_high&comment%20=test'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "PUT",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "lead",
        "{{lead_id}}",
        "leadLost"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ reasonLost: 'price_too_high', 'comment ': 'test' }));
    req.end();

The above command returns JSON structured like this:


  {
    "_id": "5ebe9558aea45e10fc094c8b",
    "comments": "62b094763720b627e83324ef",
    "timestamp": "2020-03-15 16:12:56",
    "createdAt": "2020-03-15 16:12:56",
    "status": "lead",
    "userFirstName": "First Name",
    "userLastName": "Last Name",
    "userPhone": "0700000118",
    "userEmail": "test5557@test.com",
    "locationId": "5cf92039bc79te5cf99e3540",
    "offerId": "5cf92a83bc790a5cf99e35cf",
    "updatedAt": "2020-03-15 16:12:56",
    "consultantId": "59f8530f0et24a7c9247cuew7",
    "assignedBefore": 1,
    "skuId": "5e6b7be8576e5213f065b23c",
    "contractId": "5ebe97b8d6772218b0a76785",
    "skuExternalId": "12345"
  }

Updates the lost lead.

HTTP Request

PUT {{base_url}}/api/lead/{{lead_id}}/leadLost

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
reasonLost Reason for update Lost accepted values: poor_qualification,need,wrong_time,price_too_high,lost_momentum,competition,abandoned,feature,other
comment Comments

Customers

Get customers

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://20.50.22.58/auchan/unknown/probgenderpredictions/api/v1/all")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/client?access_token={{access_token}}&userEmail=test@test.ro&userPhone=0700000000",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/client?access_token={{access_token}}&userEmail=test@test.ro&userPhone=0700000000' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "client"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:

 {
      "_id": "5e7adfb9f583635122272a45",
      "userFirstName": "Test",
      "userLastName": "Test",
      "userEmail": "test@test.com",
      "userPhone": "0700000000",
      "timestamp": "2018-08-20T15:35:22.024Z",
      "createdAt": "2018-08-20T15:35:21.962Z",
      "type": "B2C",
      "__v": 2,
      "kidsAge": [],
      "interests": [],
      "preferences": [],
      "employees": [],
      "marketingChannels": [],
      "pointsOfPresence": [],
      "interactionsTimeline": [
          {
              "createdAt": "2018-08-20T15:35:22.024Z",
              "timestamp": "2018-08-20T15:35:22.024Z",
              "icon": "icon-location-city",
              "offlineCampaignId": null,
              "offerCategoryId": {
                  "applicationKeys": [],
                  "consultants": [],
                  "locations": [
                      "59f8385a65157484ba1d11d",
                      "55f838e128a157484ba1d230"
                  ],
                  "offers": [
                      {
                          "_id": "5a05eafff1fa75415cc21f7d",
                          "name": "Contests and prizes",
                          "description": "",
                          "price": "",
                          "offerCategoryId": "5a053cc5b425fe79a0a51254",
                          "userId": "59f855060e3f1a7c9247c4b1",
                          "timestamp": "2017-11-08T11:31:11.633Z",
                          "createdAt": "2017-11-08T11:31:11.633Z",
                          "__v": "0"
                      }
                  ],
                  "__v": 2,
                  "createdAt": "2017-11-06T10:43:17.124Z",
                  "timestamp": "2017-11-08T11:32:32.304Z",
                  "description": "",
                  "name": "Offline campaigns",
                  "_id": "5a103cc5b425fe79a0a41253"
              },
              "leadId": "5b7adfb9f58383518b332a46"
          }
      ],
      "personalAssistance": [],
      "leads": [
          {
              "history": [
                  {
                      "__v": 0,
                      "leadId": "5b7adfb9f58383518b332a46",
                      "userFirstName": "Test",
                      "userLastName": "Test",
                      "userEmail": "test@test.com",
                      "userPhone": "0700000000",
                      "offerCategoryId": "5a003cc5b425fe79a0a41254",
                      "status": "lead",
                      "applicationKey": "072f34176f42a855da5ff3b1",
                      "isMultipart": false,
                      "isComplete": true,
                      "timestamp": "2018-08-20T15:35:22.012Z",
                      "createdAt": "2018-08-20T15:35:22.012Z",
                      "_id": "5b7adfbaf58363518b372a47"
                  }
              ],
              "interactions": [],
              "comments": [],
              "kidsAge": [],
              "__v": 1,
              "type": "B2C",
              "actionRequired": true,
              "createdAt": "2018-08-20T15:35:21.973Z",
              "timestampStatusChange": "2018-08-20T15:35:21.973Z",
              "timestamp": "2018-08-20T15:35:21.973Z",
              "isComplete": true,
              "isMultipart": false,
              "offerCategory": {
                  "consultants": [],
                  "id": "5a003aa5b425aa79a0a41254"
              },
              "application": {
                  "name": "CRM Application",
                  "id": "67a6ff12cf74a7140931626c"
              },
              "applicationKey": "071f34176f42a143da5ff3b1",
              "status": "lead",
              "clientId": "5b7vvfb9f58363518b37r345",
              "offerCategoryId": "5a113cc5b425fe79a0a41254",
              "userPhone": "0700000000",
              "userEmail": "test@test.com",
              "userLastName": "Test",
              "userFirstName": "Test",
              "_id": "5b7adfb9f58363518b372a43",
              "channelId": "5a3e2bac8720349d675c97c9"
          }
      ]
  }

Get a profile based on customer's email and phone (mandatory fields) or customer's NationalId number

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/client

Query Parameters

Parameter Description
access_tokenaccess token
userEmailuser's email address
userPhoneuser's phone

Update customer

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/client?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Put.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userFirstName=Test&userLastName=Test&userEmail=test@test.ro&userPhone=0700000000"
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/client?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "PUT",
      CURLOPT_POSTFIELDS => "userFirstName=Test&userLastName=Test&userEmail=test@test.ro&userPhone=0700000000",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request PUT \
    --url 'http://{{base_url}}/api/client?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'userFirstName=Test&userLastName=Test&userEmail=test@test.ro&userPhone=0700000000'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "PUT",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "client"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ userFirstName: 'Test',
      userLastName: 'Test',
      userEmail: 'test@test.ro',
      userPhone: '0700000000' }));
    req.end();

The above command returns JSON structured like this:

 {
    "status": "success"
 }

Update customer's data

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

PUT {{base_url}} /api/client

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userFirstNameuser's first name
userLastNameuser's last name
nationalIduser's national Id
userEmailuser's email address
userPhoneuser's phone
userSexpossible values: male, female
userCityuser's city
userCountyuser's county
userCountryuser's country
userAddressuser's address
userFamilyDetalispossible values: "single","married"
userChildrenuser's number of children
userIndustryuser's industry
userCompanyNameuser's company
userCompanyAddressuser's company address
userJobuser's job
userJobDescriptionuser's job description
userBirthdayuser's birthday, accepted format Y-m-d
userExternalIduser's id from the primary database
facebookUrlFacebook user profile
imageUrluser profile picture
marketingChannelsarray containing objects like
channel ('sms', 'email', 'notification', 'dm', 'socialMedia'),
type ('owner', 'group', 'partners'),
agreed ("true", "false")
interestsarray de strings ['books', 'cars']
preferencesarray de strings ['books', 'cars']
customDetails
hasKidspossible values: "true", "false"
noOfKidsnumber of kids
kidsAgearray of numbers - Ex: [6, 14]
agreeTandcTerms & Conditions Agreement, possible values: "true", "false"
agreePrivacyPrivacy Policy Agreement, possible values: "true", "false"
agreedTargetedMessagesPersonalized Messages Agreement possible values: "true", "false"
isAdultpossible values: "true", "false"

Delete customer

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/client?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Delete.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userExternalId=2446456"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/client?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "DELETE",
      CURLOPT_POSTFIELDS => "userExternalId=2446456",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request DELETE \
    --url 'http://{{base_url}}/api/client?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data userExternalId=2446456
    var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "DELETE",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "client"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ userExternalId: '2446456' }));
    req.end();

The above command returns JSON structured like this:

  {
    "status": "success"
  }

Delete customer's data

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

DELETE {{base_url}}/api/client

Query Parameters

Parameter Description
access_token access token

Recommendation Engine

Home Page Recommendation

Use the access token obtained from authentication method:


  require "uri"
  require "net/http"
  
  url = URI("{{baseURL}}/api/recommendations/home?access_token={access_token}&limit=3&clientId=64704bc8d0afa15c5c459cbc&userExternalId=1781720938019283091283091280391")
  
  http = Net::HTTP.new(url.host, url.port);
  request = Net::HTTP::Get.new(url)
  
  response = http.request(request)
  puts response.read_body
  
 
  $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => '{{baseURL}}/api/recommendations/home?access_token={access_token}&limit=3&clientId=64704bc8d0afa15c5c459cbc&userExternalId=1781720938019283091283091280391',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
  ));
  
  $response = curl_exec($curl);
  
  curl_close($curl);
  echo $response;
  

 curl --location '{{baseURL}}/api/recommendations/home?access_token={access_token}&limit=3&clientId=64704bc8d0afa15c5c459cbc&userExternalId=1781720938019283091283091280391'

  var requestOptions = {
    method: 'GET',
    redirect: 'follow'
  };
  
  fetch("{{baseURL}}/api/recommendations/home?access_token={access_token}&limit=3&clientId=64704bc8d0afa15c5c459cbc&userExternalId=1781720938019283091283091280391", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

The above command returns JSON structured like this:

 
  {
    "status": "success",
    "data": {
        "clientId": "64704bc8d0afa15c5c459cbc",
        "userExternalId": "d650988e68ac760feeef40a67c5.....",
        "recommendations": [
            {
                "externalId": "68261",
                "name": "Ciocolata cu arahide Africana, 90 g",
                "score": "45%",
                "productId": "646b39bd7c9ad562cba09424"
            },
            {
                "externalId": "860529",
                "name": "Croissant cu crema cu cacao si pasta de alune de padure Auchan, 85 g",
                "score": "45%",
                "productId": "646b3d6e7c9ad562cba360e7"
            },
            {
                "externalId": "169605",
                "name": "Pui intreg cu cartofi wedges, 1.6 kg, 2 portii",
                "score": "43%",
                "productId": "646b3a047c9ad562cba110f4"
            }
        ]
    }
}

Retrieve a list of recommended items for a specific user in a given category

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET api/recommendations/home

Query Parameters

Parameter Type Required Description
clientId string No The unique identifier of the client or user.
userExternalId string No The unique identifier of the user (alternative to clientId).
limit number No The maximum number of recommended products to return.
access_token string Yes Retrieved from the Access Token API with the credentials of Admin or Marketing Manager.

Personalized Emails Recommendation

Use the access token obtained from authentication method:


  require "uri"
  require "net/http"
  
  url = URI("{{baseURL}}/api/recommendations/email?limit=10&clientId=64704bc8d0afa15c5c459cbc&category=Bacanie&userExternalId=12738172938102938120983091283012983&access_token={access_token}")
  
  http = Net::HTTP.new(url.host, url.port);
  request = Net::HTTP::Get.new(url)
  
  response = http.request(request)
  puts response.read_body
  
  

  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => '{{baseURL}}/api/recommendations/email?limit=10&clientId=64704bc8d0afa15c5c459cbc&category=Bacanie&userExternalId=12738172938102938120983091283012983&access_token={access_token}',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
  ));
  
  $response = curl_exec($curl);
  
  curl_close($curl);
  echo $response;
  

  curl --location --globoff '{{baseURL}}/api/recommendations/email?limit=10&clientId=64704bc8d0afa15c5c459cbc&category=Bacanie&userExternalId=12738172938102938120983091283012983&access_token={access_token}'

  var requestOptions = {
    method: 'GET',
    redirect: 'follow'
  };
  
  fetch("{{baseURL}}/api/recommendations/email?limit=10&clientId=64704bc8d0afa15c5c459cbc&category=Bacanie&userExternalId=12738172938102938120983091283012983&access_token={access_token}", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

The above command returns JSON structured like this:

[
  {
    "status": "success",
    "data": {
        "clientId": "64704bc8d0afa15c5c459cbc",
        "userExternalId": "d650988e68ac760feeef40a67c5.....",
        "recommendations": [
            {
                "externalId": "68261",
                "name": "Ciocolata cu arahide Africana, 90 g",
                "score": "45%",
                "productId": "646b39bd7c9ad562cba09424"
            },
            {
                "externalId": "860529",
                "name": "Croissant cu crema cu cacao si pasta de alune de padure Auchan, 85 g",
                "score": "45%",
                "productId": "646b3d6e7c9ad562cba360e7"
            },
            {
                "externalId": "169605",
                "name": "Pui intreg cu cartofi wedges, 1.6 kg, 2 portii",
                "score": "43%",
                "productId": "646b3a047c9ad562cba110f4"
            }
        ]
    }
}

Retrieves personalized product recommendations for personalized emails. The recommendations can be filtered by category, and the maximum number of recommendations to include in the email can be specified.

Note: When making requests to the API, you need to provide either the clientId or the userExternalId as a required parameter. The clientId is an auto-generated user identifier provided by F-AI. However, there may be cases where the clientId is not saved in your CRM system from F-AI

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET /api/recommendations/email

Query Parameters

Parameter Type Required Description
clientId string Conditional The unique identifier of the client or user.
userExternalId string Conditional The unique identifier of the user (alternative to clientId).
limit number No The maximum number of recommended products to return.
access_token string Yes Retrieved from the Access Token API with the credentials of Admin or Marketing Manager.

Search based Recommendation

Use the access token obtained from authentication method:


  require "uri"
  require "net/http"
  
  url = URI("{{baseURL}}/api/recommendations/search?limit=10&userExternalId=1781720938019283091283091280391&clientId=64704bc8d0afa15c5c459cbc&category=Bacanie&query=beer,whisky&access_token={access_token}")
  
  http = Net::HTTP.new(url.host, url.port);
  request = Net::HTTP::Get.new(url)
  
  response = http.request(request)
  puts response.read_body
  
  
\
  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => '{{baseURL}}/api/recommendations/search?limit=10&userExternalId=1781720938019283091283091280391&clientId=64704bc8d0afa15c5c459cbc&category=Bacanie&query=beer%2Cwhisky&access_token={access_token}',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
  ));
  
  $response = curl_exec($curl);
  
  curl_close($curl);
  echo $response;

  curl --location --globoff '{{baseURL}}/api/recommendations/search?limit=10&userExternalId=1781720938019283091283091280391&clientId=64704bc8d0afa15c5c459cbc&category=Bacanie&query=beer%2Cwhisky&access_token={access_token}' \
  --data ''

  var raw = "";

  var requestOptions = {
    method: 'GET',
    body: raw,
    redirect: 'follow'
  };
  
  fetch("{{baseURL}}/api/recommendations/search?limit=10&userExternalId=1781720938019283091283091280391&clientId=64704bc8d0afa15c5c459cbc&category=Bacanie&query=beer,whisky&access_token={access_token}", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

The above command returns JSON structured like this:


  {
    "status": "success",
    "data": {
        "clientId": "64704ae0d0afa15c5c444b59",
        "userExternalId": "d650988e68ac760feeef40a67c5.....",
        "recommendations": [
            {
                "externalId": "969436",
                "name": "Cocktail masline Auchan, 200g",
                "score": 45.099999999999994,
                "productId": "646b3e6b7c9ad562cba3c8c4"
            },
            {
                "externalId": "325494",
                "name": "Otet Balsamic de Modena Auchan 0.5L",
                "score": 44.2,
                "productId": "646b3a7e7c9ad562cba19b18"
            },
            {
                "externalId": "539963",
                "name": "Otet balsamic Auchan 250 ml",
                "score": 44.2,
                "productId": "646b3b547c9ad562cba243dd"
            },
            {
                "externalId": "973167",
                "name": "Otet balsamic modena Auchan, 500ml",
                "score": 44.2,
                "productId": "646b3e7f7c9ad562cba3d09c"
            },
            {
                "externalId": "149391",
                "name": "Migdale in miere Auchan, 30 g",
                "score": 43.9,
                "productId": "646b39f27c9ad562cba0f7d4"
            },
            {
                "externalId": "244717",
                "name": "Otel din vin alb Auchan, 1 l",
                "score": 43.9,
                "productId": "646b3a457c9ad562cba161dc"
            },
            {
                "externalId": "832430",
                "name": "Miere tei Auchan, 400 g",
                "score": 43.9,
                "productId": "646b3d387c9ad562cba348f7"
            },
            {
                "externalId": "969415",
                "name": "Zahar brun Auchan, 750 g",
                "score": 43.9,
                "productId": "646b3e6a7c9ad562cba3c880"
            },
            {
                "externalId": "977423",
                "name": "Otet alimentar Auchan, 1l",
                "score": 43.9,
                "productId": "646b3e977c9ad562cba3da04"
            },
            {
                "externalId": "132159",
                "name": "Sos barbeque Auchan 350 ml",
                "score": 43.599999999999994,
                "productId": "646b39e97c9ad562cba0e964"
            }
        ]
    }
}

Retrieves personalized product recommendations for search results based on the user's search query. The recommendations can be filtered by category, and the maximum number of recommendations can be specified.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET /api/recommendations/search

Query Parameters

Parameter Type Required Description
clientId string No The unique identifier of the client or user.
userExternalId string No The unique identifier of the user (alternative to clientId).
query string Yes The user's search query.
category string No The category of products to filter the recommendations.
limit number No The maximum number of recommended products to return.
access_token string Yes Retrieved from the Access Token API with the credentials of Admin or Marketing Manager.

Product based Recommendation

Use the access token obtained from authentication method:


  require "uri"
  require "net/http"
  
  url = URI("{{baseURL}}/api/recommendations/product?limit=10&clientId=64704bc8d0afa15c5c459cbc&product=beer%2Cwhisky&access_token={access_token}")
  
  http = Net::HTTP.new(url.host, url.port);
  request = Net::HTTP::Get.new(url)
  
  response = http.request(request)
  puts response.read_body
  
  
  
\
  
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '{{baseURL}}/api/recommendations/product?limit=10&clientId=64704bc8d0afa15c5c459cbc&product=beer%2Cwhisky&access_token={access_token}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


  curl --location --globoff '{{baseURL}}/api/recommendations/product?limit=10&clientId=64704bc8d0afa15c5c459cbc&product=beer%2Cwhisky&access_token={access_token}' 
  --data ''

  var raw = "";

  var requestOptions = {
    method: 'GET',
    body: raw,
    redirect: 'follow'
  };
  
  fetch("{{baseURL}}/api/recommendations/product?limit=10&clientId=64704bc8d0afa15c5c459cbc&product=beer%2Cwhisky&access_token={access_token}", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

The above command returns JSON structured like this:


  {
    "status": "success",
    "data": {
        "clientId": "64704ae0d0afa15c5c444b59",
        "userExternalId": "d650988e68ac760feeef40a67c5.....",
        "recommendations": [
            {
                "externalId": "969436",
                "name": "Cocktail masline Auchan, 200g",
                "score": 45.099999999999994,
                "productId": "646b3e6b7c9ad562cba3c8c4"
            },
            {
                "externalId": "325494",
                "name": "Otet Balsamic de Modena Auchan 0.5L",
                "score": 44.2,
                "productId": "646b3a7e7c9ad562cba19b18"
            },
            {
                "externalId": "539963",
                "name": "Otet balsamic Auchan 250 ml",
                "score": 44.2,
                "productId": "646b3b547c9ad562cba243dd"
            },
            {
                "externalId": "973167",
                "name": "Otet balsamic modena Auchan, 500ml",
                "score": 44.2,
                "productId": "646b3e7f7c9ad562cba3d09c"
            },
            {
                "externalId": "149391",
                "name": "Migdale in miere Auchan, 30 g",
                "score": 43.9,
                "productId": "646b39f27c9ad562cba0f7d4"
            },
            {
                "externalId": "244717",
                "name": "Otel din vin alb Auchan, 1 l",
                "score": 43.9,
                "productId": "646b3a457c9ad562cba161dc"
            },
            {
                "externalId": "832430",
                "name": "Miere tei Auchan, 400 g",
                "score": 43.9,
                "productId": "646b3d387c9ad562cba348f7"
            },
            {
                "externalId": "969415",
                "name": "Zahar brun Auchan, 750 g",
                "score": 43.9,
                "productId": "646b3e6a7c9ad562cba3c880"
            },
            {
                "externalId": "977423",
                "name": "Otet alimentar Auchan, 1l",
                "score": 43.9,
                "productId": "646b3e977c9ad562cba3da04"
            },
            {
                "externalId": "132159",
                "name": "Sos barbeque Auchan 350 ml",
                "score": 43.599999999999994,
                "productId": "646b39e97c9ad562cba0e964"
            }
        ]
    }
}

Retrieves personalized product recommendations for the product detail page. The recommendations can be filtered by category, and the maximum number of recommendations can be specified.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET /api/recommendations/product

Query Parameters

Parameter Type Required Description
clientId string Conditional The unique identifier of the client or user.
userExternalId string Conditional The unique identifier of the user (alternative to clientId).
product string No The identifier of the current product being viewed. (or) product name.
limit number No The maximum number of recommended products to return.
access_token string Yes Retrieved from the Access Token API with the credentials of Admin or Marketing Manager.

Checkout based Recommendation

Use the access token obtained from authentication method:


  require "uri"
  require "net/http"
  
  url = URI("{{baseURL}}/api/recommendations/checkout?limit=10&clientId=64704bc8d0afa15c5c459cbc&cart_items=beer,whisky&access_token={access_token}&userExternalId=1781720938019283091283091280391")
  
  http = Net::HTTP.new(url.host, url.port);
  request = Net::HTTP::Get.new(url)
  
  response = http.request(request)
  puts response.read_body
  
  
  
\
  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => '"{{baseURL}}/api/recommendations/checkout?limit=10&clientId=64704bc8d0afa15c5c459cbc&cart_items=beer,whisky&access_token={access_token}&userExternalId=1781720938019283091283091280391"',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
  ));
  
  $response = curl_exec($curl);
  
  curl_close($curl);
  echo $response;
  

  curl --location --globoff '"{{baseURL}}/api/recommendations/checkout?limit=10&clientId=64704bc8d0afa15c5c459cbc&cart_items=beer,whisky&access_token={access_token}&userExternalId=1781720938019283091283091280391"' \
  --data ''

  var raw = "";

  var requestOptions = {
    method: 'GET',
    body: raw,
    redirect: 'follow'
  };
  
  fetch("{{baseURL}}/api/recommendations/checkout?limit=10&clientId=64704bc8d0afa15c5c459cbc&cart_items=beer,whisky&access_token={access_token}&userExternalId=1781720938019283091283091280391", requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log('error', error));

The above command returns JSON structured like this:


  {
    "status": "success",
    "data": {
        "clientId": "64704ae0d0afa15c5c444b59",
        "userExternalId": "d650988e68ac760feeef40a67c590b8233a411a6c81cbddd2026d7adf3221b1d68292e9b45983b14ccab8aa36eac8c24052a08ae9acb5f5187bf3974a3aad7dd",
        "recommendations": [
            {
                "externalId": "969436",
                "name": "Cocktail masline Auchan, 200g",
                "score": 45.099999999999994,
                "productId": "646b3e6b7c9ad562cba3c8c4"
            },
            {
                "externalId": "325494",
                "name": "Otet Balsamic de Modena Auchan 0.5L",
                "score": 44.2,
                "productId": "646b3a7e7c9ad562cba19b18"
            },
            {
                "externalId": "539963",
                "name": "Otet balsamic Auchan 250 ml",
                "score": 44.2,
                "productId": "646b3b547c9ad562cba243dd"
            },
            {
                "externalId": "973167",
                "name": "Otet balsamic modena Auchan, 500ml",
                "score": 44.2,
                "productId": "646b3e7f7c9ad562cba3d09c"
            },
            {
                "externalId": "149391",
                "name": "Migdale in miere Auchan, 30 g",
                "score": 43.9,
                "productId": "646b39f27c9ad562cba0f7d4"
            },
            {
                "externalId": "244717",
                "name": "Otel din vin alb Auchan, 1 l",
                "score": 43.9,
                "productId": "646b3a457c9ad562cba161dc"
            },
            {
                "externalId": "832430",
                "name": "Miere tei Auchan, 400 g",
                "score": 43.9,
                "productId": "646b3d387c9ad562cba348f7"
            },
            {
                "externalId": "969415",
                "name": "Zahar brun Auchan, 750 g",
                "score": 43.9,
                "productId": "646b3e6a7c9ad562cba3c880"
            },
            {
                "externalId": "977423",
                "name": "Otet alimentar Auchan, 1l",
                "score": 43.9,
                "productId": "646b3e977c9ad562cba3da04"
            },
            {
                "externalId": "132159",
                "name": "Sos barbeque Auchan 350 ml",
                "score": 43.599999999999994,
                "productId": "646b39e97c9ad562cba0e964"
            }
        ]
    }
}

Retrieves personalized product recommendations for personalized emails. The recommendations can be filtered by category, and the maximum number of recommendations to include in the email can be specified.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET /api/recommendations/checkout

Query Parameters

Parameter Type Required Description
clientId string Conditional The unique identifier of the client or user.
userExternalId string Conditional The unique identifier of the user (alternative to clientId).
cart_items string Yes An array of product IDs representing the items in the user's shopping cart.
limit number No The maximum number of recommended products to return.
access_token string Yes Retrieved from the Access Token API with the credentials of Admin or Marketing Manager.

Loyalty Campaign Codes

Get Active Loyalty Campaigns

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/active-campaigns?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/active-campaigns?access_token={{access_token}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request GET \
    --url 'http://{{base_url}}/api/loyaltyCode/active-campaigns?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
  var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "loyaltyCode",
        "active-campaigns"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:

  {
    "status": "success",
    "campaigns": [
        {
            "_id": "5bd2f3b6a651e40b280741ac",
            "internalId": "3irf2dmn8ks",
            "name": "Demo Campaign 2",
            "startDate": "2018-10-26T10:59:08.000Z",
            "endDate": "2018-12-26T10:59:08.000Z",
            "expireCodesDate": "2019-10-27T10:59:08.000Z",
            "loyaltySettings": {
                "loyaltyPrizeTypes": [
                    {
                        "name": "Prize 1"
                    },
                    {
                        "name": "Prize 2"
                    }
                ]
            },
            "location": {
                "name": "Mega Mall"
            },
            "total": 0
        },
        {
            "_id": "5ls6a8de1f4da126689eec44",
            "internalId": "i8inejs4t8c",
            "name": "Demo Campaign 4",
            "startDate": "2018-10-07T08:59:40.000Z",
            "endDate": "2018-11-30T08:59:40.000Z",
            "expireCodesDate": "2018-11-22T08:59:40.000Z",
            "loyaltySettings": {
                "loyaltyPrizeTypes": [
                    {
                        "name": "Prize 3"
                    }
                ]
            },
            "location": {
                "name": "Mega Mall"
            },
            "total": 1
        }
    ]
}

This method allows you to get the list with all active campaigns associated to the authenticated user

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/loyaltyCode/active-campaigns

Query Parameters

Parameter Description
access_token access token

Get Loyalty Campaigns

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/campaigns?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/campaigns?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
    curl --request GET \
    --url 'http://{{base_url}}/api/loyaltyCode/campaigns?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "loyaltyCode",
        "campaigns"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end(); 

The above command returns JSON structured like this:

  {
    "status": "success",
    "campaigns": [
        {
            "_id": "5ss2f3b6a651736e40b280741ac",
            "internalId": "4ihf47mngkb",
            "name": "Campaign name",
            "type": "drive_loyalty",
            "budget": 0,
            "salesCost": null,
            "monthlySellingCost": null,
            "monthlyServicingCost": null,
            "productionCost": null,
            "profitabilityTime": null,
            "retentionRate": null,
            "landingPageURL": "",
            "startDate": "2018-10-26T10:59:08.000Z",
            "endDate": "2018-12-26T10:59:08.000Z",
            "expireCodesDate": "2019-10-27T10:59:08.000Z",
            "timestamp": "2018-10-26T11:00:06.633Z",
            "createdAt": "2018-10-26T11:00:06.633Z",
            "__v": 15,
            "locationId": "58d5385a68a157484ba1dw11",
            "loyaltySettings": {
                "type": "instant",
                "allowedChars": "",
                "codeLength": "9",
                "loyaltyPrizeTypes": [
                    {
                        "_id": "5cs8868d0880e32034d474d9",
                        "totalCodes": 22,
                        "pointsValue": 10,
                        "name": "Prize 1"
                    },
                    {
                        "_id": "5cs8968d0880e32034d474d8",
                        "totalCodes": 25,
                        "pointsValue": 20,
                        "name": "Prize 2"
                    }
                ]
            },
            "extraAllocations": [
                {
                    "type": "purchases",
                    "currency": "",
                    "criteria": "above",
                    "period": "",
                    "value": 120,
                    "betweenValue": null,
                    "loyaltyPoints": 10,
                    "customPeriod": 0,
                    "_id": "5ds2f3b6b651e42baaa941wq"
                }
            ],
            "leads": [],
            "total": 0
        }
    ]
}

This method allows you to get the list with all campaigns associated to the authenticated user

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/loyaltyCode/campaigns

Query Parameters

Parameter Description
access_token access token

Check Client Code

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/check?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2"
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/check?access_token={{access_token}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
  --url 'http://{{base_url}}/api/loyaltyCode/check?access_token={{access_token}}' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2'
   var qs = require("querystring");
  var http = require("http");
  
  var options = {
    "method": "POST",
    "hostname": [
      "{{base_url}}"
    ],
    "path": [
      "api",
      "loyaltyCode",
      "check"
    ],
    "headers": {
      "Content-Type": "application/x-www-form-urlencoded"
    }
  };
  
  var req = http.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function () {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  });
  
  req.write(qs.stringify({ userEmail: 'mihai@popescu.com',
    userPhone: '+075364628484',
    campaignInternalId: 'msyfms5a9sd2' }));
  req.end();

The above command returns JSON structured like this:

  {
    "status": "success",
    "message": "redeem code found",
    "code": "9E58EDI",
    "expire_code_date": "2018-12-15 17:28:47",
    "prize_status": "associated", 
    "prize": {
          name: "Prize Name Example"
    }, 
    "last_update": "2018-11-21 15:48:14"
  }

This method allows you to check if a client has a code already allocated to a specific campaign

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/loyaltyCode/check

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userEmail user's email address
userPhone user's phone
campaignInternalId campaign internal id

Change Code Status

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/change?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2&code=XFSTWK98HG"
    
    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/change?access_token={{access_token}}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2&code=XFSTWK98HG",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
  --url 'http://{{base_url}}/api/loyaltyCode/change?access_token={{access_token}}' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'userEmail=mihai%40popescu.com&userPhone=%2B075364628484&campaignInternalId=msyfms5a9sd2&code=XFSTWK98HG'
   var qs = require("querystring");
  var http = require("http");
  
  var options = {
    "method": "POST",
    "hostname": [
      "{{base_url}}"
    ],
    "path": [
      "api",
      "loyaltyCode",
      "change"
    ],
    "headers": {
      "Content-Type": "application/x-www-form-urlencoded"
    }
  };
  
  var req = http.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function () {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  });
  
  req.write(qs.stringify({ userEmail: 'mihai@popescu.com',
    userPhone: '+075364628484',
    campaignInternalId: 'msyfms5a9sd2',
    code: 'XFSTWK98HG' }));
  req.end();

The above command returns JSON structured like this:

  {
    "status": "success"
  }

This method allows you to change a status code from allocated to redeemed/blocked

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/loyaltyCode/change

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userEmail user's email address
userPhone user's phone
campaignInternalId campaign internal id
code the code to be redeemed/blocked

Code List

Use the access token obtained from authentication method:



    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/loyaltyCode/list?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "campaignInternalId=e2h11c3its&searchTerm=&page=1"

  $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/list?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "campaignInternalId=e2h11c3its&searchTerm=&page=1",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }

   curl --request POST \
    --url 'http://{{base_url}}/api/loyaltyCode/list?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'campaignInternalId=e2h11c3its&searchTerm=&page=1'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "loyaltyCode",
        "list"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ campaignInternalId: 'e2h11c3its', searchTerm: '', page: '1' }));
    req.end();

The above command returns JSON structured like this:

  {
  "status": "success",
  "clients": [
      {
          "code": "9X4C8DN6",
          "campaign": {
              "_id": "5cc5ef457c4c2154445fe9d2",
              "internalId": "e2h11c3its",
              "name": "Test 1",
              "type": "drive_loyalty",
              "startDate": "2018-10-01T13:38:39.000Z",
              "endDate": "2018-10-16T13:38:39.000Z",
              "loyaltySettings": {
                  "type": "standard"
              },
              "expireCodesDate": "2018-10-31T21:00:00.000Z"
          },
          "client": {
              "_id": "5ba4c44422206e61b1b8b515",
              "userFirstName": "Andrei",
              "userLastName": "Ionescu",
              "userEmail": "exemplu@test.com",
              "userPhone": "0700000000",
              "userAddress": ""
          },
          "status": "associated",
          "prize": {
              "pointsValue": 1,
              "name": "Prize number 1"
          },
          "hostess": {
              "_id": "5a0f3b91137e430dfc6795d7",
              "name": "Test Hostess"
          }
      }
  ],
  "totalResults": 1
} 

Get the paginated list with allocated,redeemed and blocked codes for one/all campaigns

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/loyaltyCode/list

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
campaignInternalId (optional) campaign internal id
searchTerm (optional) search in code field
page (optional) page number (if not specified the server will return the first page results)

Check Loyalty User Prize History

Use the access token obtained from authentication method:



    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/loyaltyCode/history?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "userEmail=mihai%40popescu.com&userPhone=%2B075364625500"

    response = http.request(request)
    puts response.read_body

  $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/loyaltyCode/history?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "userEmail=mihai%40popescu.com&userPhone=%2B075364625500",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }

   curl --request POST \
    --url 'http://{{base_url}}/api/loyaltyCode/history?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'userEmail=mihai%40popescu.com&userPhone=%2B075364625500'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "loyaltyCode",
        "history"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ userEmail: 'mihai@popescu.com', userPhone: '+075364625500' }));
    req.end();

The above command returns JSON structured like this:

  
    {
      "status": "success",
      "codes": [
          {
              "code": "JGFRZ328",
              "campaign": {
                  "internalId": "17ytx3n52qm",
                  "name": "Loyalty Test"
              },
              "status": "redeemed",
              "prize": {
                  "name": "Prize Name"
              },
              "location": {
                  "name": "Location name"
              },
              "expire_code_date": "2018-12-15T15:28:47.000Z",
              "last_update": "2018-11-28T09:26:00.726Z"
          }
      ]
  }

Get the prizes redeemed or associated to a specific user

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/loyaltyCode/history

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
userEmail user email
userPhone user phone

List Categories

Use the access token obtained from authentication method:

    require 'uri'
require 'net/http'

url = URI("http://{{base_url}}/api/offerCategory?access_token={{access_token}}")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offerCategory?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/offerCategory?access_token={{access_token}}'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory"
      ],
      "headers": {}
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

Response headers:

  
  {
    Access-Control-Expose-Headers : X-Total-Pages, X-Records, X-Current-Page
    X-Current-Page : 1
    X-Records : 2
    X-Total-Pages : 1
  }

Response body:

  
    [
      { 
        "_id": "5d7a3190e47bd328e45bd176",
        "name": "Catalog 1"
      },
      { 
        "_id": "5d7a3190e47bd328e45bd177",
        "name": "Catalog 2"
      }
    ]

List Categories

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/offerCategory

Query Parameters

Parameter Description
access_token access token
page page number

List offers

Use the access token obtained from authentication method:

    require 'uri'
require 'net/http'

url = URI("http://{{base_url}}/api/offer?access_token={{access_token}}&page=1")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offer?access_token={{access_token}}&page=1",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/offer?access_token={{access_token}}&page=1'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory"
      ],
      "headers": {}
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

Response headers:

  
  {
    Access-Control-Expose-Headers : X-Total-Pages, X-Records, X-Current-Page
    X-Current-Page : 1
    X-Records : 2
    X-Total-Pages : 1
  }

Response body:

  
    [
      {
          "_id": "5d7f8932387e93790a187b3b",
          "name": "Offer 1",
          "price": 250,
          "externalId": "GSFAR300", 
          "offerCategory": {
              "_id": "5cf92a83bc790a5cf99e34cd",
              "name": "Catalog 1"
          }
      },
      {
        "_id": "5d7f8932387e93790a187b3b",
        "name": "Offer 2",
        "price": 350, 
        "externalId": "GDTSR302",
        "offerCategory": {
            "_id": "5cf92a83bc790a5cf99e34cd",
            "name": "Catalog 1"
        }
      },
    ]

List Offers

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/offer

Query Parameters

Parameter Description
access_token access token
page page number

List SKUs

Use the access token obtained from authentication method:


require 'uri'
require 'net/http'

url = URI("http://{{base_url}}/api/sku?access_token={{access_token}}&page=1")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/sku?access_token={{access_token}}&page=1",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/sku?access_token={{access_token}}&page=1'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory"
      ],
      "headers": {}
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

Response headers:

  
  {
    Access-Control-Expose-Headers : X-Total-Pages, X-Records, X-Current-Page
    X-Current-Page : 1
    X-Records : 2
    X-Total-Pages : 1
  }

Response body:

  
    [
      {
          "_id": "5e6b7be8576e5213f065b23c",
          "name": "PROD SKU 1",
          "price": 5534,
          "externalId": "RESH132",
          "quantity": 1,
          "offer": {
              "_id": "5cf92a83bc790a5cf99e35cf",
              "name": "Product 1"
          }
      },
      {
        "_id": "5d7f8932387e93790a187b38",
        "name": "PROD SKU 2",
        "price": 1132,
        "externalId": "TARS635",
        "quantity": 1,
        "offer": {
            "_id": "5cf92a83bc790a5cf99e35cd",
            "name": "Product 5"
        }
      },
    ]

List SKUs

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/sku

Query Parameters

Parameter Description
access_token access token
page page number

List Locations

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/location?access_token={{access_token}}&country_name={{country_name}}&county_name={{county_name}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/location?access_token={{access_token}}&country_name={{country_name}}&county_name={{county_name}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/location?access_token={{access_token}}&country_name={{country_name}}&county_name={{county_name}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "location"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:


    [{
        "_id": "5b887473a504503c31559108",
        "timestamp": "2018-08-07T10:29:07.932Z",
        "createdAt": "2018-08-07T10:29:07.932Z",
        "areaId": "5b697473a504503c31299107",
        "name": "Sucursala Test", 
        "description": "17:00-19:00",
        "address": "Alba Iulia, Str. Test nr.1",
        "__v": 1,
        "coords": [
            0,
            0
        ],
        "image": ""
    }]

Lists bussiness locations

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/location

Query Parameters

Parameter Description
access_token Access token
country_name Country name (Optional)
county_name County name (Optional)

List Offline Campaigns

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/offlineCampaign?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offlineCampaign?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
   curl --request GET \
    --url 'http://{{base_url}}/api/offlineCampaign?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offlineCampaign"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:


    [{
        "_id": "5b30cb8ae1267446c1554b6c",
        "locationId": "5b02c891f7fb282c3a8f34b9",
        "name": "Offline Campanign Test",
        "description": "",
        "image": null,
        "type": "offline",
        "budget": 0,
        "startDate": "2018-06-25T11:00:18.000Z",
        "endDate": "2018-11-30T11:00:18.000Z",
        "timestamp": "2018-06-25T11:00:58.546Z",
        "createdAt": "2018-06-25T11:00:58.546Z",
        "drawFrequency": {
            "repeats": "none",
            "frequency": null,
            "day": null,
            "end": {
                "type": "",
                "value": ""
            }
        },
        "winningType": [],
        "__v": 0
    }]

List Offline Campaigns

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/offlineCampaign

Query Parameters

Parameter Description
access_token access token

List Business Users

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/business-users?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/business-users?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
   curl --request GET \
    --url 'http://{{base_url}}/api/business-users?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "business-users"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:


    [{
      "_id": "5ff16u391c21fa85wfad5278",
      "locations": [
          {
              "_id": "5d53b911441c3a7890b5212c",
              "name": "Location 1"
          },
          {
              "_id": "5b4b3b4598721d409592201a",
              "name": "Location 2"
          }
      ],
      "offerCategories": [
          {
              "_id": "5dae1ff557a2dg03f7799c9a",
              "name": "Category 1"
          },
          {
              "_id": "5df03c10cec8576c0fc1e46d",
              "name": "Category 2"
          }
      ],
      "firstName": "User Last Name",
      "lastName": "User First Name",
      "email": "user.email@test.com",
      "phone": "0000000000",
      "groupRole": "sales",
      "role": "consultant"
  }]

List Business Users

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/business-users

Query Parameters

Parameter Description
access_token access token

List Channels

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/api/channels?access_token={{access_token}}")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/channels?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
   curl --request GET \
    --url 'http://{{base_url}}/api/channels?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded'
   var http = require("http");

    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "channels"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:


    [{
      "_id": "5d72559ea51b651623b1ac8b",
      "name": "Channel 1",
      "mediaType": "Earned Media"
    },
    {
      "_id": "7d72339ea51b651648b1a4a2",
      "name": "Channel 2",
      "mediaType": "Owned Media"
    }]

List Channels

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/channels

Query Parameters

Parameter Description
access_token access token

Send Notifications

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/notifications/send?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "templateKey=irqm1350re7pw&email=test@test.com&attachmentFileName=test.pdf&attachmentFileContent=JVBERi0xLjQNJeLjz9M..."
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/notifications/send?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "templateKey=irqm1350re7pw&email=test@test.com&attachmentFileName=test.pdf&attachmentFileContent=JVBERi0xLjQNJeLjz9M...",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request POST \
    --url 'http://{{base_url}}/api/notifications/send?access_token={{access_token}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'templateKey=irqm1350re7pw&email=test@test.com&attachmentFileName=test.pdf&attachmentFileContent=JVBERi0xLjQNJeLjz9M...'
   var qs = require("querystring");
    var http = require("http");
    
    var options = { 
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "notifications",
        "send"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ templateKey: 'irqm1350re7pw',
      email: 'test@test.com',
      attachmentFileName: 'test.pdf',
      attachmentFileContent: 'JVBERi0xLjQNJeLjz9M...' }));
    req.end();

The above command returns JSON structured like this:

 {
  "status": "success",
  "message": "Message sent!"
}

Send email notifications

HTTP Request

POST {{base_url}}/api/notifications/send

Query Parameters

Parameter Description
access_token access token

Body

Parameter Description
templateKeytemplate key
emailuser email address
firstNameuser's first name
lastNameuser's last name
attachmentFileNameattachment filename
attachmentFileContentattachment file content (base64 encoded); file types allowed - pdf

Rate Limiting

A rate limiting algorithm is used to check if the IP address has to be limited based on the information in the session cache. In case a client made too many requests within a given time frame, HTTP servers can respond with status code 429: Too Many Requests.

Header

  
{
    "X-RateLimit-Limit": "180",
    "X-RateLimit-Remaining": "178",
    "X-RateLimit-Reset": "1690902474"
}
Key Description
X-RateLimit-Limit The HTTP response header X-RateLimit-Limit is used by web servers to provide the maximum number of requests that a client (such as a web browser or External API client) is permitted to perform in a given amount of time, usually measured in seconds.
X-RateLimit-Remaining The HTTP response header called X-RateLimit-Remaining is sent with rate-limited API responses. It displays the amount of requests a client can still submit within the current time frame before exceeding the set cap.
X-RateLimit-Reset The HTTP response header called X-RateLimit-Reset is used to specify the amount of time (in seconds since the Unix epoch) after a client reaches a rate limit in an API or web service when they can retry making requests. The time at which clients should send new requests is at this point.

Web Data Tracking

Initialize web tracking session


    require 'uri'
  require 'net/http'

  url = URI("http://{{base_url}}/jsapi/init")

  http = Net::HTTP.new(url.host, url.port)

  request = Net::HTTP::Post.new(url)
  request["Content-Type"] = 'application/x-www-form-urlencoded'
  request.body = "appkey=571e64183647a855d0sgf3a3&email=test.email%40test.com"

  response = http.request(request)
  puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/jsapi/init",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "appkey=571e64183647a855d0sgf3a3&email=test.email%40test.com",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
    --url 'http://{{base_url}}/jsapi/init' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'appkey=571e64183647a855d0sgf3a3&email=test.email%40test.com'
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "jsapi",
        "init"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ appkey: '571e64183647a855d0sgf3a3',
      email: 'test.email%40test.com' }));
    req.end();

The above command returns JSON structured like this:

  
{
    "status": "ok",
    "pid": "b38efdc7087731bbef9d6cb050a6aa9bbcb8beb2178ec42afac83eb5e836f050"
}

This method initializes the web tracking session for a specific user. In a successful response you'll get an uid value (when the user was identified in our database) or a pid value for a NOT identified user. You can use this value in the next method for sending tracking data.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/jsapi/init

Body

Parameter Description
appkey application key
email user's email address
technicalInfo[screenSize] screen size (widthxheight), string format
technicalInfo[browserUserAgent] browserUserAgent data; ex: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36
technicalInfo[browserType] browser type; ex: Chrome
technicalInfo[appId] iTunes ID / Google Play ID
technicalInfo[deviceOs] device operating system (Windows, Android, iOS ...)

Fetch Client Details

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/lead/fetch?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/lead/fetch?access_token={{access_token}}&email={{email}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_POSTFIELDS => "email=demo@gmail.com&phone=9876543210",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   curl --request GET \
    --url 'http://{{base_url}}/api/lead/fetch{{access_token}}&email={{email}}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \

   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "GET",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "lead",
        "fetch"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ email:'demo@gmail.com', phone:'9876543210' }));
    req.end();

The above command returns JSON structured like this:

 {
  "status": "ok",
  "data": {
    "offerCategoryId": "5fae0f4e1850056be1fd4ec4", 
    "offerId":"5fae16621850056be1fd5001", 
    "offerSKUs": [ 
       "5fae17a71850056be1fd5005", 
       "636d1131666ee32450ba5f86" 
    ],
    "offerCategoryName": "Demo M Life",
    "offerName": "Asigurarea Asa cum vrei tu",	
    "marketingChannels": [ 
        { 
            "locationId": "5cf92039bc790a5cf99e3540", 
            "consentCreatedAt": "2023-08-11T11:45:21.879Z", 
            "requestedThrough": "Form", 
            "agreeToCollect": true, 
            "agreementExpiration": "2025-08-11T11:45:21.878Z", 
            "settings": [ 
                { 
                    "channel": "email", 
                    "type": "owner", 
                    "agreed": false 
                }, 
                { 
                    "channel": "email", 
                    "type": "partners", 
                    "agreed": false 
                }, 
                { 
                    "channel": "email", 
                    "type": "group", 
                    "agreed": false 
                }, 
                { 
                    "channel": "email", 
                    "type": "profiling", 
                    "agreed": true 
                }, 
                { 
                    "channel": "sms", 
                    "type": "owner", 
                    "agreed": true 
                }, 
                {
                    "channel": "sms", 
                    "type": "partners", 
                    "agreed": false 
                }, 
                { 
                    "channel": "sms", 
                    "type": "group", 
                    "agreed": true 
                }, 
                { 
                    "channel": "sms", 
                    "type": "profiling", 
                    "agreed": false 
                }, 
                { 
                    "channel": "notification", 
                    "type": "owner", 
                    "agreed": true 
                },
                { 
                    "channel": "notification", 
                    "type": "partners", 
                    "agreed": false 
                }, 
                { 
                    "channel": "notification", 
                    "type": "group", 
                    "agreed": false 
                }, 
                { 
                    "channel": "notification", 
                    "type": "profiling", 
                    "agreed": false 
                } 
            ] 
        } 
    ], 
    "userFirstName": "Demo", 
    "userLastName": "Client", 
    "userEmail": demo@gmail.com, 
    "userPhone": "9876543210",	
    "userCompanyAddress": "5072 W Plano Pkwy #150, Plano, TX 75093, USA", 
    "userCompanyTaxNumber": "13124", 
    "userBuildingNumber": "", 
    "userApartmentNumber": "", 
    "userFloorNumber": "",       
    "locationId": "5cf92039bc790a5cf99e3540", 
    "locationName": "Test – Location 1" 
} 

}

This method is used to get the client details. It fetch the data based on the provided email or phone.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

GET {{base_url}}/api/lead/fetch

Query Parameters

Parameter Description
access_token access token
email user's email address
phone user's phone number

Create/Update Categories

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/offerCategory/storeOfferCategories={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Pos.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offerCategory/storeOfferCategories?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
    curl --location 'https://{{base_url}}/api/offerCategory/storeOfferCategories?access_token={{access_token}}' \
  --header 'Content-Type: application/json' \
  --data '{
      "offerCategories":[
      {
      "name": "demo",
      "locationId": [""],
      "salesManagerId": [""],
      "consultantId": [""],
      "alias": [""],
      "externalId":"",
      "active":true/false,
      "image":"",
      "description":"",
      "catalogType":"rent/buy"
      }]
  }'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory",
        "storeOfferCategories"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:

{
  "status": true,
  "message": "success"
}

This method is used to create or update the categories.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/offerCategory/storeOfferCategories

Query Parameters

Parameter Description
access_token access token

Body

Parameter Type Required Description
name string yes Category Name
externalId string no Category ExternalId
catalogType string yes Category type (rent/buy)
locationId array no Business Location Id
salesManagerId array no Sales Manager Id
consultantId array no Sales Consultant Id
image string no Category Image
alias array no Category Alias
description string no Category Description
active boolean yes Category Status (true/false)

Create/Update Offers

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/offerCategory/storeOffers={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Pos.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offerCategory/storeOffers?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
    curl --location 'https://{{base_url}}/api/offerCategory/storeOffers?access_token={{access_token}}' \
  --header 'Content-Type: application/json' \
  --data '{
      "offers":[
      {
      "catalogName": "demo",
      "name":"demo product",
      "alias": [""],
      "externalId":"",
      "catalogExternalId":"",
      "price":1,
      "active":true/false,
      "image":"",
      "description":"",
      "documents":[""]
      }]
  }'
   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory",
        "storeOffers"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:

{
  "status": true,
  "message": "success"
}

This method is used to create or update the offers.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/offerCategory/storeOffers

Query Parameters

Parameter Description
access_token access token

Body

Parameter Type Required Description
name string yes Offer Name
catalogName string yes Category Name (Use this name to create/update the product to the category.)
externalId string no Offer External Id
catalogExternalId string no Category External Id
price number yes Product Price
image string no Offer Image
alias array no Offer Alias
description string no Offer Description
active boolean yes Offer status (true/false)
document array no Array with the product documents

Create/Update Skus

Use the access token obtained from authentication method:


    require 'uri'
    require 'net/http'
    
    url = URI("http://{{base_url}}/api/offerCategory/storeOfferSku?access_token={{access_token}}")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Pos.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    
    response = http.request(request)
    puts response.read_body

    $curl = curl_init();

    curl_setopt_array($curl, array(
      CURLOPT_URL => "http://{{base_url}}/api/offerCategory/storeOfferSku?access_token={{access_token}}",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "",
      CURLOPT_HTTPHEADER => array(
        "Content-Type: application/x-www-form-urlencoded"
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }


    
    
  curl --location 'https://{{base_url}}/api/offerCategory/storeOfferSku?access_token={{access_token}}' \
  --header 'Content-Type: application/json' \
  --data '{
  "offerSku":[
  {
  "productName": "demo product",
  "name":"demo sku",
  "alias": [""],
  "externalId":"",
  "productExternalId":"",
  "price":1,
  "active":true/false,
  "image":"",
  "description":"",
  "documents":[""],
  "startDate":"YYYY-MM-DD",
  "endDate":"YYYY-MM-DD",
  "currency":"RON/USD/EUR/AED",
  "quantity" : 1,
  "repeatInterval" : "day/week/month/year",
  "repeatFreqency" : 1
  }]
  }'



   var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "api",
        "offerCategory",
        "storeOfferSku"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.end();

The above command returns JSON structured like this:

{
  "status": true,
  "message": "success"
}

This method is used to create or update the SKUs.

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/api/offerCategory/storeOfferSku

Query Parameters

Parameter Description
access_token access token

Body

Parameter Type Required Description
name string yes SKU name
productName string yes Offer Name (Use this name to create/update the sku to the product.)
externalId string no SKU External Id
productExternalId string no Offer External Id
price number yes SKU price
image string no SKU image
alias array no SKU Alias
description string no SKU Description
active boolean yes SKU status (true/false)
document array no Array with the SKU documents
quantity number yes SKU Quantity
currency string yes currency accept types('USD','EUR','RON','AED')
startDate string no SKU start date
endDate string no SKU end date
repeatInterval string required for catalog rent type SKU repeat interval
repeatFreqency number required for catalog rent type SKU repeat frequency

Send web tracking data

Use the value obtained from "Initialize tracking session" method in the uid/pid field:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/jsapi/send")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/x-www-form-urlencoded'
    request.body = "appkey=571e64183647a855d0sgf3a3&uid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&uType=c&actionType=visit&requestType=action&aditionalData%5Bbrands%5D%5B0%5D=Zara&aditionalData%5Bbrands%5D%5B1%5D=Adidas&aditionalData%5Btenants%5D%5B0%5D=H%26M&aditionalData%5Btenants%5D%5B1%5D=C%26A"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/jsapi/send",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "appkey=571e64183647a855d0sgf3a3&uid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&uType=c&actionType=visit&requestType=action&aditionalData%5Bbrands%5D%5B0%5D=Zara&aditionalData%5Bbrands%5D%5B1%5D=Adidas&aditionalData%5Btenants%5D%5B0%5D=H%26M&aditionalData%5Btenants%5D%5B1%5D=C%26A",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/x-www-form-urlencoded"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
    --url 'http://{{base_url}}/jsapi/send' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'appkey=571e64183647a855d0sgf3a3&uid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&uType=c&actionType=visit&requestType=action&aditionalData%5Bbrands%5D%5B0%5D=Zara&aditionalData%5Bbrands%5D%5B1%5D=Adidas&aditionalData%5Btenants%5D%5B0%5D=H%26M&aditionalData%5Btenants%5D%5B1%5D=C%26A'
  
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "jsapi",
        "send"
      ],
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ appkey: '571e64183647a855d0sgf3a3',
      uid: 'a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667',
      uType: 'c',
      actionType: 'visit',
      requestType: 'action',
      'aditionalData[brands][0]': 'Zara',
      'aditionalData[brands][1]': 'Adidas',
      'aditionalData[tenants][0]': 'H&M',
      'aditionalData[tenants][1]': 'C&A' }));
    req.end();

The above command returns JSON structured like this:

  {}

This method sends the tracking data for a specific user

Headers

Content-Type application/x-www-form-urlencoded

HTTP Request

POST {{base_url}}/jsapi/send

Body

Parameter Description
appkey application key
uid use the value obtained in Initialize tracking session method (uid/pid value)
uType accepted values: p,c (uType is p if Initialize tracking session returned pid value, uType is c if Initialize tracking session returned uid value)
actionType accepted values: visit,sale,contact,feedback,engagement,profiling
requestType accepted values: action
aditionalData[brands] array with brand names ex: [Zara, Adidas, C&A]; this aditional data should be used only when request type is 'visit'
aditionalData[tenants] array with tenants ex: [H&M]; this aditional data should be used only when request type is 'visit'
aditionalData[interests] array with interests ex: [Beverages,Food]; this aditional data should be used only when request type is 'visit'
aditionalData[receipts] array with receipts; receipt format [name => "tenant name", value=> amount] ex: aditionalData[receipts] = [[name => "C&A",value => 52], [name => "Adidas",value => 322]]; this aditional data should be used only when request type is 'sale'
aditionalData[rating] rating value; a number between 1-10; this aditional data should be used only when request type is 'feedback'
aditionalData[appointmentDate] appointment date; date format YYYY-MM-DD HH:ii:ss; this aditional data should be used only when request type is 'contact'
aditionalData[senderType] accepted values: person,organization; this aditional data should be used only when request type is 'contact'
aditionalData[percentCompleted] profile completion percentage (without "%" symbol); values between 0-100; this aditional data should be used only when request type is 'profiling'
aditionalData[description] string; this aditional data should be used only when request type is 'engagement'

Mobile SDK API

Mobile Tracking Session Initialization


  require 'uri'
  require 'net/http'

  url = URI("http://{{base_url}}/mobileapi/init")

  http = Net::HTTP.new(url.host, url.port)

  request = Net::HTTP::Post.new(url)
  request["Content-Type"] = 'application/json'
  request.body = "appkey=571e64183647a855d0sgf3a3&userEmail=test.email%40test.com"

  response = http.request(request)
  puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/mobileapi/init",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "appkey=571e64183647a855d0sgf3a3&userEmail=test.email%40test.com&pushNotificationToken=123456",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
    --url 'http://{{base_url}}/mobileapi/init' \
    --header 'Content-Type: application/json' \
    --data 'appkey=571e64183647a855d0sgf3a3&userEmail=test.email%40test.com&pushNotificationToken=123456'
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "mobileapi",
        "init"
      ],
      "headers": {
        "Content-Type": "application/json"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ appkey: '571e64183647a855d0sgf3a3',
        userEmail: 'test.email%40test.com', pushNotificationToken: 123456 }));
    req.end();

The above command returns JSON structured like this:

  
{
    "success": true,
    "mobileId": "b38efdc7087731bbef9d6cb050a6aa9bbcb8beb2178ec42afac83eb5e836f050"
}

This method sets up the mobile tracking session for a specific user. Upon a successful response, you will receive a mobileId value, which can be used in subsequent methods to send tracking data.

Headers

Content-Type application/json

HTTP Request

POST {{base_url}}/mobileapi/init

Body

Parameter Description
appkey The application key from the data source
mid Please use the value obtained in Mobile Tracking Session Initialization method (mobileId value)
userEmail The user's email address(optional)
userPhone The user's phone(optional)
pushNotificationToken The Push notification token(optional)
technicalInfo[screenSize] The screen size (widthxheight), string format
technicalInfo[iosAdvertisingId] The iOS Advertising ID
technicalInfo[androidAdvertisingId] The Android Advertising ID
technicalInfo[deviceOs] The device operating system (Windows, Android, iOS ...)
technicalInfo[deviceType] The deviceType field specifies the general category of the device (Smartphone, Tablet ...)

Track Action, Reach and Impression

Use the value obtained from "Mobile Tracking Session Initialization" method in the mobileId field:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/mobileapi/send")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/json'
    request.body = "appkey=571e64183647a855d0sgf3a3&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&actionType=visit&requestType=action&additionalData%5Bbrands%5D%5B0%5D=Zara&additionalData%5Bbrands%5D%5B1%5D=Adidas&additionalData%5Btenants%5D%5B0%5D=H%26M&additionalData%5Btenants%5D%5B1%5D=C%26A"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "http://{{base_url}}/mobileapi/send",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "appkey=571e64183647a855d0sgf3a3&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&actionType=visit&requestType=action&additionalData%5Bbrands%5D%5B0%5D=Zara&additionalData%5Bbrands%5D%5B1%5D=Adidas&additionalData%5Btenants%5D%5B0%5D=H%26M&additionalData%5Btenants%5D%5B1%5D=C%26A",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request POST \
    --url 'http://{{base_url}}/mobileapi/send' \
    --header 'Content-Type: application/json' \
    --data 'appkey=571e64183647a855d0sgf3a3&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&actionType=visit&requestType=action&additionalData%5Bbrands%5D%5B0%5D=Zara&additionalData%5Bbrands%5D%5B1%5D=Adidas&additionalData%5Btenants%5D%5B0%5D=H%26M&additionalData%5Btenants%5D%5B1%5D=C%26A'
  
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "POST",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "mobileapi",
        "send"
      ],
      "headers": {
        "Content-Type": "application/json"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ appkey: '571e64183647a855d0sgf3a3',
      mid: 'a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667',
      actionType: 'visit',
      requestType: 'action',
      'additionalData[brands][0]': 'Zara',
      'additionalData[brands][1]': 'Adidas',
      'additionalData[tenants][0]': 'H&M',
      'additionalData[tenants][1]': 'C&A' }));
    req.end();

The above command returns JSON structured like this:

{
  "success": true,
  "mobileId": "ca8822007fae99db63ff3ed584bda044accb3aa536d79fa40a77c9de3c52ec0d0"
}

This method sends the tracking data for a specific user

Headers

Content-Type application/json

HTTP Request

POST {{base_url}}/mobileapi/send

Body

Parameter Description
appkey application key
mid use the value obtained in Mobile Tracking Session Initialization method (mobileId value)
actionType accepted values: visit,sale,contact,feedback,engagement,profiling
requestType accepted values: action
additionalData[brands] array with brand names ex: [Zara, Adidas, C&A]; this aditional data should be used only when request type is 'visit'
additionalData[tenants] array with tenants ex: [H&M]; this aditional data should be used only when request type is 'visit'
additionalData[interests] array with interests ex: [Beverages,Food]; this aditional data should be used only when request type is 'visit'
additionalData[receipts] array with receipts; receipt format [name => "tenant name", value=> amount] ex: additionalData[receipts] = [[name => "C&A",value => 52], [name => "Adidas",value => 322]]; this aditional data should be used only when request type is 'sale'
additionalData[rating] rating value; a number between 1-10; this aditional data should be used only when request type is 'feedback'
additionalData[appointmentDate] appointment date; date format YYYY-MM-DD HH:ii:ss; this aditional data should be used only when request type is 'contact'
additionalData[senderType] accepted values: person,organization; this aditional data should be used only when request type is 'contact'
additionalData[percentCompleted] profile completion percentage (without "%" symbol); values between 0-100; this aditional data should be used only when request type is 'profiling'
additionalData[description] string; this aditional data should be used only when request type is 'engagement'
additionalData[campaignId] string; use the value from the content-delivery api response for the specific ad
additionalData[adId] string; use the value from the content-delivery api response for the specific ad

Tracking Sensors/BlueTooth

Use the value obtained from "Initialize mobile tracking session" method in the mobileId field:


    require 'uri'
    require 'net/http'

    url = URI("http://{{base_url}}/mobileapi/sensors")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = 'application/json'
    request.body = "appkey=571e64183647a855d0sgf3a3&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&actionType=visit&requestType=action&aditionalData%5Bbrands%5D%5B0%5D=Zara&aditionalData%5Bbrands%5D%5B1%5D=Adidas&aditionalData%5Btenants%5D%5B0%5D=H%26M&aditionalData%5Btenants%5D%5B1%5D=C%26A"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => "{{base_url}}/mobileapi/sensors",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_POSTFIELDS => "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73&sensors%5B0%5D%5Buuid%5D=2376-34342-1233-23424&sensors%5B0%5D%5Brssi%5D=5&sensors%5B0%5D%5Bdistance%5D=4&sensors%5B0%5D%5BmacAddress%5D=345987345345-23482746-345934587&sensors%5B0%5D%5BtxPower%5D=2&sensors%5B0%5D%5Bname%5D=mimi&sensors%5B0%5D%5Bminor%5D=3.2&sensors%5B0%5D%5Bmajor%5D=4.1&sensors%5B1%5D%5Buuid%5D=2376-34342-1233-23422&sensors%5B1%5D%5Brssi%5D=5&sensors%5B1%5D%5Bdistance%5D=44&sensors%5B1%5D%5BmacAddress%5D=345987345345-23482746-345934587&sensors%5B1%5D%5BtxPower%5D=6&sensors%5B1%5D%5Bname%5D=cici&sensors%5B1%5D%5Bminor%5D=1.1&sensors%5B1%5D%5Bmajor%5D=2.2",
    CURLOPT_HTTPHEADER => array(
      "Content-Type: application/json"
    ),
  ));
  
  $response = curl_exec($curl);
  $err = curl_error($curl);
  
  curl_close($curl);
  
  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
    curl --request PUT \
    --url 'http://{{base_url}}/mobileapi/sensors' \
    --header 'Content-Type: application/json' \
    --data 'appkey=571e64183647a855d0sgf3a3&mid=a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667&sensors%5B0%5D%5Buuid%5D=2376-34342-1233-23424&sensors%5B0%5D%5Brssi%5D=5&sensors%5B0%5D%5Bdistance%5D=4&sensors%5B0%5D%5BmacAddress%5D=345987345345-23482746-345934587&sensors%5B0%5D%5BtxPower%5D=2&sensors%5B0%5D%5Bname%5D=mimi&sensors%5B0%5D%5Bminor%5D=3.2&sensors%5B0%5D%5Bmajor%5D=4.1&sensors%5B1%5D%5Buuid%5D=2376-34342-1233-23422&sensors%5B1%5D%5Brssi%5D=5&sensors%5B1%5D%5Bdistance%5D=44&sensors%5B1%5D%5BmacAddress%5D=345987345345-23482746-345934587&sensors%5B1%5D%5BtxPower%5D=6&sensors%5B1%5D%5Bname%5D=cici&sensors%5B1%5D%5Bminor%5D=1.1&sensors%5B1%5D%5Bmajor%5D=2.2'
  
  var qs = require("querystring");
    var http = require("http");
    
    var options = {
      "method": "PUT",
      "hostname": [
        "{{base_url}}"
      ],
      "path": [
        "mobileapi",
        "sensors"
      ],
      "headers": {
        "Content-Type": "application/json"
      }
    };
    
    var req = http.request(options, function (res) {
      var chunks = [];
    
      res.on("data", function (chunk) {
        chunks.push(chunk);
      });
    
      res.on("end", function () {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
      });
    });
    
    req.write(qs.stringify({ appkey: '571e64183647a855d0sgf3a3',
      mid: 'a5c2dd6ebhsgtdr4ca6142a42910a972fecc71aa32ea88a0c681f77395bc218667',
      'sensors[uuid][0]': '4457-7784-5577-6655',
      'sensors[rssi][0]': '5461567',
      'sensors[distance][0]': 22,
      'sensors[txPower][0]': 568,
      'sensors[name][0]': 'Sensor1',
      'sensors[minor][0]': 10.2,
      'sensors[major][0]': 22.3,
      'sensors[macAddress][0]': '00-14-22-01-23-45' }));
    req.end();

The above command returns JSON structured like this:

  {
    "success": true
}

This method sends the tracking data for a group of sensors (beacons)

Headers

Content-Type application/json

HTTP Request

POST {{base_url}}/mobileapi/sensors

Body

Parameter Description
appkey application key
mid use the value obtained in Mobile Tracking Session Initialization method (mobileId value)
sensors[x][uuid] sensor specific attribute
sensors[x][rssi] sensor specific attribute
sensors[x][distance] sensor specific attribute
sensors[x][macAddress] user macAddress
sensors[x][txPower] sensor specific attribute
sensors[x][name] sensor specific attribute
sensors[x][minor] sensor specific attribute
sensors[x][major] sensor specific attribute

Content Delivery

Use the value obtained from "Initialize mobile tracking session" method in the mobileId field:


    require "uri"
    require "net/http"

    url = URI("{{base_url}}/mobileapi/content-delivery")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = "application/json"
    request.body = "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  $curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{base_url}}/mobileapi/content-delivery",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => false,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
    curl --location --request POST "{{base_url}}/mobileapi/content-delivery" \
  --header "Content-Type: application/json" \
  --data "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73"
  
  
  
  var qs = require("querystring");
  var https = require('https');

  var qs = require('querystring');
  
  var options = {
    'method': 'POST',
    'hostname': '{{base_url}}',
    'path': '/mobileapi/content-delivery',
    'headers': {
      'Content-Type': 'application/json'
    }
  };
  
  var req = https.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function (chunk) {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  
    res.on("error", function (error) {
      console.error(error);
    });
  });
  
  var postData = qs.stringify({
    'appkey': '{{username}}',
    'mid': 'p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73'
  });
  
  req.write(postData);
  
  req.end();

The above command returns JSON structured like this:

{
  "success": true,
  "mobileId": "cc69d046e2afb1283392fb2b87b380b824d2346dadf71b9ff91e3ba9b3146ae29",
  "data": {
      "videoAdHorizontalVideo": [
          {
              "adType": "videoAdHorizontalVideo",
              "adId": "61f7b1c1-11ef-8c31-ac31-a15a01957116",
              "title": "Test Title",
              "campaignName": "Test campaign",
              "topMessage": "Test message",
              "contentType": "video",
              "contentUrl": "https://example.com/test.mp4",
              "bottomMessage": "Test message",
              "buttonText": "Click here!",
              "publishDate": "2025-01-08T00:00:00.000Z",
              "expirationDate": "2025-02-08T00:00:00.000Z",
              "campaignId": "61f7b1c1-11ef-8c31-ac31-a15a01957116",
              "linkUrl": "https://www.example.com"
          }
      ],
      "videoAdVerticalVideo": [
         {
              "adType": "videoAdHorizontalVideo",
              "adId": "61f7b1c1-11ef-8c31-ac31-a15a01957116",
              "title": "Test Title",
              "campaignName": "Test campaign",
              "topMessage": "Test message",
              "contentType": "video",
              "contentUrl": "https://example.com/test.mp4",
              "bottomMessage": "Test message",
              "buttonText": "Click here!",
              "publishDate": "2025-01-08T00:00:00.000Z",
              "expirationDate": "2025-02-08T00:00:00.000Z",
              "campaignId": "61f7b1c1-11ef-8c31-ac31-a15a01957116",
              "linkUrl": "https://www.example.com"
          }
      ],
      "leadAd": [],
      "productAd": [],
      "mobileNotifications": [],
      "displayAd": [
          {
              "adType": "videoAdHorizontalVideo",
              "adId": "61f7b1c1-11ef-8c31-ac31-a15a01957116",
              "title": "Test Title",
              "campaignName": "Test campaign",
              "topMessage": "Test message",
              "contentType": "image",
              "contentUrl": "https://example.com/test.jpeg",
              "bottomMessage": "Test message",
              "buttonText": "Click here!",
              "publishDate": "2025-01-08T00:00:00.000Z",
              "expirationDate": "2025-02-08T00:00:00.000Z",
              "campaignId": "61f7b1c1-11ef-8c31-ac31-a15a01957116",
              "linkUrl": "https://www.example.com"
          }
      ]
  }
}

This method fetch the active campaign's content delivery

Headers

Content-Type application/json

HTTP Request

POST {{base_url}}/mobileapi/content-delivery

Body

Parameter Description
appkey application key
mid use the value obtained in Mobile Tracking Session Initialization method (mobileId value)

Tracking Geolocation

Use the value obtained from "Initialize mobile tracking session" method in the mobileId field:


    require "uri"
    require "net/http"

    url = URI("{{base_url}}/mobileapi/geo")

    http = Net::HTTP.new(url.host, url.port)

    request = Net::HTTP::Put.new(url)
    request["Content-Type"] = "application/json"
    request.body = "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73&lat=44.432149&lon=26.088868&accuracy=3"

    response = http.request(request)
    puts response.read_body
   $curl = curl_init();
  
  $curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{{base_url}}/mobileapi/geo",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => false,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73&lat=44.432149&lon=26.088868&accuracy=3",
  CURLOPT_HTTPHEADER => array(
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
    curl --location --request PUT "{{base_url}}/mobileapi/geo" \
  --header "Content-Type: application/json" \
  --data "appkey={{username}}&mid=p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73&lat=44.432149&lon=26.088868&accuracy=3"
  
  
  
  var qs = require("querystring");
  var https = require('https');

  var qs = require('querystring');
  
  var options = {
    'method': 'PUT',
    'hostname': '{{base_url}}',
    'path': '/mobileapi/geo',
    'headers': {
      'Content-Type': 'application/json'
    }
  };
  
  var req = https.request(options, function (res) {
    var chunks = [];
  
    res.on("data", function (chunk) {
      chunks.push(chunk);
    });
  
    res.on("end", function (chunk) {
      var body = Buffer.concat(chunks);
      console.log(body.toString());
    });
  
    res.on("error", function (error) {
      console.error(error);
    });
  });
  
  var postData = qs.stringify({
    'appkey': '{{username}}',
    'mid': 'p93eeea7322fed62b9b240d613b6c925b1cf125aed3bf030c64d8a51b35981c73',
    'lat': '44.432149',
    'lon': '26.088868',
    'accuracy': '3'
  });
  
  req.write(postData);
  
  req.end();

The above command returns JSON structured like this:

{
  "success": true,
  "mobileId": "ca8822007fae99db63ff3ed584bda044accb3aa536d79fa40a77c9de3c52ec0d0"
}

This method sends geolocation data

Headers

Content-Type application/json

HTTP Request

PUT {{base_url}}/mobileapi/geo

Body

Parameter Description
appkey application key
mid use the value obtained in Mobile Tracking Session Initialization method (mobileId value)
lat latitude
lon longitude
accuracy accuracy

JavaScript library

Initialize JavaScript tracking SDK

Integrate this Code:



  // You will need to use your App Key and integrate the following script into the section of the new data source

  <script> 
    (function (d, s, id) {

      var js, ojs = d.getElementsByTagName(s)[0];

      if (d.getElementById(id))
            {return;} 
        js = d.createElement(s); js.id = id; js.async=!0; 
        js.src ="{{base_url}}/jsapi/omnichannel.js";
        ojs.parentNode.insertBefore(js, ojs); 

    } (document, 'script', 'omnichanneltrack'));
  </script>

    // You will need to add the following JavaScript code snippet before closing the section of the new data source:

    <script>
      (function (d, s, id) { 

        var js, ojs = d.getElementsByTagName(s)[0]; 

        if (d.getElementById(id)) 
              {return;} 

        js = d.createElement(s); js.id = id; js.async=!0; 
        js.src ="{{base_url}}/jsapi/omnichannel.js";
        ojs.parentNode.insertBefore(js, ojs);
        } (document, 'script', 'omnichanneltrack'));
    </script>

The above command returns JSON structured like this:

  

Our JavaScript tracking code is capable to cover any types of data your project might generate and could benefit the purpose for which Footprints is used in your organization. Like what is the medium your user is coming from, what is a specific user doing onto your digital property, how they engage with various elements of your digital property or collecting and validating any data that the user would fill in any form.

The following tracking code must be implemented in the source code of each of the beneficiaries properties.

Step 1

For each individual data source (digital property) a data source must be configured by going into Settings > Data Sources > Create New Data Source. By doing so, you will be able to create an active source of data for your application and get the necessary credentials for further integrations (the App Key and the App Secret would be generated at this stage).

Step 2

You will need to use your App Key and integrate the following script into the section of the new data source

<script>
var ochnkey='<key>';
function ochntrack() {
ochn.init();
}</script>

Step 3

You will need to add the following JavaScript code snippet before closing the section of the new data source:

<script>
(function (d, s, id) {
var js, ojs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id; js.async=!0;
js.src ="{{base_url}}/jsapi/omnichannel.js"; ojs.parentNode.insertBefore(js, ojs);
} (document, 'script', 'omnichanneltrack'));
</script>

Setup guidelines



 
 

 


ochnkey is represented by the App Key for the corresponding data source (declared in Footprints > Account Settings > Data Sources). Both, the js ochntrack() function and the call code for the omnichannel.js file will be declared in all the pages.

• Inside the ontrack () function we have the method for initializing the tracking instance ochn.init (present on all pages) It can be accessed simply by ochn.init () in case the user is not logged in or ochn.init ('example@test.com') for the logged in user. Sending information regarding the newly accessed page is done through ochn.send ('action','visit', <object_date_additional>)