Redemptions & Discount Codes
Check discount code validity
PUT
/
api
/
external
/
check-discount
Check discount code validity
curl --request PUT \
--url https://loyalty-admin.appstle.com/api/external/check-discount \
--header 'Content-Type: application/json' \
--data '
{
"customerId": 67890,
"discountCode": "LOYALTY15OFF"
}
'import requests
url = "https://loyalty-admin.appstle.com/api/external/check-discount"
payload = {
"customerId": 67890,
"discountCode": "LOYALTY15OFF"
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({customerId: 67890, discountCode: 'LOYALTY15OFF'})
};
fetch('https://loyalty-admin.appstle.com/api/external/check-discount', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://loyalty-admin.appstle.com/api/external/check-discount';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({customerId: 67890, discountCode: 'LOYALTY15OFF'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://loyalty-admin.appstle.com/api/external/check-discount",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => 67890,
'discountCode' => 'LOYALTY15OFF'
]),
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://loyalty-admin.appstle.com/api/external/check-discount"
payload := strings.NewReader("{\n \"customerId\": 67890,\n \"discountCode\": \"LOYALTY15OFF\"\n}")
req, _ := http.NewRequest("PUT", 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))
}require 'uri'
require 'net/http'
url = URI("https://loyalty-admin.appstle.com/api/external/check-discount")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": 67890,\n \"discountCode\": \"LOYALTY15OFF\"\n}"
response = http.request(request)
puts response.read_body{
"createAt": "2025-01-15T10:30:00Z",
"customerId": 67890,
"discountCode": "LOYALTY15OFF",
"discountType": "PERCENTAGE",
"discountValue": 15,
"expiryDate": "2025-06-30T23:59:59Z",
"id": 12345,
"minimumPurchaseAmount": 50,
"pointsRedeemed": 100,
"shopifyDiscountCodeId": "gid://shopify/DiscountCode/123",
"status": "UNUSED"
}{
"error": "Discount code already used",
"status": "USED",
"usedAt": "2025-01-20T14:30:00Z"
}{
"error": "Invalid API key"
}{
"error": "Discount code not found for the specified customer"
}Body
application/json
Request containing customer ID and discount code to validate
Shopify customer ID (numeric). Identifies which customer is attempting to use the discount code. Used to verify the discount code belongs to this customer. Example: 67890
Example:
67890
The discount code to validate. Case-insensitive. This is the code the customer enters at checkout. System will check if:
- Code exists in loyalty system
- Code belongs to this customer
- Code status is UNUSED or ACTIVE
- Code has not expired Examples: "LOYALTY15OFF", "VIP20", "WELCOME10"
Maximum string length:
100Example:
"LOYALTY15OFF"
Response
Discount code is valid and reward details returned
Available options:
USED, UNUSED, REFUNDED, EXPIRED, SUBSCRIPTION_ACTIVE, CANCELED Available options:
STORE_CREDIT, DISCOUNT_CODE, POINTS ⌘I
Check discount code validity
curl --request PUT \
--url https://loyalty-admin.appstle.com/api/external/check-discount \
--header 'Content-Type: application/json' \
--data '
{
"customerId": 67890,
"discountCode": "LOYALTY15OFF"
}
'import requests
url = "https://loyalty-admin.appstle.com/api/external/check-discount"
payload = {
"customerId": 67890,
"discountCode": "LOYALTY15OFF"
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({customerId: 67890, discountCode: 'LOYALTY15OFF'})
};
fetch('https://loyalty-admin.appstle.com/api/external/check-discount', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://loyalty-admin.appstle.com/api/external/check-discount';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({customerId: 67890, discountCode: 'LOYALTY15OFF'})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://loyalty-admin.appstle.com/api/external/check-discount",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'customerId' => 67890,
'discountCode' => 'LOYALTY15OFF'
]),
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://loyalty-admin.appstle.com/api/external/check-discount"
payload := strings.NewReader("{\n \"customerId\": 67890,\n \"discountCode\": \"LOYALTY15OFF\"\n}")
req, _ := http.NewRequest("PUT", 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))
}require 'uri'
require 'net/http'
url = URI("https://loyalty-admin.appstle.com/api/external/check-discount")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"customerId\": 67890,\n \"discountCode\": \"LOYALTY15OFF\"\n}"
response = http.request(request)
puts response.read_body{
"createAt": "2025-01-15T10:30:00Z",
"customerId": 67890,
"discountCode": "LOYALTY15OFF",
"discountType": "PERCENTAGE",
"discountValue": 15,
"expiryDate": "2025-06-30T23:59:59Z",
"id": 12345,
"minimumPurchaseAmount": 50,
"pointsRedeemed": 100,
"shopifyDiscountCodeId": "gid://shopify/DiscountCode/123",
"status": "UNUSED"
}{
"error": "Discount code already used",
"status": "USED",
"usedAt": "2025-01-20T14:30:00Z"
}{
"error": "Invalid API key"
}{
"error": "Discount code not found for the specified customer"
}