Send event
curl --request POST \
--url https://fit.kleep.ai/v1/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Kleep-Retailer: <kleep-retailer>' \
--data '
{
"type": "added_to_cart",
"recommendation_id": "rec_7Hq2mV9xKp",
"variant_id": "JEAN-0142-M",
"conversation_id": "conv_5521"
}
'import requests
url = "https://fit.kleep.ai/v1/events"
payload = {
"type": "added_to_cart",
"recommendation_id": "rec_7Hq2mV9xKp",
"variant_id": "JEAN-0142-M",
"conversation_id": "conv_5521"
}
headers = {
"Kleep-Retailer": "<kleep-retailer>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Kleep-Retailer': '<kleep-retailer>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'added_to_cart',
recommendation_id: 'rec_7Hq2mV9xKp',
variant_id: 'JEAN-0142-M',
conversation_id: 'conv_5521'
})
};
fetch('https://fit.kleep.ai/v1/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://fit.kleep.ai/v1/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => 'added_to_cart',
'recommendation_id' => 'rec_7Hq2mV9xKp',
'variant_id' => 'JEAN-0142-M',
'conversation_id' => 'conv_5521'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Kleep-Retailer: <kleep-retailer>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://fit.kleep.ai/v1/events"
payload := strings.NewReader("{\n \"type\": \"added_to_cart\",\n \"recommendation_id\": \"rec_7Hq2mV9xKp\",\n \"variant_id\": \"JEAN-0142-M\",\n \"conversation_id\": \"conv_5521\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Kleep-Retailer", "<kleep-retailer>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://fit.kleep.ai/v1/events")
.header("Kleep-Retailer", "<kleep-retailer>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"added_to_cart\",\n \"recommendation_id\": \"rec_7Hq2mV9xKp\",\n \"variant_id\": \"JEAN-0142-M\",\n \"conversation_id\": \"conv_5521\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://fit.kleep.ai/v1/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Kleep-Retailer"] = '<kleep-retailer>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"added_to_cart\",\n \"recommendation_id\": \"rec_7Hq2mV9xKp\",\n \"variant_id\": \"JEAN-0142-M\",\n \"conversation_id\": \"conv_5521\"\n}"
response = http.request(request)
puts response.read_body{
"error": {
"code": "invalid_input",
"message": "Unknown event type"
}
}{
"error": {
"code": "unauthorized",
"message": "Invalid API key"
}
}{
"error": {
"code": "retailer_not_enabled",
"message": "Retailer 9b1f… has not enabled this partner"
}
}{
"error": {
"code": "rate_limited",
"message": "Too many requests"
}
}Partner API reference
Send event
Report what happened after a recommendation so the retailer sees the chat’s impact in the Kleep dashboard: shown, added to cart, ordered.
POST
/
events
Send event
curl --request POST \
--url https://fit.kleep.ai/v1/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Kleep-Retailer: <kleep-retailer>' \
--data '
{
"type": "added_to_cart",
"recommendation_id": "rec_7Hq2mV9xKp",
"variant_id": "JEAN-0142-M",
"conversation_id": "conv_5521"
}
'import requests
url = "https://fit.kleep.ai/v1/events"
payload = {
"type": "added_to_cart",
"recommendation_id": "rec_7Hq2mV9xKp",
"variant_id": "JEAN-0142-M",
"conversation_id": "conv_5521"
}
headers = {
"Kleep-Retailer": "<kleep-retailer>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Kleep-Retailer': '<kleep-retailer>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'added_to_cart',
recommendation_id: 'rec_7Hq2mV9xKp',
variant_id: 'JEAN-0142-M',
conversation_id: 'conv_5521'
})
};
fetch('https://fit.kleep.ai/v1/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://fit.kleep.ai/v1/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'type' => 'added_to_cart',
'recommendation_id' => 'rec_7Hq2mV9xKp',
'variant_id' => 'JEAN-0142-M',
'conversation_id' => 'conv_5521'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"Kleep-Retailer: <kleep-retailer>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://fit.kleep.ai/v1/events"
payload := strings.NewReader("{\n \"type\": \"added_to_cart\",\n \"recommendation_id\": \"rec_7Hq2mV9xKp\",\n \"variant_id\": \"JEAN-0142-M\",\n \"conversation_id\": \"conv_5521\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Kleep-Retailer", "<kleep-retailer>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://fit.kleep.ai/v1/events")
.header("Kleep-Retailer", "<kleep-retailer>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"type\": \"added_to_cart\",\n \"recommendation_id\": \"rec_7Hq2mV9xKp\",\n \"variant_id\": \"JEAN-0142-M\",\n \"conversation_id\": \"conv_5521\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://fit.kleep.ai/v1/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Kleep-Retailer"] = '<kleep-retailer>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"type\": \"added_to_cart\",\n \"recommendation_id\": \"rec_7Hq2mV9xKp\",\n \"variant_id\": \"JEAN-0142-M\",\n \"conversation_id\": \"conv_5521\"\n}"
response = http.request(request)
puts response.read_body{
"error": {
"code": "invalid_input",
"message": "Unknown event type"
}
}{
"error": {
"code": "unauthorized",
"message": "Invalid API key"
}
}{
"error": {
"code": "retailer_not_enabled",
"message": "Retailer 9b1f… has not enabled this partner"
}
}{
"error": {
"code": "rate_limited",
"message": "Too many requests"
}
}Authorizations
Your partner API key: kp_live_… in production, kp_test_… on the sandbox retailer.
Headers
The retailer's Kleep public_id. Every call is scoped to one retailer.
Body
application/json
Available options:
recommendation_shown, added_to_cart, order_placed added_to_cart and order_placed: the variant bought.
order_placed: the retailer's order ID.
Defaults to the time Kleep receives the event.
Response
Accepted.
