Update discount code status
Sets the status of one of a customer’s rewards, found by customerId and discountCode, and returns the reward.
Appstle sets a reward to USED by itself shortly after a Shopify order uses up its code (after one use, unless the redeem rule allows more), and saves the order and usedAt on the reward. Call this endpoint to set a status yourself, for example to mark a code used in a sale outside Shopify or to cancel a reward without giving its points back. Appstle Subscriptions also calls it, with SUBSCRIPTION_ACTIVE, when a Loyalty reward code is applied to a subscription.
Request body:
- customerId: Shopify customer ID of the reward’s owner (required)
- discountCode: The reward’s discount code (required). The lookup ignores case, and the reward keeps the spelling you send, so send the code exactly as issued.
- status: The new status (required). A request without status, or with a value that isn’t one of the six statuses, returns 400.
What each status does at checkout:
- UNUSED: the code applies at checkout. If SUBSCRIPTION_ACTIVE took the code off its redeem rule’s discount in Shopify, Appstle asks Shopify to add it back. usedAt is cleared if the code was never used.
- USED, EXPIRED, REFUNDED, CANCELED: the code stops applying at checkout, although it stays on the discount in Shopify. USED set this way sets usedAt to the time of the call; this call never changes orderId or orderName.
- SUBSCRIPTION_ACTIVE: Appstle asks Shopify to delete the code from its redeem rule’s discount, and returns 200 even if Shopify refuses. Don’t send it yourself; send UNUSED to undo it.
The change applies at checkout as soon as the call returns. This holds for a code on its redeem rule’s discount (discountCodeId starts with gid://shopify/DiscountRedeemCodeBulkCreation/). A code that is a Shopify discount of its own (discountCodeId starts with gid://shopify/DiscountCodeNode/) keeps working whatever its status. No status gives points back. On success the call also writes an entry to the customer’s activity log.
Errors:
- A reward that is already USED can’t be changed. Every request for it returns 400 “Discount is already used.”, including a second request for USED.
- A code that doesn’t exist, or that belongs to another customer, changes nothing and returns 400 “Discount is not found”.
curl --request PUT \
--url https://loyalty-admin.appstle.com/api/external/update-discount \
--header 'Content-Type: application/json' \
--data '
{
"customerId": 67890,
"discountCode": "LOYALTY15OFF",
"status": "USED"
}
'import requests
url = "https://loyalty-admin.appstle.com/api/external/update-discount"
payload = {
"customerId": 67890,
"discountCode": "LOYALTY15OFF",
"status": "USED"
}
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', status: 'USED'})
};
fetch('https://loyalty-admin.appstle.com/api/external/update-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/update-discount';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({customerId: 67890, 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",
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',
'status' => 'USED'
]),
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/update-discount"
payload := strings.NewReader("{\n \"customerId\": 67890,\n \"discountCode\": \"LOYALTY15OFF\",\n \"status\": \"USED\"\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/update-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 \"status\": \"USED\"\n}"
response = http.request(request)
puts response.read_body{
"activeFrom": null,
"amount": null,
"createAt": "2026-11-15T14:52:03.082685Z",
"customerId": 67890,
"description": "$5.00 off your order",
"discountCode": "LOYALTY5OFF",
"discountCodeId": "gid://shopify/DiscountRedeemCodeBulkCreation/1234567890",
"expireDate": null,
"id": 123456,
"lastExpiryReminderSentDate": null,
"orderId": null,
"orderName": null,
"pointRedeemRuleId": 1234,
"pointTransactionId": 2345678,
"productData": null,
"rewardType": "DISCOUNT_CODE",
"shop": "your-store.myshopify.com",
"status": "CANCELED",
"usageCount": null,
"usedAt": null,
"variantId": null
}{
"message": "error.",
"params": "",
"status": 400,
"title": "Discount is already used.",
"type": "https://appstle.com/problem/problem-with-message"
}{
"detail": "Invalid authentication",
"status": 401
}Body
Request containing customer ID, discount code, and new status
New status for the reward. One of USED, UNUSED, EXPIRED, REFUNDED, CANCELED or SUBSCRIPTION_ACTIVE. The operation description says what each one does at checkout. A reward that is already USED can't be changed.
USED, UNUSED, REFUNDED, EXPIRED, SUBSCRIPTION_ACTIVE, CANCELED "USED"
Response
The reward with its new status.
curl --request PUT \
--url https://loyalty-admin.appstle.com/api/external/update-discount \
--header 'Content-Type: application/json' \
--data '
{
"customerId": 67890,
"discountCode": "LOYALTY15OFF",
"status": "USED"
}
'import requests
url = "https://loyalty-admin.appstle.com/api/external/update-discount"
payload = {
"customerId": 67890,
"discountCode": "LOYALTY15OFF",
"status": "USED"
}
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', status: 'USED'})
};
fetch('https://loyalty-admin.appstle.com/api/external/update-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/update-discount';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({customerId: 67890, 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",
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',
'status' => 'USED'
]),
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/update-discount"
payload := strings.NewReader("{\n \"customerId\": 67890,\n \"discountCode\": \"LOYALTY15OFF\",\n \"status\": \"USED\"\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/update-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 \"status\": \"USED\"\n}"
response = http.request(request)
puts response.read_body{
"activeFrom": null,
"amount": null,
"createAt": "2026-11-15T14:52:03.082685Z",
"customerId": 67890,
"description": "$5.00 off your order",
"discountCode": "LOYALTY5OFF",
"discountCodeId": "gid://shopify/DiscountRedeemCodeBulkCreation/1234567890",
"expireDate": null,
"id": 123456,
"lastExpiryReminderSentDate": null,
"orderId": null,
"orderName": null,
"pointRedeemRuleId": 1234,
"pointTransactionId": 2345678,
"productData": null,
"rewardType": "DISCOUNT_CODE",
"shop": "your-store.myshopify.com",
"status": "CANCELED",
"usageCount": null,
"usedAt": null,
"variantId": null
}{
"message": "error.",
"params": "",
"status": 400,
"title": "Discount is already used.",
"type": "https://appstle.com/problem/problem-with-message"
}{
"detail": "Invalid authentication",
"status": 401
}