Validate a promo code
POST
/api/website/promo/validate
const url = 'https://api.petanqueai.com/api/website/promo/validate';const options = { method: 'POST', headers: { 'x-storefront-token': '<x-storefront-token>', 'Content-Type': 'application/json' }, body: '{"code":"example","lines":[{"productId":"example","quantity":1}],"email":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.petanqueai.com/api/website/promo/validate \ --header 'Content-Type: application/json' \ --header 'x-storefront-token: <x-storefront-token>' \ --data '{ "code": "example", "lines": [ { "productId": "example", "quantity": 1 } ], "email": "example" }'Prices a basket with a promo code so your cart can show the discount before the order is placed. Always answers 200: either valid: true with every line, the discount, shipping and total, or valid: false with a reason (NOT_FOUND, EXPIRED, USED_UP, MIN_BASKET, …) and a message you can show.
Nothing is reserved: placing the order checks the code again. Send email to apply a once-per-shopper limit.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
code
required
string
lines
required
Array<object>
object
productId
required
string
quantity
required
integer
email
string
Example generated
{ "code": "example", "lines": [ { "productId": "example", "quantity": 1 } ], "email": "example"}object
code
required
string
lines
required
Array<object>
object
productId
required
string
quantity
required
integer
email
string
Example generated
code=example&lines=%7B%22productId%22%3A%22example%22%2C%22quantity%22%3A1%7D&email=exampleobject
code
required
string
lines
required
Array<object>
object
productId
required
string
quantity
required
integer
email
string