curl --request POST \
--url https://api.fabric.inc/v3/price-engine/actions/evaluate-cart \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
--data '
{
"cartItems": [
{
"itemId": 1730902008,
"quantity": 15,
"position": 1,
"sku": "16B2GS8LD5FDS",
"productAttributes": [
{
"name": "gift wrapping (small)",
"value": "true",
"attributeId": "60c2a358eb2ec30008ae70a1",
"description": "Gift wrapping for a small package",
"mapping": "ITEM",
"type": "GIFT",
"price": 10,
"level": "order"
}
],
"priceListId": 108674,
"price": {
"sale": 1000.15,
"cost": 900.15,
"base": 2000.15,
"unitPriceWithoutDiscounts": 2000.15,
"lineTotalWithoutDiscounts": 2000.15,
"lineTotalWithDiscounts": 2000.15,
"type": "BASE"
},
"groups": [
"61d38e117162b7dba69c3d6d"
],
"attributes": {
"productFamily": "Laptop computers"
},
"shippingDetails": {
"shippingCost": 150.25,
"shippingMethodId": "dfsae-2d32113-32lpdd",
"shippingDiscount": 150.25,
"shippingMethodName": "Express Delivery"
},
"productCollections": [
"5e2cfb9b45570b000863c4b5"
]
}
],
"customer": {
"id": "5e2cfb9b45570b000864c4b5",
"segments": [
{
"name": "category",
"value": [
"GOLD",
"YELLOW"
]
},
{
"name": "ageGroup",
"value": [
"elderly"
]
}
]
},
"couponCodes": [
"SUPERCOUPON1"
],
"locale": "en-US"
}
'{
"cartItems": [
{
"itemId": 1730902008,
"quantity": 15,
"position": 1,
"sku": "16B2GS8LD5FDS",
"productAttributes": [
{
"name": "gift wrapping (small)",
"value": "true",
"attributeId": "60c2a358eb2ec30008ae70a1",
"description": "Gift wrapping for a small package",
"mapping": "ITEM",
"type": "GIFT",
"price": 10,
"level": "order"
}
],
"priceListId": 108674,
"price": {
"sale": 1000.15,
"cost": 900.15,
"base": 2000.15,
"unitPriceWithoutDiscounts": 2000.15,
"lineTotalWithoutDiscounts": 2000.15,
"lineTotalWithDiscounts": 2000.15,
"type": "BASE"
},
"groups": [
"61d38e117162b7dba69c3d6d"
],
"attributes": {
"productFamily": "Laptop computers"
},
"shippingDetails": {
"shippingCost": 150.25,
"shippingMethodId": "dfsae-2d32113-32lpdd",
"shippingDiscount": 150.25,
"shippingMethodName": "Express Delivery"
},
"discounts": [
{
"amount": 100.15,
"quantity": 1,
"proratedAmount": 100.15,
"proratedQuantity": 1,
"application": 1,
"promotion": {
"id": "6197ec46e836ff000952d668",
"value": 2000.15,
"groupId": "61a6354d0d70e30009415f16",
"level": 1,
"isStackable": true,
"isAlwaysApplied": true,
"name": "20% OFF",
"type": "Coupon",
"discountType": "AMOUNT_OFF",
"stackingType": "STACKABLE"
}
}
],
"priceAttributes": {
"floor": 1000.15,
"cost": 900.15,
"clearance": 2000.15
},
"productCollections": [
"5e2cfb9b45570b000863c4b5"
]
}
],
"errors": [
"Parameter doesn't exist"
],
"appliedDiscounts": [
{
"promotionId": "6197ec46e836ff000952c665",
"promotionName": "Buy shoes get socks for free",
"couponCode": "SUPERCOUPON20",
"type": "COUPON",
"amount": 105.15,
"discountScope": "SKU",
"discountType": "AMOUNT_OFF",
"value": 10
}
],
"suggestedProducts": [
{
"promotionId": "6197ec46e836ff000952c665",
"promotionName": "Buy shoes get socks for free",
"itemId": 234343,
"itemIds": [
1120201,
1120202
],
"sku": "SHOE1234",
"skus": [
"SHOE-1",
"SHOE-2"
],
"eligiblePriceLists": [
10000
],
"quantity": 2,
"promotionQuantity": 10,
"isFree": true,
"discountType": "PERCENTAGE_OFF",
"amount": 105.15
}
],
"notAppliedCoupons": [
{
"couponCode": "SUPERCOUPON",
"promotionId": "624b5aa2a8fd12000965dfdc",
"message": "Invalid coupon"
}
],
"promotionMessages": [
{
"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,
"promoId": "61df12345678900009b7091c"
}
]
}Evaluate cart’s total cost instantly, after applying all applicable promotions and discount coupons. Using this endpoint, submit a range of data that will be referenced against the conditions that are set earlier using the promotions, coupons or prices APIs. The response includes the details of the promotions and discounts applied. These promotions and discounts can be displayed on your website to help shoppers know that they’re getting their expected discounts.
curl --request POST \
--url https://api.fabric.inc/v3/price-engine/actions/evaluate-cart \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
--data '
{
"cartItems": [
{
"itemId": 1730902008,
"quantity": 15,
"position": 1,
"sku": "16B2GS8LD5FDS",
"productAttributes": [
{
"name": "gift wrapping (small)",
"value": "true",
"attributeId": "60c2a358eb2ec30008ae70a1",
"description": "Gift wrapping for a small package",
"mapping": "ITEM",
"type": "GIFT",
"price": 10,
"level": "order"
}
],
"priceListId": 108674,
"price": {
"sale": 1000.15,
"cost": 900.15,
"base": 2000.15,
"unitPriceWithoutDiscounts": 2000.15,
"lineTotalWithoutDiscounts": 2000.15,
"lineTotalWithDiscounts": 2000.15,
"type": "BASE"
},
"groups": [
"61d38e117162b7dba69c3d6d"
],
"attributes": {
"productFamily": "Laptop computers"
},
"shippingDetails": {
"shippingCost": 150.25,
"shippingMethodId": "dfsae-2d32113-32lpdd",
"shippingDiscount": 150.25,
"shippingMethodName": "Express Delivery"
},
"productCollections": [
"5e2cfb9b45570b000863c4b5"
]
}
],
"customer": {
"id": "5e2cfb9b45570b000864c4b5",
"segments": [
{
"name": "category",
"value": [
"GOLD",
"YELLOW"
]
},
{
"name": "ageGroup",
"value": [
"elderly"
]
}
]
},
"couponCodes": [
"SUPERCOUPON1"
],
"locale": "en-US"
}
'{
"cartItems": [
{
"itemId": 1730902008,
"quantity": 15,
"position": 1,
"sku": "16B2GS8LD5FDS",
"productAttributes": [
{
"name": "gift wrapping (small)",
"value": "true",
"attributeId": "60c2a358eb2ec30008ae70a1",
"description": "Gift wrapping for a small package",
"mapping": "ITEM",
"type": "GIFT",
"price": 10,
"level": "order"
}
],
"priceListId": 108674,
"price": {
"sale": 1000.15,
"cost": 900.15,
"base": 2000.15,
"unitPriceWithoutDiscounts": 2000.15,
"lineTotalWithoutDiscounts": 2000.15,
"lineTotalWithDiscounts": 2000.15,
"type": "BASE"
},
"groups": [
"61d38e117162b7dba69c3d6d"
],
"attributes": {
"productFamily": "Laptop computers"
},
"shippingDetails": {
"shippingCost": 150.25,
"shippingMethodId": "dfsae-2d32113-32lpdd",
"shippingDiscount": 150.25,
"shippingMethodName": "Express Delivery"
},
"discounts": [
{
"amount": 100.15,
"quantity": 1,
"proratedAmount": 100.15,
"proratedQuantity": 1,
"application": 1,
"promotion": {
"id": "6197ec46e836ff000952d668",
"value": 2000.15,
"groupId": "61a6354d0d70e30009415f16",
"level": 1,
"isStackable": true,
"isAlwaysApplied": true,
"name": "20% OFF",
"type": "Coupon",
"discountType": "AMOUNT_OFF",
"stackingType": "STACKABLE"
}
}
],
"priceAttributes": {
"floor": 1000.15,
"cost": 900.15,
"clearance": 2000.15
},
"productCollections": [
"5e2cfb9b45570b000863c4b5"
]
}
],
"errors": [
"Parameter doesn't exist"
],
"appliedDiscounts": [
{
"promotionId": "6197ec46e836ff000952c665",
"promotionName": "Buy shoes get socks for free",
"couponCode": "SUPERCOUPON20",
"type": "COUPON",
"amount": 105.15,
"discountScope": "SKU",
"discountType": "AMOUNT_OFF",
"value": 10
}
],
"suggestedProducts": [
{
"promotionId": "6197ec46e836ff000952c665",
"promotionName": "Buy shoes get socks for free",
"itemId": 234343,
"itemIds": [
1120201,
1120202
],
"sku": "SHOE1234",
"skus": [
"SHOE-1",
"SHOE-2"
],
"eligiblePriceLists": [
10000
],
"quantity": 2,
"promotionQuantity": 10,
"isFree": true,
"discountType": "PERCENTAGE_OFF",
"amount": 105.15
}
],
"notAppliedCoupons": [
{
"couponCode": "SUPERCOUPON",
"promotionId": "624b5aa2a8fd12000965dfdc",
"message": "Invalid coupon"
}
],
"promotionMessages": [
{
"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,
"promoId": "61df12345678900009b7091c"
}
]
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
A header used by fabric to identify the tenant making the request. You must include tenant id in the authentication header for an API request to access any of fabric’s endpoints. You can retrieve the tenant id , which is also called account id, from Copilot. This header is required.
24The Date and time, in ISO 8601 format, for which the evaluation should be done. The prices and promotions that are active on this date will be considered for evaluation.
"2022-09-06T14:07:17.000Z"
A unique request ID.
"263e731c-45c8-11ed-b878-0242ac120002"
x-fabric-channel-id identifies the sales channel where the API request is being made; primarily for multichannel use cases. The channel ids are 12 corresponding to US and 13 corresponding to Canada. The default channel id is 12. This field is required.
"12"
A sample cart evaluation request.
The details of items in the cart.
Show child attributes
Item ID obtained from Product Catalog.
1730902008
Line item quantity within the cart
15
Line item position (starts at 1)
x >= 11
Line item SKU
"16B2GS8LD5FDS"
Line item product attributes
Show child attributes
Attribute name
"gift wrapping (small)"
Attribute value
"true"
Attribute ID
"60c2a358eb2ec30008ae70a1"
Attribute description
"Gift wrapping for a small package"
Attribute mapping
"ITEM"
Attribute type
"GIFT"
Attribute price
10
Attribute level
"order"
The price list ID associated with the item generated using the create price list endpoint.
108674
Individual line item price
Show child attributes
Sale price of the product.
1000.15
Cost of goods sold, from either producing or purchasing from other vendors.
900.15
The base price of a single item before any discounts.
2000.15
Price of a single item without discount. This price is either the base or sale price. The type used is noted in the type property.
2000.15
Total price of all items without calculating discounts. This is the unitPriceWithoutDiscounts multiplied by the quantity.
5000.15
Total price of all items after all discounts. This is the unitPriceWithoutDiscounts multiplied by the quantity, less the promotion discounts.
5000.15
Price type
"BASE"
Currency string value
"USD"
{
"sale": 1000.15,
"cost": 900.15,
"base": 2000.15,
"unitPriceWithoutDiscounts": 2000.15,
"lineTotalWithoutDiscounts": 2000.15,
"lineTotalWithDiscounts": 2000.15,
"type": "BASE"
}List of group IDs for groups or category the line items belongs to
ID of group or category to which line item belongs
Line item attributes passed by caller
{ "productFamily": "Laptop computers" }Shipping details
Show child attributes
Shipping cost
150.25
Shipping method ID
"dfsae-2d32113-32lpdd"
Discount amount
150.25
Shipping method name
"Express Delivery"
The collections associated with given item.
A 24-character system-generated collection ID.
Customer details
Show child attributes
Unique identifier for the customer
"5e2cfb9b45570b000864c4b5"
A list of segments the customer belongs to.
[
{
"name": "category",
"value": ["GOLD", "YELLOW"]
},
{ "name": "ageGroup", "value": ["elderly"] }
]Promotion codes to be applied
Promotion code
The language code, which is a combination of language in ISO 639 format and country in ISO 3166 format. The default value is en-US.
"en-US"
OK
The response of the evaluation request of the cart promotion.
The list of items in the cart.
Show child attributes
Item ID obtained from Product Catalog.
1730902008
Line item quantity within the cart
15
Line item position (starts at 1)
x >= 11
Line item SKU
"16B2GS8LD5FDS"
Line item product attributes
Show child attributes
Attribute name
"gift wrapping (small)"
Attribute value
"true"
Attribute ID
"60c2a358eb2ec30008ae70a1"
Attribute description
"Gift wrapping for a small package"
Attribute mapping
"ITEM"
Attribute type
"GIFT"
Attribute price
10
Attribute level
"order"
The price list ID associated with the item generated using the create price list endpoint.
108674
Individual line item price
Show child attributes
Sale price of the product.
1000.15
Cost of goods sold, from either producing or purchasing from other vendors.
900.15
The base price of a single item before any discounts.
2000.15
Price of a single item without discount. This price is either the base or sale price. The type used is noted in the type property.
2000.15
Total price of all items without calculating discounts. This is the unitPriceWithoutDiscounts multiplied by the quantity.
5000.15
Total price of all items after all discounts. This is the unitPriceWithoutDiscounts multiplied by the quantity, less the promotion discounts.
5000.15
Price type
"BASE"
Currency string value
"USD"
{
"sale": 1000.15,
"cost": 900.15,
"base": 2000.15,
"unitPriceWithoutDiscounts": 2000.15,
"lineTotalWithoutDiscounts": 2000.15,
"lineTotalWithDiscounts": 2000.15,
"type": "BASE"
}List of group IDs for groups or category the line items belongs to
ID of group or category to which line item belongs
Line item attributes passed by caller
{ "productFamily": "Laptop computers" }Shipping details
Show child attributes
Shipping cost
150.25
Shipping method ID
"dfsae-2d32113-32lpdd"
Discount amount
150.25
Shipping method name
"Express Delivery"
A list of applicable discounts.
Show child attributes
The actual discount amount applied to the price. For example, specifying 100.15 for a product with a base price of 2000.15 results in a discounted price of 1900.
100.15
The number of items eligible for the promotional discount.
5
The discount amount distributed proportionally among all the selected items. The distribution is determined based on each item's price relative to the total price of all participating items. Typically, proratedAmount matches the amount. However, there might be variations, particularly in the context of Buy-Get promotions.
1000.15
This is used in conjunction with proratedAmount to determine the discount portion allocated to the respective units of BuyGet promotions. This is applicable in partial return scenarios.
5
An identifier for an instance of the Buy-Get promotion that can be applied repeatedly. For example, consider a promotion - Buy 1 shirt and get 1 pant at a 20% off. If a shopper buys three shirts, 20% discount is individually applied to each shirt-pant pair. Each such discounted pair is assigned a unique application number for tracking purposes.
1
The promotion details.
Show child attributes
A 24-character system-generated coupon ID generated using the create coupon endpoint.
"6197ec46e836ff000952c667"
The discount in percent or amount.
2000.15
ID of the group or category this product belongs to
"61a6354d0d70e30009415f16"
The order in which the current promotion is executed.
1
A flag indicating whether the promotion is stackable. Set to true to combine the given promotion with other promotions. The discount of the current promotion is combined with other promotions, if applicable, to the item. Set to false if the promotion isn't stackable; the given promotion can't be combined with other promotions.
true
A flag indicating whether the promotion is always applied regardless of any exclusive promotions on the same item. Set to true if the promotion is always applied and set to false if the promotion isn't applied on the item by default.
true
Defines the rules for how a promotion can be combined with other promotions. This field determines whether a specific promotion can be applied in conjunction with other active promotions during a transaction or if it must be used exclusively. Possible values: - STACKABLE: This promotion can be combined with other stackable promotions, allowing multiple
discounts to be applied together. The order in which stackable promotions are applied
is determined by the level field, with promotions having a higher priority (lower numeric value)
being applied before those with a lower priority.
EXCLUSIVE: This promotion can't be combined with any other promotions. The level field is
used to determine which exclusive promotion will be evaluated and applied first. Once an exclusive
promotion is applied, no other promotions can be used in the same transaction.TYPE_EXCLUSIVE: This promotion can't be combined with other promotions of the same type.
The level field is used to determine which promotion within the same type will be evaluated and
applied first.UNIVERSAL: This promotion can be combined with any other promotions without restrictions.
Universal promotions will be evaluated last.STACKABLE, EXCLUSIVE, TYPE_EXCLUSIVE, UNIVERSAL "STACKABLE"
The name of the promotion.
"20% off"
The type of the promotion.
"COUPON"
The type of discount.
PERCENTAGE_OFF, AMOUNT_OFF, FIXED_PRICE "PERCENTAGE_OFF"
{
"id": "6197ec46e836ff000952c668",
"value": 2000.15,
"groupId": "61a6354d0d70e30009415f16",
"level": 1,
"isStackable": true,
"isAlwaysApplied": true,
"name": "20% OFF",
"type": "Coupon",
"discountType": "AMOUNT_OFF",
"stackingType": "STACKABLE"
}Price attributes
{
"floor": 1000.15,
"cost": 900.15,
"clearance": 2000.15
}The collections associated with given item.
A 24-character system-generated collection ID.
The error details.
The list of errors.
["Parameter doesn't exist"]The details of the discounts applied to the cart.
Show child attributes
A 24-character system-generated coupon ID generated using the create coupon endpoint.
"6197ec46e836ff000952c664"
Coupon code
"SUPERCOUPON20"
Promotion name
"20% off"
Promotion type
"COUPON"
Discount amount
10.15
[
{
"promotionId": "6197ec46e836ff000952c665",
"promotionName": "Buy shoes get socks for free",
"couponCode": "SUPERCOUPON20",
"type": "COUPON",
"amount": 105.15,
"discountScope": "SKU",
"discountType": "AMOUNT_OFF",
"value": 10
}
]Suggested free products
Show child attributes
A 24-character system-generated coupon ID generated using the create coupon endpoint.
"6197ec46e836ff000952c665"
The promotion name
"Buy shoes get socks for free"
The item ID of the free product
234343
The suggested item IDs from which shoppers can choose one or more items based on the configuration of BuyGet promotion. Even if an item ID is already in the cart, they appear in the list of potential item IDs. This ensures visibility and enables shoppers to make informed decisions during the checkout process.
The item ID of the free product.
The Stock Keeping Unit (SKU) of the free product.
"SHOE1234"
The suggested SKUs from which shoppers can choose one or more items based on the configuration of BuyGet promotion. Even if an SKU is already in the cart, they appear in the list of potential SKUs. This ensures visibility and enables shoppers to make informed decisions during the checkout process.
The Stock Keeping Unit (SKU) of the free product.
The price list IDs, eligible for promotions. When they're not specified, the promotion applies to all price lists. specified, promotion applies to all price lists.
The price list ID associated with the item generated using the create price list endpoint.
The number of complimentary items in the promotion.
2
The maximum limit of complimentary items available for the BuyGet promotion. For example, consider the promotionQuantity is 10 and promotion condition is Buy 1 pair of shoes and Get 1 pair of socks free. If a shopper purchases up to 10 pairs of shoes, they will get an equivalent number of socks for free. However, even if they buy more than 10 pairs of shoes, the maximum free pairs of socks will remain 10, as defined by the promotionQuantity parameter.
10
A flag indicating whether a free item is included as part of promotion. Set to true to indicate a free item is offered as promotion and false to indicate otherwise.
The type of discount.
"PERCENTAGE_OFF"
The discount amount.
100.15
[
{
"promotionId": "6197ec46e836ff000952c665",
"promotionName": "Buy shoes get socks for free",
"itemId": 234343,
"itemIds": [1120201, 1120202],
"sku": "SHOE1234",
"skus": ["SHOE-1", "SHOE-2"],
"eligiblePriceLists": [10000],
"quantity": 2,
"promotionQuantity": 10,
"isFree": true,
"discountType": "PERCENTAGE_OFF",
"amount": 105.15
}
]Rejected coupons
Show child attributes
Coupon code
"SUPERCOUPON"
A 24-character system-generated coupon ID generated using the create coupon endpoint.
"624b5aa2a8fd12000965dfdc"
Reason why coupon not applied
"Invalid coupon"
[
{
"couponCode": "SUPERCOUPON",
"promotionId": "624b5aa2a8fd12000965dfdc",
"message": "Invalid coupon"
}
]The promotion message that is displayed to the customer.
Show child attributes
Message name
"Buy 2 get 1 free"
Message description
"Offer valid at participating stores through September 5, 2023."
The types of web pages where the message is displayed.
Page type
PDP, PLP, Cart, Checkout The geographic regions where the promotion message is displayed, determined by the user's IP address. Locales define language and country-specific settings for promotions.
Locale
Specifies the promotion message type.
DISCOUNT: The discount has been applied.PROXIMITY: The product or cart is close to meeting discount conditions.POTENTIAL_DISCOUNT: The product could qualify for a discount but has not yet.DISCOUNT, PROXIMITY, POTENTIAL_DISCOUNT "DISCOUNT"
Indicates a quantity or amount that is close to meeting the discount requirement. If the user reaches this value, a promotion message is displayed. This field is only valid for PROXIMITY messages.
2
A 24-character system-generated coupon ID generated using the create coupon endpoint.
"61df12345678900009b7091c"
Was this page helpful?