Redemptions & Discount Codes
Check discount code validity
Returns a customer’s loyalty reward for a discount code.
When to use this:
- Before applying a loyalty discount code, to confirm it belongs to the customer
- To check the code’s status before you apply it
- To retrieve reward details
Request body:
- customerId: Shopify customer ID (required)
- discountCode: The discount code to look up (required)
What this endpoint checks:
- The code belongs to the specified customer in your store
The reward is returned whatever its status, so check the status field before you apply the code.
Reward statuses:
- UNUSED: Code has not been used yet
- USED: Code has already been used
- EXPIRED: Code has passed its expiry date
- SUBSCRIPTION_ACTIVE: Code is applied to an active subscription
- REFUNDED, CANCELED: Code can’t be applied
Integration pattern:
- Customer enters loyalty code at checkout
- Call this endpoint with the customer ID and code
- If the status is UNUSED, apply the discount in checkout
- Appstle sets the reward to USED by itself after a Shopify order uses up the code. For a sale outside Shopify, set the status with update-discount.
- Handle 400 by showing an error message to the customer
Common scenarios:
- Code found for this customer: 200 with the reward, whatever its status
- Code doesn’t exist, or belongs to a different customer: 400 “Discount is not found”
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{
"amount": 15,
"createAt": "2025-01-15T10:30:00Z",
"customerId": 67890,
"description": "$15 off coupon",
"discountCode": "LOYALTY15OFF",
"expireDate": "2025-06-30T23:59:59Z",
"id": 12345,
"pointRedeemRuleId": 5,
"rewardType": "DISCOUNT_CODE",
"status": "UNUSED",
"usedAt": null
}{
"status": 400,
"title": "Discount is not found"
}{
"detail": "Invalid authentication",
"status": 401
}Body
application/json
Request containing customer ID and discount code to validate
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
Reward found for this customer and code
⌘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{
"amount": 15,
"createAt": "2025-01-15T10:30:00Z",
"customerId": 67890,
"description": "$15 off coupon",
"discountCode": "LOYALTY15OFF",
"expireDate": "2025-06-30T23:59:59Z",
"id": 12345,
"pointRedeemRuleId": 5,
"rewardType": "DISCOUNT_CODE",
"status": "UNUSED",
"usedAt": null
}{
"status": 400,
"title": "Discount is not found"
}{
"detail": "Invalid authentication",
"status": 401
}