Get calculated prices - Fabric
Get calculated prices
cURL
curl --request POST \
--url https://live.copilot.fabric.inc/v1/price/get-by-sku \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"traceId": 394823457,
"priceList": [
100275,
100276
],
"sku": [
1000019501,
1000019502
],
"itemId": [
111111,
222222
],
"userId": "5e2cfb9b45570b000864c4b5",
"userProfile": {
"Customer Type": [
"Wholesale"
]
},
"isLoggedIn": true,
"channel": [
12,
15
],
"date": "2019-08-24T14:15:22Z",
"priceParams": [
{
"options": {
"length": "2",
"width": "15",
"blindMotor": true
},
"sku": "11111",
"quantity": 5,
"itemId": 12345
}
],
"audit": true
}
'
Python
import requests
url = "https://live.copilot.fabric.inc/v1/price/get-by-sku"
payload = {
"traceId": 394823457,
"priceList": [100275, 100276],
"sku": [1000019501, 1000019502],
"itemId": [111111, 222222],
"userId": "5e2cfb9b45570b000864c4b5",
"userProfile": { "Customer Type": ["Wholesale"] },
"isLoggedIn": True,
"channel": [12, 15],
"date": "2019-08-24T14:15:22Z",
"priceParams": [
{
"options": {
"length": "2",
"width": "15",
"blindMotor": True
},
"sku": "11111",
"quantity": 5,
"itemId": 12345
}
],
"audit": True
}
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)
JavaScript (Fetch)
const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
traceId: 394823457,
priceList: [100275, 100276],
sku: [1000019501, 1000019502],
itemId: [111111, 222222],
userId: '5e2cfb9b45570b000864c4b5',
userProfile: {'Customer Type': ['Wholesale']},
isLoggedIn: true,
channel: [12, 15],
date: '2019-08-24T14:15:22Z',
priceParams: [
{
options: {length: '2', width: '15', blindMotor: true},
sku: '11111',
quantity: 5,
itemId: 12345
}
],
audit: true
})
};
fetch('https://live.copilot.fabric.inc/v1/price/get-by-sku', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
Response Structure
Successful Response (200)
[
{
"priceList": "100275",
"sku": "11111111",
"itemId": 11111111,
"offers": {
"price": {
"sale": 10,
"cost": 9,
"base": 10,
"finalPrice": 20,
"currency": "USD",
"totalPrice": 15
},
"kind": "BASE",
"channel": 12,
"discounts": [
{
"amount": 10,
"value": 20,
"groupId": "61a6354d0d70e30009415f16",
"promotionId": "6197ec46e836ff000952c668",
"priority": 1,
"stackable": true,
"title": "20% off",
"quantity": 5,
"promotionType": "COUPON",
"application": 1,
"isAlwaysApplied": false,
"level": 1,
"stackingType": "STACKABLE",
"proratedAmount": 10,
"proratedQuantity": 1,
"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
}
]
}
],
"additionalAttributes": [{}],
"promotionMessages": [
{"promoId": "6197ec46e836ff000952c667", "threshold": 3, "message": "Add another pair of shoes to get free socks!", "locales": ["en-US", "en-GB"], "type": "PROXIMITY"},
{"promoId": "6197ec46e836ff000952c668", "title": "Get free socks!", "message": "Buy two pairs of shoes and get a pair of socks for free!", "locales": ["en-US", "en-GB"], "pages": ["PDP", "CART"], "type": "POTENTIAL_DISCOUNT"}
]
},
"audit": {
"userId": "62f5e25ca090100009c6e0f0",
"priceMethodType": "SurfaceArea_Square_Increment",
"quantity": 5,
"options": {"length": 12,"width": 10},
"appliedAddons": ["blind-motor"]
}
}
]
Error Response (e.g., Not Found 404)
{
"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"
}
]
}