curl --request POST \
--url https://live.copilot.fabric.inc/v1/promo/evaluate-promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"items": [
{
"priceList": 100275,
"quantity": 5,
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"hierarchy": [
[
"clothingId1",
"footwear",
"sandalsId1"
],
[
"nike",
"sandalsId2"
],
[
"clothingId2",
"beach"
]
],
"productAttributes": {
"color": [
"red",
"green"
],
"brand": "Nike",
"size": "10"
},
"priceParams": {
"options": {
"length": "2",
"width": "15",
"blindMotor": true
}
},
"price": {
"sale": 10,
"base": 123
},
"channel": [
12,
15
],
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"traceId": "394823457",
"isLoggedIn": true,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": [
"SUPERCOUPON1",
"FIRSTPURCHASE10"
],
"shipping": [
{
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"date": "2019-08-24T14:15:22Z",
"userProfile": {
"Customer Type": [
"Wholesale"
]
}
}
'import requests
url = "https://live.copilot.fabric.inc/v1/promo/evaluate-promotions"
payload = {
"items": [
{
"priceList": 100275,
"quantity": 5,
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"group": ["5e2cfb9b45570b000863c4b5"],
"hierarchy": [["clothingId1", "footwear", "sandalsId1"], ["nike", "sandalsId2"], ["clothingId2", "beach"]],
"productAttributes": {
"color": ["red", "green"],
"brand": "Nike",
"size": "10"
},
"priceParams": { "options": {
"length": "2",
"width": "15",
"blindMotor": True
} },
"price": {
"sale": 10,
"base": 123
},
"channel": [12, 15],
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"traceId": "394823457",
"isLoggedIn": True,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": ["SUPERCOUPON1", "FIRSTPURCHASE10"],
"shipping": [
{
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"date": "2019-08-24T14:15:22Z",
"userProfile": { "Customer Type": ["Wholesale"] }
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
items: [
{
priceList: 100275,
quantity: 5,
lineItemId: 1,
sku: 1111111,
itemId: 1111111,
group: ['5e2cfb9b45570b000863c4b5'],
hierarchy: [
['clothingId1', 'footwear', 'sandalsId1'],
['nike', 'sandalsId2'],
['clothingId2', 'beach']
],
productAttributes: {color: ['red', 'green'], brand: 'Nike', size: '10'},
priceParams: {options: {length: '2', width: '15', blindMotor: true}},
price: {sale: 10, base: 123},
channel: [12, 15],
shippingMethodId: 123,
shippingPrice: 20
}
],
traceId: '394823457',
isLoggedIn: true,
userId: '5e2cfb9b45570b000864c4b5',
promoCodes: ['SUPERCOUPON1', 'FIRSTPURCHASE10'],
shipping: [{shippingMethodId: 123, shippingPrice: 20}],
date: '2019-08-24T14:15:22Z',
userProfile: {'Customer Type': ['Wholesale']}
})
};
fetch('https://live.copilot.fabric.inc/v1/promo/evaluate-promotions', 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://live.copilot.fabric.inc/v1/promo/evaluate-promotions",
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([
'items' => [
[
'priceList' => 100275,
'quantity' => 5,
'lineItemId' => 1,
'sku' => 1111111,
'itemId' => 1111111,
'group' => [
'5e2cfb9b45570b000863c4b5'
],
'hierarchy' => [
[
'clothingId1',
'footwear',
'sandalsId1'
],
[
'nike',
'sandalsId2'
],
[
'clothingId2',
'beach'
]
],
'productAttributes' => [
'color' => [
'red',
'green'
],
'brand' => 'Nike',
'size' => '10'
],
'priceParams' => [
'options' => [
'length' => '2',
'width' => '15',
'blindMotor' => true
]
],
'price' => [
'sale' => 10,
'base' => 123
],
'channel' => [
12,
15
],
'shippingMethodId' => 123,
'shippingPrice' => 20
]
],
'traceId' => '394823457',
'isLoggedIn' => true,
'userId' => '5e2cfb9b45570b000864c4b5',
'promoCodes' => [
'SUPERCOUPON1',
'FIRSTPURCHASE10'
],
'shipping' => [
[
'shippingMethodId' => 123,
'shippingPrice' => 20
]
],
'date' => '2019-08-24T14:15:22Z',
'userProfile' => [
'Customer Type' => [
'Wholesale'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$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://live.copilot.fabric.inc/v1/promo/evaluate-promotions"
payload := strings.NewReader("{\n \"items\": [\n {\n \"priceList\": 100275,\n \"quantity\": 5,\n \"lineItemId\": 1,\n \"sku\": 1111111,\n \"itemId\": 1111111,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"hierarchy\": [\n [\n \"clothingId1\",\n \"footwear\",\n \"sandalsId1\"\n ],\n [\n \"nike\",\n \"sandalsId2\"\n ],\n [\n \"clothingId2\",\n \"beach\"\n ]\n ],\n \"productAttributes\": {\n \"color\": [\n \"red\",\n \"green\"\n ],\n \"brand\": \"Nike\",\n \"size\": \"10\"\n },\n \"priceParams\": {\n \"options\": {\n \"length\": \"2\",\n \"width\": \"15\",\n \"blindMotor\": true\n }\n },\n \"price\": {\n \"sale\": 10,\n \"base\": 123\n },\n \"channel\": [\n 12,\n 15\n ],\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"traceId\": \"394823457\",\n \"isLoggedIn\": true,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"SUPERCOUPON1\",\n \"FIRSTPURCHASE10\"\n ],\n \"shipping\": [\n {\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"date\": \"2019-08-24T14:15:22Z\",\n \"userProfile\": {\n \"Customer Type\": [\n \"Wholesale\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
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://live.copilot.fabric.inc/v1/promo/evaluate-promotions")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"priceList\": 100275,\n \"quantity\": 5,\n \"lineItemId\": 1,\n \"sku\": 1111111,\n \"itemId\": 1111111,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"hierarchy\": [\n [\n \"clothingId1\",\n \"footwear\",\n \"sandalsId1\"\n ],\n [\n \"nike\",\n \"sandalsId2\"\n ],\n [\n \"clothingId2\",\n \"beach\"\n ]\n ],\n \"productAttributes\": {\n \"color\": [\n \"red\",\n \"green\"\n ],\n \"brand\": \"Nike\",\n \"size\": \"10\"\n },\n \"priceParams\": {\n \"options\": {\n \"length\": \"2\",\n \"width\": \"15\",\n \"blindMotor\": true\n }\n },\n \"price\": {\n \"sale\": 10,\n \"base\": 123\n },\n \"channel\": [\n 12,\n 15\n ],\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"traceId\": \"394823457\",\n \"isLoggedIn\": true,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"SUPERCOUPON1\",\n \"FIRSTPURCHASE10\"\n ],\n \"shipping\": [\n {\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"date\": \"2019-08-24T14:15:22Z\",\n \"userProfile\": {\n \"Customer Type\": [\n \"Wholesale\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://live.copilot.fabric.inc/v1/promo/evaluate-promotions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"priceList\": 100275,\n \"quantity\": 5,\n \"lineItemId\": 1,\n \"sku\": 1111111,\n \"itemId\": 1111111,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"hierarchy\": [\n [\n \"clothingId1\",\n \"footwear\",\n \"sandalsId1\"\n ],\n [\n \"nike\",\n \"sandalsId2\"\n ],\n [\n \"clothingId2\",\n \"beach\"\n ]\n ],\n \"productAttributes\": {\n \"color\": [\n \"red\",\n \"green\"\n ],\n \"brand\": \"Nike\",\n \"size\": \"10\"\n },\n \"priceParams\": {\n \"options\": {\n \"length\": \"2\",\n \"width\": \"15\",\n \"blindMotor\": true\n }\n },\n \"price\": {\n \"sale\": 10,\n \"base\": 123\n },\n \"channel\": [\n 12,\n 15\n ],\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"traceId\": \"394823457\",\n \"isLoggedIn\": true,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"SUPERCOUPON1\",\n \"FIRSTPURCHASE10\"\n ],\n \"shipping\": [\n {\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"date\": \"2019-08-24T14:15:22Z\",\n \"userProfile\": {\n \"Customer Type\": [\n \"Wholesale\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body[
{
"items": [
{
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"priceList": 100275,
"group": [
"5e2cfb9b45570b000863c4b5",
"clothingId1",
"footwear"
],
"quantity": 5,
"price": {
"currency": "USD",
"base": 10,
"kind": "BASE",
"totalPrice": 50,
"finalPrice": 50,
"sale": 50
},
"priceAttributes": {
"cost": 9,
"floor": 10,
"clearance": 10
},
"discount": [
{
"quantity": 5,
"amount": 10,
"unit": "%OFF",
"value": 10,
"promoId": "6197ec46e836ff000952c668",
"promoCode": "SUPERCOUPON20",
"promoTitle": "20% off",
"type": "COUPON",
"application": 1,
"isStackable": true,
"isAlwaysApplied": false,
"level": 1,
"stackingType": "STACKABLE",
"proratedAmount": 10,
"proratedQuantity": 1
}
],
"attributes": {
"color": "red",
"brand": "Nike",
"size": "10"
},
"shippingPrice": 20,
"shippingMethodId": 123,
"shippingDiscount": 5
}
],
"errors": [
"Parameter does not exist"
],
"shipping": [
{
"shippingMethodId": 456,
"shippingPrice": 5,
"shippingDiscount": 5
}
],
"appliedDiscounts": [
{
"promoId": "6197ec46e836ff000952c668",
"promoCode": "SUPERCOUPON20",
"promoTitle": "20% off",
"type": "COUPON",
"amount": 10
}
],
"suggestedProducts": [
{
"promotionId": "6197ec46e836ff000952c668",
"promotionTitle": "Buy Shoes, get socks for free",
"itemId": 234343,
"sku": "SHOE1234",
"eligiblePriceLists": [
1000
],
"quantity": 2,
"free": true,
"discountType": "%OFF",
"amount": 100
}
],
"notAppliedCoupons": [
{
"promoCode": "SUPERCOUPON",
"promoId": "624b5aa2a8fd12000965dfdc",
"message": "Invalid coupon"
}
],
"promotionMessages": [
{
"promoId": "61df12345678900009b7091c",
"title": "Buy 2 get 1 free",
"message": "Offer valid at participating stores through September 5, 2023.",
"pages": [
"PDP"
],
"locales": [
"en-CA"
],
"type": "DISCOUNT",
"threshold": 2
}
],
"success": true
}
]{
"status": "NOT_FOUND",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Validation error",
"debugMessage": "Either item ID or SKU is mandatory.",
"subErrors": [
{
"object": "promotionsEvaluationRequest",
"field": "items[0].quantity",
"rejectedValue": -2,
"message": "Must be greater than 0"
}
]
}{
"status": "NOT_FOUND",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Validation error",
"debugMessage": "Either item ID or SKU is mandatory.",
"subErrors": [
{
"object": "promotionsEvaluationRequest",
"field": "items[0].quantity",
"rejectedValue": -2,
"message": "Must be greater than 0"
}
]
}{
"status": "NOT_FOUND",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Validation error",
"debugMessage": "Either item ID or SKU is mandatory.",
"subErrors": [
{
"object": "promotionsEvaluationRequest",
"field": "items[0].quantity",
"rejectedValue": -2,
"message": "Must be greater than 0"
}
]
}{
"status": "NOT_FOUND",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Validation error",
"debugMessage": "Either item ID or SKU is mandatory.",
"subErrors": [
{
"object": "promotionsEvaluationRequest",
"field": "items[0].quantity",
"rejectedValue": -2,
"message": "Must be greater than 0"
}
]
}Evaluate promotions
Evaluates a cart’s promotions, discount coupons and implicit promotions, either by specified itemId or by SKU (based on the customer specific configuration set in the backend)
curl --request POST \
--url https://live.copilot.fabric.inc/v1/promo/evaluate-promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"items": [
{
"priceList": 100275,
"quantity": 5,
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"hierarchy": [
[
"clothingId1",
"footwear",
"sandalsId1"
],
[
"nike",
"sandalsId2"
],
[
"clothingId2",
"beach"
]
],
"productAttributes": {
"color": [
"red",
"green"
],
"brand": "Nike",
"size": "10"
},
"priceParams": {
"options": {
"length": "2",
"width": "15",
"blindMotor": true
}
},
"price": {
"sale": 10,
"base": 123
},
"channel": [
12,
15
],
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"traceId": "394823457",
"isLoggedIn": true,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": [
"SUPERCOUPON1",
"FIRSTPURCHASE10"
],
"shipping": [
{
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"date": "2019-08-24T14:15:22Z",
"userProfile": {
"Customer Type": [
"Wholesale"
]
}
}
'import requests
url = "https://live.copilot.fabric.inc/v1/promo/evaluate-promotions"
payload = {
"items": [
{
"priceList": 100275,
"quantity": 5,
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"group": ["5e2cfb9b45570b000863c4b5"],
"hierarchy": [["clothingId1", "footwear", "sandalsId1"], ["nike", "sandalsId2"], ["clothingId2", "beach"]],
"productAttributes": {
"color": ["red", "green"],
"brand": "Nike",
"size": "10"
},
"priceParams": { "options": {
"length": "2",
"width": "15",
"blindMotor": True
} },
"price": {
"sale": 10,
"base": 123
},
"channel": [12, 15],
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"traceId": "394823457",
"isLoggedIn": True,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": ["SUPERCOUPON1", "FIRSTPURCHASE10"],
"shipping": [
{
"shippingMethodId": 123,
"shippingPrice": 20
}
],
"date": "2019-08-24T14:15:22Z",
"userProfile": { "Customer Type": ["Wholesale"] }
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
items: [
{
priceList: 100275,
quantity: 5,
lineItemId: 1,
sku: 1111111,
itemId: 1111111,
group: ['5e2cfb9b45570b000863c4b5'],
hierarchy: [
['clothingId1', 'footwear', 'sandalsId1'],
['nike', 'sandalsId2'],
['clothingId2', 'beach']
],
productAttributes: {color: ['red', 'green'], brand: 'Nike', size: '10'},
priceParams: {options: {length: '2', width: '15', blindMotor: true}},
price: {sale: 10, base: 123},
channel: [12, 15],
shippingMethodId: 123,
shippingPrice: 20
}
],
traceId: '394823457',
isLoggedIn: true,
userId: '5e2cfb9b45570b000864c4b5',
promoCodes: ['SUPERCOUPON1', 'FIRSTPURCHASE10'],
shipping: [{shippingMethodId: 123, shippingPrice: 20}],
date: '2019-08-24T14:15:22Z',
userProfile: {'Customer Type': ['Wholesale']}
})
};
fetch('https://live.copilot.fabric.inc/v1/promo/evaluate-promotions', 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://live.copilot.fabric.inc/v1/promo/evaluate-promotions",
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([
'items' => [
[
'priceList' => 100275,
'quantity' => 5,
'lineItemId' => 1,
'sku' => 1111111,
'itemId' => 1111111,
'group' => [
'5e2cfb9b45570b000863c4b5'
],
'hierarchy' => [
[
'clothingId1',
'footwear',
'sandalsId1'
],
[
'nike',
'sandalsId2'
],
[
'clothingId2',
'beach'
]
],
'productAttributes' => [
'color' => [
'red',
'green'
],
'brand' => 'Nike',
'size' => '10'
],
'priceParams' => [
'options' => [
'length' => '2',
'width' => '15',
'blindMotor' => true
]
],
'price' => [
'sale' => 10,
'base' => 123
],
'channel' => [
12,
15
],
'shippingMethodId' => 123,
'shippingPrice' => 20
]
],
'traceId' => '394823457',
'isLoggedIn' => true,
'userId' => '5e2cfb9b45570b000864c4b5',
'promoCodes' => [
'SUPERCOUPON1',
'FIRSTPURCHASE10'
],
'shipping' => [
[
'shippingMethodId' => 123,
'shippingPrice' => 20
]
],
'date' => '2019-08-24T14:15:22Z',
'userProfile' => [
'Customer Type' => [
'Wholesale'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$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://live.copilot.fabric.inc/v1/promo/evaluate-promotions"
payload := strings.NewReader("{\n \"items\": [\n {\n \"priceList\": 100275,\n \"quantity\": 5,\n \"lineItemId\": 1,\n \"sku\": 1111111,\n \"itemId\": 1111111,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"hierarchy\": [\n [\n \"clothingId1\",\n \"footwear\",\n \"sandalsId1\"\n ],\n [\n \"nike\",\n \"sandalsId2\"\n ],\n [\n \"clothingId2\",\n \"beach\"\n ]\n ],\n \"productAttributes\": {\n \"color\": [\n \"red\",\n \"green\"\n ],\n \"brand\": \"Nike\",\n \"size\": \"10\"\n },\n \"priceParams\": {\n \"options\": {\n \"length\": \"2\",\n \"width\": \"15\",\n \"blindMotor\": true\n }\n },\n \"price\": {\n \"sale\": 10,\n \"base\": 123\n },\n \"channel\": [\n 12,\n 15\n ],\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"traceId\": \"394823457\",\n \"isLoggedIn\": true,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"SUPERCOUPON1\",\n \"FIRSTPURCHASE10\"\n ],\n \"shipping\": [\n {\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"date\": \"2019-08-24T14:15:22Z\",\n \"userProfile\": {\n \"Customer Type\": [\n \"Wholesale\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
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://live.copilot.fabric.inc/v1/promo/evaluate-promotions")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"priceList\": 100275,\n \"quantity\": 5,\n \"lineItemId\": 1,\n \"sku\": 1111111,\n \"itemId\": 1111111,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"hierarchy\": [\n [\n \"clothingId1\",\n \"footwear\",\n \"sandalsId1\"\n ],\n [\n \"nike\",\n \"sandalsId2\"\n ],\n [\n \"clothingId2\",\n \"beach\"\n ]\n ],\n \"productAttributes\": {\n \"color\": [\n \"red\",\n \"green\"\n ],\n \"brand\": \"Nike\",\n \"size\": \"10\"\n },\n \"priceParams\": {\n \"options\": {\n \"length\": \"2\",\n \"width\": \"15\",\n \"blindMotor\": true\n }\n },\n \"price\": {\n \"sale\": 10,\n \"base\": 123\n },\n \"channel\": [\n 12,\n 15\n ],\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"traceId\": \"394823457\",\n \"isLoggedIn\": true,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"SUPERCOUPON1\",\n \"FIRSTPURCHASE10\"\n ],\n \"shipping\": [\n {\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"date\": \"2019-08-24T14:15:22Z\",\n \"userProfile\": {\n \"Customer Type\": [\n \"Wholesale\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://live.copilot.fabric.inc/v1/promo/evaluate-promotions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"priceList\": 100275,\n \"quantity\": 5,\n \"lineItemId\": 1,\n \"sku\": 1111111,\n \"itemId\": 1111111,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"hierarchy\": [\n [\n \"clothingId1\",\n \"footwear\",\n \"sandalsId1\"\n ],\n [\n \"nike\",\n \"sandalsId2\"\n ],\n [\n \"clothingId2\",\n \"beach\"\n ]\n ],\n \"productAttributes\": {\n \"color\": [\n \"red\",\n \"green\"\n ],\n \"brand\": \"Nike\",\n \"size\": \"10\"\n },\n \"priceParams\": {\n \"options\": {\n \"length\": \"2\",\n \"width\": \"15\",\n \"blindMotor\": true\n }\n },\n \"price\": {\n \"sale\": 10,\n \"base\": 123\n },\n \"channel\": [\n 12,\n 15\n ],\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"traceId\": \"394823457\",\n \"isLoggedIn\": true,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"SUPERCOUPON1\",\n \"FIRSTPURCHASE10\"\n ],\n \"shipping\": [\n {\n \"shippingMethodId\": 123,\n \"shippingPrice\": 20\n }\n ],\n \"date\": \"2019-08-24T14:15:22Z\",\n \"userProfile\": {\n \"Customer Type\": [\n \"Wholesale\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body[
{
"items": [
{
"lineItemId": 1,
"sku": 1111111,
"itemId": 1111111,
"priceList": 100275,
"group": [
"5e2cfb9b45570b000863c4b5",
"clothingId1",
"footwear"
],
"quantity": 5,
"price": {
"currency": "USD",
"base": 10,
"kind": "BASE",
"totalPrice": 50,
"finalPrice": 50,
"sale": 50
},
"priceAttributes": {
"cost": 9,
"floor": 10,
"clearance": 10
},
"discount": [
{
"quantity": 5,
"amount": 10,
"unit": "%OFF",
"value": 10,
"promoId": "6197ec46e836ff000952c668",
"promoCode": "SUPERCOUPON20",
"promoTitle": "20% off",
"type": "COUPON",
"application": 1,
"isStackable": true,
"isAlwaysApplied": false,
"level": 1,
"stackingType": "STACKABLE",
"proratedAmount": 10,
"proratedQuantity": 1
}
],
"attributes": {
"color": "red",
"brand": "Nike",
"size": "10"
},
"shippingPrice": 20,
"shippingMethodId": 123,
"shippingDiscount": 5
}
],
"errors": [
"Parameter does not exist"
],
"shipping": [
{
"shippingMethodId": 456,
"shippingPrice": 5,
"shippingDiscount": 5
}
],
"appliedDiscounts": [
{
"promoId": "6197ec46e836ff000952c668",
"promoCode": "SUPERCOUPON20",
"promoTitle": "20% off",
"type": "COUPON",
"amount": 10
}
],
"suggestedProducts": [
{
"promotionId": "6197ec46e836ff000952c668",
"promotionTitle": "Buy Shoes, get socks for free",
"itemId": 234343,
"sku": "SHOE1234",
"eligiblePriceLists": [
1000
],
"quantity": 2,
"free": true,
"discountType": "%OFF",
"amount": 100
}
],
"notAppliedCoupons": [
{
"promoCode": "SUPERCOUPON",
"promoId": "624b5aa2a8fd12000965dfdc",
"message": "Invalid coupon"
}
],
"promotionMessages": [
{
"promoId": "61df12345678900009b7091c",
"title": "Buy 2 get 1 free",
"message": "Offer valid at participating stores through September 5, 2023.",
"pages": [
"PDP"
],
"locales": [
"en-CA"
],
"type": "DISCOUNT",
"threshold": 2
}
],
"success": true
}
]{
"status": "NOT_FOUND",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Validation error",
"debugMessage": "Either item ID or SKU is mandatory.",
"subErrors": [
{
"object": "promotionsEvaluationRequest",
"field": "items[0].quantity",
"rejectedValue": -2,
"message": "Must be greater than 0"
}
]
}{
"status": "NOT_FOUND",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Validation error",
"debugMessage": "Either item ID or SKU is mandatory.",
"subErrors": [
{
"object": "promotionsEvaluationRequest",
"field": "items[0].quantity",
"rejectedValue": -2,
"message": "Must be greater than 0"
}
]
}{
"status": "NOT_FOUND",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Validation error",
"debugMessage": "Either item ID or SKU is mandatory.",
"subErrors": [
{
"object": "promotionsEvaluationRequest",
"field": "items[0].quantity",
"rejectedValue": -2,
"message": "Must be greater than 0"
}
]
}{
"status": "NOT_FOUND",
"timestamp": "2023-11-07T05:31:56Z",
"message": "Validation error",
"debugMessage": "Either item ID or SKU is mandatory.",
"subErrors": [
{
"object": "promotionsEvaluationRequest",
"field": "items[0].quantity",
"rejectedValue": -2,
"message": "Must be greater than 0"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
The x-site-context header is a JSON object that contains information about the source you wish to pull from. The mandatory account is the 24 character identifier found in Copilot. The channel (Sales channel ID), stage (environment name), and date attributes can be used to further narrow the scope of your data source.
"{\"date\": \"2023-01-01T00:00:00.000Z\", \"channel\": 12, \"account\": \"1234abcd5678efgh9ijklmno\",\"stage\":\"production\"}"
Body
Prices conditions
List of item information objects
Show child attributes
Show child attributes
Trace ID, used to trace logs
"394823457"
true: user logged in
false: user is not logged in
true
User ID
"5e2cfb9b45570b000864c4b5"
A list of coupon codes that are applicable only for coupons. For coupons, the response includes promo codes associated with the coupon. For promotions, the response includes an empty array.
["SUPERCOUPON1", "FIRSTPURCHASE10"]Shipping cost for the entire cart. You can use this shipping array if you want to add shipping cost for the entire cart.
If you want to add shipping cost for individual items, you can provide details for each item using items.shippingMethodId and items.shippingPrice fields.
Show child attributes
Show child attributes
Date for which the promotions to be evaluated
yyyy-MM-ddThh:mm:ssZ"2019-08-24T14:15:22Z"
Segment the user belongs to
Show child attributes
Show child attributes
{ "Customer Type": ["Wholesale"] }Response
Successfully evaluated the promotions
Show child attributes
Show child attributes
["Parameter does not exist"]Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
The promotion message that is displayed to the customer.
Show child attributes
Show child attributes
Indicates if promotion is successfully evaluated
Was this page helpful?
