curl --request POST \
--url https://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"items": [
{
"itemId": 1000000119,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"quantity": 3,
"price": {
"base": 1000,
"sale": 0,
"currency": "USD"
},
"lineItemId": 1,
"sku": "SKU0001"
}
],
"isLoggedIn": false,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": [
"300DOFF"
]
}
'import requests
url = "https://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate"
payload = {
"items": [
{
"itemId": 1000000119,
"group": ["5e2cfb9b45570b000863c4b5"],
"quantity": 3,
"price": {
"base": 1000,
"sale": 0,
"currency": "USD"
},
"lineItemId": 1,
"sku": "SKU0001"
}
],
"isLoggedIn": False,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": ["300DOFF"]
}
headers = {
"x-site-context": "<x-site-context>",
"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>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
itemId: 1000000119,
group: ['5e2cfb9b45570b000863c4b5'],
quantity: 3,
price: {base: 1000, sale: 0, currency: 'USD'},
lineItemId: 1,
sku: 'SKU0001'
}
],
isLoggedIn: false,
userId: '5e2cfb9b45570b000864c4b5',
promoCodes: ['300DOFF']
})
};
fetch('https://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate', 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://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate",
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' => [
[
'itemId' => 1000000119,
'group' => [
'5e2cfb9b45570b000863c4b5'
],
'quantity' => 3,
'price' => [
'base' => 1000,
'sale' => 0,
'currency' => 'USD'
],
'lineItemId' => 1,
'sku' => 'SKU0001'
]
],
'isLoggedIn' => false,
'userId' => '5e2cfb9b45570b000864c4b5',
'promoCodes' => [
'300DOFF'
]
]),
CURLOPT_HTTPHEADER => [
"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://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate"
payload := strings.NewReader("{\n \"items\": [\n {\n \"itemId\": 1000000119,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"quantity\": 3,\n \"price\": {\n \"base\": 1000,\n \"sale\": 0,\n \"currency\": \"USD\"\n },\n \"lineItemId\": 1,\n \"sku\": \"SKU0001\"\n }\n ],\n \"isLoggedIn\": false,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"300DOFF\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
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://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate")
.header("x-site-context", "<x-site-context>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"itemId\": 1000000119,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"quantity\": 3,\n \"price\": {\n \"base\": 1000,\n \"sale\": 0,\n \"currency\": \"USD\"\n },\n \"lineItemId\": 1,\n \"sku\": \"SKU0001\"\n }\n ],\n \"isLoggedIn\": false,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"300DOFF\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate")
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["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"itemId\": 1000000119,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"quantity\": 3,\n \"price\": {\n \"base\": 1000,\n \"sale\": 0,\n \"currency\": \"USD\"\n },\n \"lineItemId\": 1,\n \"sku\": \"SKU0001\"\n }\n ],\n \"isLoggedIn\": false,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"300DOFF\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"isSuccess": true,
"items": [
{
"lineItemId": 1,
"sku": "SKU0001",
"itemId": 1000000119,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"quantity": 3,
"price": {
"sale": 1000,
"cost": 0,
"currency": "USD",
"base": 5000,
"kind": "Promotion",
"discount": 0
},
"discount": [
{
"_id": "5f9be340dde1cd0008f96035",
"unit": "AMOUNT_OFF",
"value": 300,
"ON": {
"kind": "SKU",
"value": null
},
"id": "5f9be340dde1cd0008f96035",
"promoId": "5f9be340dde1cd0008f96034",
"promoCode": "300DOFF",
"promoTitle": "SKU 300 D off all skus",
"type": "COUPON"
}
],
"discountQuantity": 3,
"discountAmount": 5070
}
],
"appliedDiscounts": [
{
"promoId": "5faaac2dd49ffe00071e4f8d",
"promoTitle": "inclsion promo 99 P off ",
"type": "PROMOTION-SKU"
}
],
"discounts": [
{
"_id": "5faaac2dd49ffe00071e4f8e",
"unit": "%OFF",
"value": 99,
"ON": {
"kind": "SKU",
"value": null
},
"id": "5faaac2dd49ffe00071e4f8e",
"type": "PROMOTION-SKU",
"promoId": "5faaac2dd49ffe00071e4f8d",
"promoTitle": "inclsion promo 99 P off."
}
]
}{
"code": 400,
"message": "SKU cannot be empty"
}{
"code": 500,
"message": "An internal error occurred. If the issue persists please contact support@fabric.inc."
}Validate Promotions
Enables you to validate a cart’s promotions - coupon codes and implicit promotions - for specified item IDs.
curl --request POST \
--url https://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"items": [
{
"itemId": 1000000119,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"quantity": 3,
"price": {
"base": 1000,
"sale": 0,
"currency": "USD"
},
"lineItemId": 1,
"sku": "SKU0001"
}
],
"isLoggedIn": false,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": [
"300DOFF"
]
}
'import requests
url = "https://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate"
payload = {
"items": [
{
"itemId": 1000000119,
"group": ["5e2cfb9b45570b000863c4b5"],
"quantity": 3,
"price": {
"base": 1000,
"sale": 0,
"currency": "USD"
},
"lineItemId": 1,
"sku": "SKU0001"
}
],
"isLoggedIn": False,
"userId": "5e2cfb9b45570b000864c4b5",
"promoCodes": ["300DOFF"]
}
headers = {
"x-site-context": "<x-site-context>",
"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>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
itemId: 1000000119,
group: ['5e2cfb9b45570b000863c4b5'],
quantity: 3,
price: {base: 1000, sale: 0, currency: 'USD'},
lineItemId: 1,
sku: 'SKU0001'
}
],
isLoggedIn: false,
userId: '5e2cfb9b45570b000864c4b5',
promoCodes: ['300DOFF']
})
};
fetch('https://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate', 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://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate",
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' => [
[
'itemId' => 1000000119,
'group' => [
'5e2cfb9b45570b000863c4b5'
],
'quantity' => 3,
'price' => [
'base' => 1000,
'sale' => 0,
'currency' => 'USD'
],
'lineItemId' => 1,
'sku' => 'SKU0001'
]
],
'isLoggedIn' => false,
'userId' => '5e2cfb9b45570b000864c4b5',
'promoCodes' => [
'300DOFF'
]
]),
CURLOPT_HTTPHEADER => [
"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://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate"
payload := strings.NewReader("{\n \"items\": [\n {\n \"itemId\": 1000000119,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"quantity\": 3,\n \"price\": {\n \"base\": 1000,\n \"sale\": 0,\n \"currency\": \"USD\"\n },\n \"lineItemId\": 1,\n \"sku\": \"SKU0001\"\n }\n ],\n \"isLoggedIn\": false,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"300DOFF\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
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://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate")
.header("x-site-context", "<x-site-context>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"itemId\": 1000000119,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"quantity\": 3,\n \"price\": {\n \"base\": 1000,\n \"sale\": 0,\n \"currency\": \"USD\"\n },\n \"lineItemId\": 1,\n \"sku\": \"SKU0001\"\n }\n ],\n \"isLoggedIn\": false,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"300DOFF\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://prod01-apigw.{customer_name}.fabric.zone/api-price/promo/validate")
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["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"itemId\": 1000000119,\n \"group\": [\n \"5e2cfb9b45570b000863c4b5\"\n ],\n \"quantity\": 3,\n \"price\": {\n \"base\": 1000,\n \"sale\": 0,\n \"currency\": \"USD\"\n },\n \"lineItemId\": 1,\n \"sku\": \"SKU0001\"\n }\n ],\n \"isLoggedIn\": false,\n \"userId\": \"5e2cfb9b45570b000864c4b5\",\n \"promoCodes\": [\n \"300DOFF\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"isSuccess": true,
"items": [
{
"lineItemId": 1,
"sku": "SKU0001",
"itemId": 1000000119,
"group": [
"5e2cfb9b45570b000863c4b5"
],
"quantity": 3,
"price": {
"sale": 1000,
"cost": 0,
"currency": "USD",
"base": 5000,
"kind": "Promotion",
"discount": 0
},
"discount": [
{
"_id": "5f9be340dde1cd0008f96035",
"unit": "AMOUNT_OFF",
"value": 300,
"ON": {
"kind": "SKU",
"value": null
},
"id": "5f9be340dde1cd0008f96035",
"promoId": "5f9be340dde1cd0008f96034",
"promoCode": "300DOFF",
"promoTitle": "SKU 300 D off all skus",
"type": "COUPON"
}
],
"discountQuantity": 3,
"discountAmount": 5070
}
],
"appliedDiscounts": [
{
"promoId": "5faaac2dd49ffe00071e4f8d",
"promoTitle": "inclsion promo 99 P off ",
"type": "PROMOTION-SKU"
}
],
"discounts": [
{
"_id": "5faaac2dd49ffe00071e4f8e",
"unit": "%OFF",
"value": 99,
"ON": {
"kind": "SKU",
"value": null
},
"id": "5faaac2dd49ffe00071e4f8e",
"type": "PROMOTION-SKU",
"promoId": "5faaac2dd49ffe00071e4f8d",
"promoTitle": "inclsion promo 99 P off."
}
]
}{
"code": 400,
"message": "SKU cannot be empty"
}{
"code": 500,
"message": "An internal error occurred. If the issue persists please contact support@fabric.inc."
}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
A JSON object containing information to apply eligible promotions to cart items.
The item details. At least one item must be specified.
Show child attributes
Show child attributes
True indicates a logged in user and False indicates guest user.
false
The 24 character system-generated ID of the logged-in user. This is auto-generated based on the Authorization Token (JWT token from the Login API) specified in the Headers.
"5e2cfb9b45570b000864c4b5"
The coupon codes applied by the user.
["300DOFF"]Response
Successful
True indicates the cart validation is successful and false indicates otherwise.
true
The item details.
Show child attributes
Show child attributes
The basic details (such as promoId, promoTitle, and type) of all the discounts applied to the cart.
Show child attributes
Show child attributes
The additional attributes of the discounts applied to the cart such as discount ID, unit, and value of discount, along with the basic details.
Show child attributes
Show child attributes
Was this page helpful?
