Check a discount code
curl --request POST \
--url https://api.exowpee.com/v1/discount/codes/validate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"customer_id": "<string>",
"lines": [
{
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"base_quantity": 2,
"gross_ht_amount": 1
}
]
}
'import requests
url = "https://api.exowpee.com/v1/discount/codes/validate"
payload = {
"code": "<string>",
"customer_id": "<string>",
"lines": [
{
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"base_quantity": 2,
"gross_ht_amount": 1
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
customer_id: '<string>',
lines: [
{
stockable_id: '<string>',
stockable_unit_id: '<string>',
base_quantity: 2,
gross_ht_amount: 1
}
]
})
};
fetch('https://api.exowpee.com/v1/discount/codes/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://api.exowpee.com/v1/discount/codes/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' => '<string>',
'customer_id' => '<string>',
'lines' => [
[
'stockable_id' => '<string>',
'stockable_unit_id' => '<string>',
'base_quantity' => 2,
'gross_ht_amount' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.exowpee.com/v1/discount/codes/validate"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"lines\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"base_quantity\": 2,\n \"gross_ht_amount\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.exowpee.com/v1/discount/codes/validate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"lines\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"base_quantity\": 2,\n \"gross_ht_amount\": 1\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.exowpee.com/v1/discount/codes/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"lines\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"base_quantity\": 2,\n \"gross_ht_amount\": 1\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"eligible": true,
"reasons": "<string>",
"would_be": {
"discount_amount": "<string>",
"qualification_base_amount": "<string>",
"selected_tier": "<string>",
"allocations": "<string>"
}
}{
"message": "<string>",
"errors": {}
}Run discount campaigns
Check a discount code
Previews whether a discount code can be used for a basket and customer, and what the discount would be, without applying it or recording any usage. A valid request always gets a 200 answer with eligible, reasons and would_be.
POST
/
discount
/
codes
/
validate
Check a discount code
curl --request POST \
--url https://api.exowpee.com/v1/discount/codes/validate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"customer_id": "<string>",
"lines": [
{
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"base_quantity": 2,
"gross_ht_amount": 1
}
]
}
'import requests
url = "https://api.exowpee.com/v1/discount/codes/validate"
payload = {
"code": "<string>",
"customer_id": "<string>",
"lines": [
{
"stockable_id": "<string>",
"stockable_unit_id": "<string>",
"base_quantity": 2,
"gross_ht_amount": 1
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
customer_id: '<string>',
lines: [
{
stockable_id: '<string>',
stockable_unit_id: '<string>',
base_quantity: 2,
gross_ht_amount: 1
}
]
})
};
fetch('https://api.exowpee.com/v1/discount/codes/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://api.exowpee.com/v1/discount/codes/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' => '<string>',
'customer_id' => '<string>',
'lines' => [
[
'stockable_id' => '<string>',
'stockable_unit_id' => '<string>',
'base_quantity' => 2,
'gross_ht_amount' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.exowpee.com/v1/discount/codes/validate"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"lines\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"base_quantity\": 2,\n \"gross_ht_amount\": 1\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.exowpee.com/v1/discount/codes/validate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"lines\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"base_quantity\": 2,\n \"gross_ht_amount\": 1\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.exowpee.com/v1/discount/codes/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"customer_id\": \"<string>\",\n \"lines\": [\n {\n \"stockable_id\": \"<string>\",\n \"stockable_unit_id\": \"<string>\",\n \"base_quantity\": 2,\n \"gross_ht_amount\": 1\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"eligible": true,
"reasons": "<string>",
"would_be": {
"discount_amount": "<string>",
"qualification_base_amount": "<string>",
"selected_tier": "<string>",
"allocations": "<string>"
}
}{
"message": "<string>",
"errors": {}
}Company space
For: Cashier and seller, Manager · Permission:
discount_campaigns.validatecode
Conditions
- The code must be provided, and the customer, when given, must be one of the company’s customers.
- Every line needs a 27-character stockable_id and stockable_unit_id, a base_quantity of at least 1 and a gross_ht_amount that is not negative and respects the currency decimals.
- An unknown code is not an error: the answer is 200 with eligible false and the reason code_unknown.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Discount code to check, up to 64 characters. Required. The comparison ignores capitals and surrounding spaces.
Maximum string length:
64Customer the basket is for (27-character KSUID string), used for access, exclusion and per-customer limits. Must be a customer of the company. Optional.
Lines of the basket to price. Optional; without lines, only the campaign rules that do not depend on amounts are checked.
Show child attributes
Show child attributes