Update discount code status (legacy endpoint)
Updates the status of a customer’s reward, found by discountCode and customerId or customerEmail, and returns the customer’s loyalty details. This is the older version of update-discount. It saves the status (USED, UNUSED, EXPIRED, REFUNDED, CANCELED or SUBSCRIPTION_ACTIVE), sets usedAt to the current time when the status is USED, and clears usedAt when the status is UNUSED and the code was never used. Checkout follows the new status as it does for update-discount, but the code is never added to or deleted from a discount in Shopify, and no points are returned. A reward that is already USED can’t be changed (400 “Discount is already used.”), except that a request for USED again returns 200 and changes nothing. A code that isn’t found returns 400 “Discount is not found”. A customer that isn’t found, or a request with neither customerId nor customerEmail, returns 400. A request without discountCode or status, or with a status that isn’t one of the six values, returns 400.
curl --request PUT \
--url https://loyalty-admin.appstle.com/api/external/update-discount-code-status \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"discountCode": "LOYALTY15OFF",
"status": "USED"
}
'import requests
url = "https://loyalty-admin.appstle.com/api/external/update-discount-code-status"
payload = {
"discountCode": "LOYALTY15OFF",
"status": "USED"
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({discountCode: 'LOYALTY15OFF', status: 'USED'})
};
fetch('https://loyalty-admin.appstle.com/api/external/update-discount-code-status', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://loyalty-admin.appstle.com/api/external/update-discount-code-status';
const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({discountCode: 'LOYALTY15OFF', status: 'USED'})
};
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/update-discount-code-status",
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([
'discountCode' => 'LOYALTY15OFF',
'status' => 'USED'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-key>"
],
]);
$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/update-discount-code-status"
payload := strings.NewReader("{\n \"discountCode\": \"LOYALTY15OFF\",\n \"status\": \"USED\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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/update-discount-code-status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"discountCode\": \"LOYALTY15OFF\",\n \"status\": \"USED\"\n}"
response = http.request(request)
puts response.read_body{
"achievableTierId": 123,
"availablePoints": 123,
"createAt": "2023-11-07T05:31:56Z",
"creditedPoints": 123,
"currentVipTier": "<string>",
"customerStatus": "ACTIVE",
"dob": "2023-12-25",
"dobYearProvided": true,
"expiringPointsAmount": 123,
"pendingPoints": 123,
"pointsExpireAt": "2023-11-07T05:31:56Z",
"referralLink": "https://referral.appstle.com/abc123def456ghij",
"referredCompleted": 123,
"rewardedForCreatingAccount": true,
"rewardedForFacebook": true,
"rewardedForInstagram": true,
"rewardedForNewsLetter": true,
"rewardedForPinterest": true,
"rewardedForSharingOnFacebook": true,
"rewardedForSharingOnX": true,
"rewardedForSms": true,
"rewardedForTiktok": true,
"rewardedForTwitter": true,
"rewardedForYoutube": true,
"rewards": [
{
"createAt": "2023-11-07T05:31:56Z",
"customerId": 123,
"discountCode": "<string>",
"shop": "<string>",
"status": "USED",
"activeFrom": "2023-11-07T05:31:56Z",
"amount": 123,
"description": "<string>",
"discountCodeId": "<string>",
"expireDate": "2023-11-07T05:31:56Z",
"id": 123,
"lastExpiryReminderSentDate": "2023-11-07T05:31:56Z",
"orderId": 123,
"orderName": "<string>",
"pointRedeemRuleId": 123,
"pointTransactionId": 123,
"productData": "<string>",
"rewardType": "STORE_CREDIT",
"usageCount": 123,
"usedAt": "2023-11-07T05:31:56Z",
"variantId": 123
}
],
"spentAmount": 123,
"storeCreditBalance": 123,
"storeCreditCurrency": "<string>",
"vipTierExpiredAt": "2023-11-07T05:31:56Z",
"vipTierOrderCount": 123,
"vipTierSpentAmount": 123
}Body
Request containing customer ID/email, discount code, and new status
Response
Discount code status updated and customer loyalty details returned
The customer's short referral link, on https://referral.appstle.com/ or the merchant's custom referral domain. Its last part is the customer's referral token, which Accept referral offer takes as token. The link redirects to the store's primary domain with appstle_referral=true and appstle_referral_code={token} in the query string.
"https://referral.appstle.com/abc123def456ghij"
curl --request PUT \
--url https://loyalty-admin.appstle.com/api/external/update-discount-code-status \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"discountCode": "LOYALTY15OFF",
"status": "USED"
}
'import requests
url = "https://loyalty-admin.appstle.com/api/external/update-discount-code-status"
payload = {
"discountCode": "LOYALTY15OFF",
"status": "USED"
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({discountCode: 'LOYALTY15OFF', status: 'USED'})
};
fetch('https://loyalty-admin.appstle.com/api/external/update-discount-code-status', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://loyalty-admin.appstle.com/api/external/update-discount-code-status';
const options = {
method: 'PUT',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({discountCode: 'LOYALTY15OFF', status: 'USED'})
};
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/update-discount-code-status",
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([
'discountCode' => 'LOYALTY15OFF',
'status' => 'USED'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <x-api-key>"
],
]);
$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/update-discount-code-status"
payload := strings.NewReader("{\n \"discountCode\": \"LOYALTY15OFF\",\n \"status\": \"USED\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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/update-discount-code-status")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"discountCode\": \"LOYALTY15OFF\",\n \"status\": \"USED\"\n}"
response = http.request(request)
puts response.read_body{
"achievableTierId": 123,
"availablePoints": 123,
"createAt": "2023-11-07T05:31:56Z",
"creditedPoints": 123,
"currentVipTier": "<string>",
"customerStatus": "ACTIVE",
"dob": "2023-12-25",
"dobYearProvided": true,
"expiringPointsAmount": 123,
"pendingPoints": 123,
"pointsExpireAt": "2023-11-07T05:31:56Z",
"referralLink": "https://referral.appstle.com/abc123def456ghij",
"referredCompleted": 123,
"rewardedForCreatingAccount": true,
"rewardedForFacebook": true,
"rewardedForInstagram": true,
"rewardedForNewsLetter": true,
"rewardedForPinterest": true,
"rewardedForSharingOnFacebook": true,
"rewardedForSharingOnX": true,
"rewardedForSms": true,
"rewardedForTiktok": true,
"rewardedForTwitter": true,
"rewardedForYoutube": true,
"rewards": [
{
"createAt": "2023-11-07T05:31:56Z",
"customerId": 123,
"discountCode": "<string>",
"shop": "<string>",
"status": "USED",
"activeFrom": "2023-11-07T05:31:56Z",
"amount": 123,
"description": "<string>",
"discountCodeId": "<string>",
"expireDate": "2023-11-07T05:31:56Z",
"id": 123,
"lastExpiryReminderSentDate": "2023-11-07T05:31:56Z",
"orderId": 123,
"orderName": "<string>",
"pointRedeemRuleId": 123,
"pointTransactionId": 123,
"productData": "<string>",
"rewardType": "STORE_CREDIT",
"usageCount": 123,
"usedAt": "2023-11-07T05:31:56Z",
"variantId": 123
}
],
"spentAmount": 123,
"storeCreditBalance": 123,
"storeCreditCurrency": "<string>",
"vipTierExpiredAt": "2023-11-07T05:31:56Z",
"vipTierOrderCount": 123,
"vipTierSpentAmount": 123
}