Validate a discount code against the cart
curl --request POST \
--url https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate \
--header 'Content-Type: application/json' \
--data '
{
"code": "LATO10",
"items": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"quantity": 1,
"variantId": "664f1a2b3c4d5e6f7a8b9c11",
"variant": "30 dni"
}
],
"paymentMethodCode": "imoje"
}
'import requests
url = "https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate"
payload = {
"code": "LATO10",
"items": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"quantity": 1,
"variantId": "664f1a2b3c4d5e6f7a8b9c11",
"variant": "30 dni"
}
],
"paymentMethodCode": "imoje"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'LATO10',
items: [
{
productId: '664f1a2b3c4d5e6f7a8b9c0d',
quantity: 1,
variantId: '664f1a2b3c4d5e6f7a8b9c11',
variant: '30 dni'
}
],
paymentMethodCode: 'imoje'
})
};
fetch('https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/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([
'code' => 'LATO10',
'items' => [
[
'productId' => '664f1a2b3c4d5e6f7a8b9c0d',
'quantity' => 1,
'variantId' => '664f1a2b3c4d5e6f7a8b9c11',
'variant' => '30 dni'
]
],
'paymentMethodCode' => 'imoje'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate"
payload := strings.NewReader("{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"valid": true,
"code": "LATO10",
"reason": null,
"subtotal": 39.98,
"discountAmount": 4,
"total": 35.98,
"currency": "PLN",
"lines": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"subtotal": 19.99,
"discountShare": 2,
"total": 17.99
}
]
}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}Storefront v1
Validate a discount code against the cart
Server-side quote using the same function as checkout (variant/method price → discount → VAT). For several lines the discount is computed once per cart and split proportionally over the lines the code covers (lines[].discountShare, adding up to the cent). An invalid code is valid: false, not an error. Does not reserve a code use.
POST
/
api
/
v2
/
storefront
/
v1
/
shops
/
{shopId}
/
discounts
/
validate
Validate a discount code against the cart
curl --request POST \
--url https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate \
--header 'Content-Type: application/json' \
--data '
{
"code": "LATO10",
"items": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"quantity": 1,
"variantId": "664f1a2b3c4d5e6f7a8b9c11",
"variant": "30 dni"
}
],
"paymentMethodCode": "imoje"
}
'import requests
url = "https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate"
payload = {
"code": "LATO10",
"items": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"quantity": 1,
"variantId": "664f1a2b3c4d5e6f7a8b9c11",
"variant": "30 dni"
}
],
"paymentMethodCode": "imoje"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'LATO10',
items: [
{
productId: '664f1a2b3c4d5e6f7a8b9c0d',
quantity: 1,
variantId: '664f1a2b3c4d5e6f7a8b9c11',
variant: '30 dni'
}
],
paymentMethodCode: 'imoje'
})
};
fetch('https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/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([
'code' => 'LATO10',
'items' => [
[
'productId' => '664f1a2b3c4d5e6f7a8b9c0d',
'quantity' => 1,
'variantId' => '664f1a2b3c4d5e6f7a8b9c11',
'variant' => '30 dni'
]
],
'paymentMethodCode' => 'imoje'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate"
payload := strings.NewReader("{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"valid": true,
"code": "LATO10",
"reason": null,
"subtotal": 39.98,
"discountAmount": 4,
"total": 35.98,
"currency": "PLN",
"lines": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"subtotal": 19.99,
"discountShare": 2,
"total": 17.99
}
]
}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}Parametry ścieżki
Shop ID (ObjectId). Also accepts the uniqueName, an active custom domain or <uniqueName>.<hosting domain>.
Przykład:
"664f1a2b3c4d5e6f7a8b9c0d"
Treść
application/json
Required string length:
1 - 50Pattern:
^[A-Za-z0-9_-]+$Przykład:
"LATO10"
Cart lines (1–20). Several lines = a payment group: one order per line and one payment for the total (adr/0002)
Required array length:
1 - 20 elementsShow child attributes
Show child attributes
Payment method — the product may have a different price for it
Required string length:
1 - 100Przykład:
"imoje"
Czy ta strona była pomocna?
⌘I