Skip to main content
This guide covers everything you need to build a production-ready integration with Appstle Loyalty. It walks through authentication, every major endpoint category, and common integration patterns for the most popular tool types (CRMs, email platforms, review apps) and headless storefronts.

Base URL

All Admin API endpoints share the same base:
Every endpoint is prefixed with /api/external/.
With a valid API key, a GET to a path under /api/external/ that has no GET endpoint returns 404, whether the path is mistyped or the endpoint takes another method. A POST, PUT or DELETE to a path that doesn’t take that method returns 405 with Request method 'PUT' not supported (or 'POST', 'DELETE'). If you get either, check the path and the method against the API reference.

Authentication

Direct integrations pass the merchant’s API key in the X-API-Key header. Merchants create keys under More → API Integrations in the Appstle admin. Each key is scoped to a single store, and up to 10 active keys are allowed per store.
Direct API access requires an active API plan. Contact support@appstle.com for details.

Point management

Orders earn points automatically

Appstle credits points for orders on its own, from Shopify’s order events and the merchant’s earning rules, so you don’t call the API for it. That includes orders placed on a custom or headless storefront, as long as the order belongs to a Shopify customer. One setting has to be on for this to work: the Appstle Loyalty app embed in the store’s live theme, even when customers never see that theme. In the Shopify admin, go to Online Store → Themes → Customize → App embeds, turn on Appstle Loyalty and click Save. Then open the Appstle Loyalty app in the Shopify admin once, so Appstle picks up the change.
While the app embed is off, Appstle skips the Shopify events that award points on their own:
  • Orders that don’t come from point of sale earn no points. Each one gets a failed earn-points entry in the activity log.
  • New Shopify customers aren’t enrolled and get no sign-up points.
  • Email and SMS marketing sign-ups earn no points.
  • Referral and reward emails aren’t sent.
Turning the embed on afterwards doesn’t reliably make up for what was skipped. Credit skipped orders with Add points or ask the merchant to re-sync them from the Orders page in the Appstle Loyalty app, and enroll skipped customers with Enroll a customer.

Look up a customer’s loyalty data

Retrieve a complete loyalty profile by Shopify customer ID or email.
The response includes available, pending, and credited points; current VIP tier; store credit balance; referral link; active rewards; and social engagement status.

Add points

Credit points to a customer’s account. Include a note so the transaction is labeled clearly in the customer’s history.
Send customerId or customerEmail, and a points value greater than 0. When you send both customer fields, Appstle uses customerId. The call returns the customer’s loyalty details with the new balance. The customer has to be in the store’s loyalty customer list, but Appstle doesn’t check their customerStatus. A customer the merchant excluded (EXCLUDED) or who opted out (EXCLUDED_BY_CUSTOMER) still gets the points, and the call returns 200. To skip those customers, read customerStatus with Get customer loyalty details first. Remove points doesn’t check customerStatus either. A refused request returns 400 with the reason in title, and adds no points. message is always error., so read title: The titles Customer info missing and Points missing end with a space, so trim title before you compare it. add-points has no idempotency key, so sending the same call twice adds the points twice. After a timeout or a 5xx error, check the customer’s balance or transaction history before you send the call again. HTTP status codes lists the other status codes.

Redeem points for a reward

Convert a customer’s points into a reward, such as a discount code or store credit, using a configured redemption rule.
To get the list of valid redeemRuleId values, call GET /api/external/point-redeem-rules (see Program configuration below). Most rules have a fixed cost and a fixed reward: the call spends the rule’s redeemPoints and ignores any points you send, store credit rules included. A DYNAMIC_DISCOUNT rule is the exception. For it, send the number of points to spend as points. It’s required, it must be positive, and the customer must have that many available. The rule’s minimum and maximum points limits apply too. The customer gets a discount code worth the rule’s discount for every redeemPoints points.

Get transaction history

Retrieve a customer’s full point transaction log.

Approve pending transactions

For programs where points require approval before becoming available, use this endpoint to move pending points to available. Send the transactions to approve as an array. Pending transactions have the status PENDING in the transaction history.
To approve every pending transaction in your store, send no body and add ?approveAllPendingTransactions=true instead. The approval runs in the background, and the endpoint returns 204 No Content.

Customer management

Enroll a customer

Add a customer to the loyalty program. Call this before attempting to add points to a customer who has not yet joined. Pass the Shopify customer ID in the customer_id query parameter.
Enrolling a customer also adds the store’s enrollment tags, such as Appstle Loyalty Member, to their Shopify customer profile. See Enrollment tags. Every enrolled customer has a referralLink in Get customer loyalty details. It’s a short link in the form https://referral.appstle.com/{token}, or on the merchant’s own domain when they’ve set one up under Custom Referral Domain in the Referrals settings. The last part of the link is the customer’s referral token. When a friend opens the link, it redirects to the store’s primary domain in Shopify, with the token in the query string:
If the merchant shows the loyalty program on a dedicated page instead of the launcher widget, the redirect goes to that page (/apps/loyalty by default). The redirect never goes to another domain. How the friend’s acceptance reaches Appstle depends on where your code runs:
  • A theme with the app embed on. The Appstle Loyalty widget reads appstle_referral_code and accepts the referral itself, with the signed-in customer’s email or one the friend enters.
  • Your own page on the merchant’s Shopify storefront. Read appstle_referral_code and send it as token to Accept referral offer. That’s a Storefront API endpoint: call it from the shopper’s browser through the App Proxy, without your API key.
  • A headless storefront, or any server. There’s no App Proxy to call, so use the Admin API: accept the referral from your server and read the referral history.
The merchant’s referral settings decide when each customer is rewarded. With When referred friend accepts the invitation, both are rewarded as soon as the friend accepts. With the purchase-based options, both are rewarded after the friend’s qualifying purchase, unless the merchant chooses to reward one of them on acceptance instead. A reward can be points, a discount code or store credit.

Accept a referral from your server

Call Accept a referral invite when a friend arrives through a referral link and gives you their email. Send the referral token as token and the friend’s email as email. The call needs a Read & write API key (Key permissions), so make it from your server and never put the key in browser code. The call doesn’t check that email is a valid address, so validate it before you call. The referral link lands on the store’s primary domain in Shopify, so open one to see where it lands. If that’s your storefront, read appstle_referral_code from the landing URL. If it isn’t, or it lands on a path your storefront doesn’t serve, share a link of your own: the token is the last part of referralLink, so put it in a URL on your site, such as https://www.example.com/?ref={token}, and read it from there. Either way, keep the token in a cookie or the session until the friend gives you their email.
On success, Appstle:
  • Creates the referral with the status PENDING, and issues any reward the merchant set to be given on acceptance. When the program rewards both customers on acceptance, the referral is already CLAIMED when the call returns.
  • Creates a Shopify customer for the friend’s email when the store has none. Appstle enrolls that customer in the loyalty program shortly after, the way it enrolls every new Shopify customer, so only while the app embed is on. existingCustomer is true when the email already belonged to a customer.
  • Tags both customers: referral:{friend's customer ID} on the referrer and referred:{referrer's customer ID} on the friend (see Referral tags).
discountCode is null unless the merchant has asked Appstle support to return the friend’s reward code and the friend got a discount code on acceptance. Then it holds the friend’s own code, never the referrer’s. id is always null: to find the referral record, read the referral history. To show the friend their reward on your site, call Get customer loyalty details with customerEmail once they’re enrolled: a discount code reward is in rewards. Appstle also emails both customers, with the discount code when the reward has one, but only while the Appstle Loyalty app embed is on in the store’s live theme. A friend who qualifies through a purchase is rewarded when they place a qualifying order with the same email, and you make no further call. Like order points, these rewards need the app embed on, even on a headless store that never shows the theme: see Orders earn points automatically. The call can take several seconds, because Appstle creates the friend’s customer and issues any reward before it answers, so give it a generous timeout. If it times out anyway, send it again: when the first call went through, the retry returns ALREADY_REFERRED and the referral shows in the referrer’s history.

Refused referrals

A refused referral and a request Appstle can’t process both return 400, with different bodies. A refusal has "status": "FAILED" and the reason in message. A request with an empty token or email gets a problem response instead (Content-Type: application/problem+json), with the reason in title. Appstle trims spaces around email, then checks the address before the token, so a malformed address returns INVALID_EMAIL even when the token is also wrong. To check an address before you call, match Appstle’s rule: a name, @, then a domain with at least one dot whose last part is two or more letters, such as nora@example.com.
An empty token or email returns this problem response:
In a FAILED response, errorKey is INVALID_EMAIL, SELF_REFERRAL or ALREADY_REFERRED for those three causes and null for the rest, so match on it rather than on the English message. Read errorKey only when status is FAILED: the problem response has the string "null" there. A FAILED response is Appstle’s answer to that request, so show the friend a message instead of retrying it. The one exception is the store’s daily limit: every accept with a valid token and a well-formed email counts toward it, refused ones and retries included, and once the store reaches it, every accept returns An error occurred while processing the request. until 00:00 UTC. If you accept many referrals for one store, for example in an import, spread them over several days. An invalid key returns 401, and a Read only key returns 403 (see Authentication errors).

Show referral history for a customer

Call Get a customer’s referral history from your server with the referrer’s Shopify customer ID to list the referrals they’ve sent. A Read only key is enough.
  • status is PENDING until the referral is rewarded, and CLAIMED once every reward the program gives for it has been issued. On a subscription referral program with Give rewards for recurring order turned on, the referral becomes RECURRING instead, as soon as either customer is rewarded.
  • referralRewarded and referredRewarded say whether the referrer and the friend have received their reward. claimAt is empty until the referral is CLAIMED.
  • referredEmailId is masked (*** when the stored value isn’t an email address), because the list is meant to be shown to the referrer. Keep the friend’s real email from your own referral-accept call if you need it.
  • description, referralRuleId, referralNote, referredNote, orderCount and pixelData are always null in this response.
  • Page through the list with page (from 0) and size, and send sort=createAt,desc for the newest first. Without sort, the order isn’t guaranteed. Name a property the referral has, in camelCase: a sort that names no such property, such as create_at, returns 400 with errorKey invalidSort. Omit page and size to get the first 20.
  • The total count is in the X-Total-Count response header, and the Link header has the URLs of the first and last pages, and of the next and previous pages when they exist.
  • A call without customerId returns 400. A customer ID with no referrals returns an empty list.

Update a customer’s birthday

Set a date of birth in dob to enable birthday reward automation. Date format is YYYY-MM-DD. If you only know the month and day, send any year and set dobYearProvided to false.

Get top customers

Retrieve your loyalty members ranked by points earned, most first. Page through the list with page (from 0) and size. The order is fixed, so leave out sort. A loyalty customer property such as createAt is ignored, and any other name returns 400 with errorKey invalidSort, including the list’s own pointsEarned.

Rewards and discounts

Check a discount code

Look up a loyalty discount code that belongs to a customer, for example before applying it at checkout. The response is the reward record, including its status (such as UNUSED or USED). If the code doesn’t belong to that customer, the API returns 400.

Change a reward’s status

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’s orderId and orderName and the time in usedAt. You don’t need to call the API for orders placed through Shopify. 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, call PUT /api/external/update-discount:
customerId, discountCode and status are all required. The call returns 200 with the reward in its new status (trimmed):
The status decides whether the code works 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 and 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. Appstle Subscriptions sets this status when a Loyalty reward code is applied to a subscription. 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, whose discountCodeId starts with gid://shopify/DiscountRedeemCodeBulkCreation/. A code that is a Shopify discount of its own (gid://shopify/DiscountCodeNode/...) keeps working whatever its status. No status gives points back, and no webhook event reports a status change. A reward that is already USED can’t be changed with this call: every request for it returns 400 with the title Discount is already used., a second USED included. If you get that 400 when you retry a timed-out USED request, call check-discount: a reward that shows USED was marked by your first request or by an order. If no reward matches customerId and discountCode, nothing changes and the call returns 400 with the title Discount is not found. A request without status, or with a status that isn’t one of the six values, also returns 400. Appstle matches the code without regard to case, and the reward keeps the spelling you send, so send the code exactly as issued. The older PUT /api/external/update-discount-code-status takes the same body and also accepts customerEmail instead of customerId. If you send both, Appstle uses customerId. It returns the customer’s loyalty details instead of the reward. Like update-discount, it sets usedAt to the time of the call for USED and clears it for UNUSED on a code that was never used. Checkout follows the new status as it does for update-discount, whether you send customerId or customerEmail. It never adds or deletes the code in Shopify. A reward that is already USED can’t be changed (400 with the title Discount is already used.), except that a request for USED again returns 200 and changes nothing, so you can retry a timed-out call. A code that isn’t found returns 400 with the title Discount is not found. A request without discountCode or status, with a status that isn’t one of the six values, with neither customerId nor customerEmail, or for a customer who isn’t enrolled also returns 400, with the reason in title.
No Admin API call gives a reward’s points back: CANCELED and REFUNDED change only the status. A signed-in customer can return an unused reward for its points through the Storefront API, and that call has no API-key version.

Store credits

Add store credits

Credit a monetary amount to a customer’s store credit balance. Credits are applied at checkout and are separate from loyalty points.
It returns 200 with the same body as Get customer loyalty details, including the new storeCreditBalance. If Shopify refuses the credit, for example because it would take the balance over Shopify’s store credit limit, the credit isn’t added and the call still returns 200. To confirm the credit, check that storeCreditBalance in the response went up by the credits you sent.

Program configuration

Get point earn rules

Retrieve all active point earn rules for your store. Use the returned id values when calling add-points with a specific rule.

Get point redeem rules

Retrieve all active redemption options. Use the returned id values as redeemRuleId when redeeming points. A rule’s ruleStartDate and ruleEndDate are ISO 8601 date-times, or null when the reward has no dates. Outside them, a redeem returns 400 with the title UserGeneratedError:This reward isn't available yet. or UserGeneratedError:This reward has ended., so offer a reward only between the two. The list can include a FREE_SHIPPING rule whose maximumShippingRate is 0 or less. That rule can’t be redeemed, so skip it.

Rate limits

The Admin API returns 429 Too Many Requests in three cases:
  • Per-minute rate limit. Each store gets 600 calls a minute, Admin API and Storefront API calls together, and 60 calls a minute to any one endpoint. Paths that differ only in a numeric ID count as one endpoint, and the query string doesn’t count, so every customer-loyalty lookup for the store shares one limit. Once an endpoint has returned five errors (status 400 or higher) for the store within a minute, its limit drops to 10. Treat these numbers as the most you should send. Over a limit, the body is {"error":"Rate limit exceeded. Try again later."} and there’s no Retry-After header. Retry with exponential backoff, never immediately.
  • Too many PUT calls at once. Send no more than five PUT calls at a time for one store. Above that, the body is {"error":"Too many concurrent mutation requests. Please wait for existing requests to complete."} and there’s no Retry-After header. Wait for your other PUT calls to finish, then retry with exponential backoff.
  • Daily call allowance. This applies only to stores that have one. The response has a Retry-After header with the seconds left until 00:00 UTC, when the allowance resets. Stop calling until then, because retrying sooner can’t succeed. Calls made with a partner token don’t count toward it.
Accepting a referral also has a daily limit for each store, which returns 400 with "status": "FAILED" instead of 429: see Refused referrals.

Common integration patterns

  1. Customer submits a review on your platform.
  2. Your platform calls POST /api/external/add-points to credit points.
  3. Optionally, use the Shopify Flow reward-points-for-reviews action for a no-code setup that does not require API calls.
  1. Call GET /api/external/customer-loyalty by customer email or ID to display loyalty status alongside the ticket.
  2. Call POST /api/external/add-points or POST /api/external/add-credits to issue goodwill adjustments.
  3. Call GET /api/external/point-transaction-history/{customer_id} to show recent activity in context.
  1. For Klaviyo, connect it in the Appstle Loyalty admin. Appstle then sends its loyalty emails to Klaviyo as events that you build flows on (see Klaviyo events). For other platforms, use webhooks to receive real-time point and tier events for trigger-based campaigns.
  2. Call GET /api/external/customer-loyalty to enrich customer profiles with points balance, VIP tier, and referral link.
  3. Segment customers by currentVipTier or availablePoints range for targeted sends.
  1. From your server, call GET /api/external/customer-loyalty and show the customer’s referralLink, or a link to your own site with the token from the end of referralLink.
  2. When a friend lands with the token, keep it until they give you their email. Then call POST /api/external/referral-accept from your server with both.
  3. From your server, call GET /api/external/customer-referrals with sort=createAt,desc to show the referrer their referrals and each one’s status.
  1. The customer signs in to your app, and your server works out which Shopify customer they are from that sign-in. Never look up a customer ID or email the app sends without checking it.
  2. From your server, call GET /api/external/customer-loyalty with their customerId or customerEmail, and send the points, VIP tier and rewards to the app. Call it when the customer opens the rewards screen, not on every app launch: all of the store’s lookups share one per-minute limit (see Rate limits).
  3. A customer who isn’t in the program yet gets 400 with the title Customer not found using this customerID, or Customer not found using this email for a lookup by email. Don’t retry the lookup, because each 400 counts toward the errors that lower the limit. Show a way to join instead, and enroll them with Enroll a customer.
  4. To redeem, call POST /api/external/redeem-points from your server. It returns the customer’s updated loyalty data, the same as customer-loyalty, so you don’t need another lookup.
  5. Keep the API key or partner token on your server, never in the app. Don’t call the Storefront API from the app: it works only for a customer signed in to the store in a browser. To show the store’s loyalty page inside the app instead, see Mobile apps and in-app browsers.

Becoming a partner

If your product integrates with loyalty programs, Appstle offers a formal partner program:
  • Zero-friction merchant onboarding via the Partner Integration Framework
  • Scoped API tokens per merchant — no manual key exchange
  • Merchants are never charged for partner API usage
  • Technical support, co-marketing opportunities, and directory listing
To get onboarded, email support@appstle.com with your company name, product description, base URL, and contact email. The Partner integration guide lists the complete onboarding requirements and implementation steps.

Next steps

Webhooks

Receive an event on your server when a customer joins, earns or redeems points, reaches a VIP tier or gets a referral reward.

Shopify Flow

Award points, assign VIP tiers and issue store credits without API code.

Klaviyo events

The events Appstle Loyalty sends to Klaviyo, when each is sent and the properties it carries.

Partner integration

Connect your platform and receive scoped API tokens for merchants.