Balances, pending points, redemption options, discount codes and the total code.
A store credit is your program's currency, usually called Points. Balances and prices are in points, and a store credit's conversion rate says how many points equal one unit of your store currency. Customers spend points on your redemption options, each with a set price and reward, or turn an amount of their choice into a discount code.
getProgramReturns your program's name, default store credit, branding and tiers.getBalanceReturns the customer's balance in a store credit, ready to display.getPendingPointsLists points the customer has earned that Toki adds later, such as a purchase reward with a reward delay.getRedemptionOptionsLists the redemption options available to the customer, in the order you set.redeemByRuleSpends the customer's points on a redemption option and returns the reward, usually a discount code.redeemPointsTurns an amount of the customer's points into a single-use discount code worth their value in your store currency.getTotalCodeReturns the customer's total code: a personal discount code or gift card that spends their balance at checkout.getUnusedDiscountsLists the customer's unused discount codes in this store, newest first.Returns your program's name, default store credit, branding and tiers.
Works for guests. For a signed-in customer, storeCredit.conversionRate is the rate for their segment, and tiers marks the tiers they're in. storeCredit is your default store credit, the first one you created.
namestringYour store's name.
storeCreditStoreCreditidstringnamestringSuch as "Points", in the storefront language.
conversionRatenumberHow many points equal one unit of your store currency for this customer.
currency{ code: string; symbol: string }The currency for amounts of money, such as { code: "USD", symbol: "$" }.
rewardDisplayPreference"store_credit" | "usd" | "both"How your program shows amounts: in points ("store_credit"), in your store currency ("usd", whatever the currency is), or both, such as "200 Points ($2)".
brandBrand | nullYour branding from the Toki app; null until you set it.
namestring | nullYour brand name.
logoUrlstring | nullYour logo's URL.
coverImageUrlstring | nullYour cover image's URL.
tiersTier[]Your tiers and paid memberships, as getTiers() returns them.
Returns the customer's balance in a store credit, ready to display.
balance is in points. Divide it by conversionRate for its value in your store currency, or show displayValue, written the way your program shows amounts. Read the balance again on tokiWalletBalanceChanged.
When some of the customer's points have an expiration date, expirationDate and expirationAmount tell you when the next ones expire and how many.
storeCreditIdstringOne of your store credits. Defaults to your default store credit.
balancenumberIn points.
displayValuestringThe balance as your program shows it: "1,250 Points", "$12.50" or "1,250 Points ($12.50)", with non-breaking spaces.
namestringThe store credit's name.
storeCreditIdstringconversionRatenumberHow many points equal one unit of your store currency for this customer.
rewardDisplayPreference"store_credit" | "usd" | "both"How your program shows amounts: in points ("store_credit"), in your store currency ("usd", whatever the currency is), or both, such as "200 Points ($2)".
expirationDatestringOptionalWhen the next points expire, formatted for display, such as "Mar 3, 2027".
expirationAmountnumber | nullOptionalHow many points expire on expirationDate; null when it's the whole balance.
Lists points the customer has earned that Toki adds later, such as a purchase reward with a reward delay.
Each item says when Toki adds its points. Items with status "CANCELED" won't be added, for example because the order was canceled.
With aggregated: true, it resolves to one total per store credit instead, adding up the pending items. Totals have no date, description, activityName or orderId. When nothing is pending, it resolves to a single total with amount 0.
activityIdsstring[]Only points from these activities.
aggregatedbooleandefault falseAdd the pending points up per store credit.
amountnumberIn points.
formattedValuestringamount as your program shows it, like displayValue in getBalance().
status"PENDING" | "CANCELED"datestringWhen Toki adds the points, as an ISO 8601 date-time.
descriptionstringThe reward's name, or "Activity reward".
activityIdstringactivityNamestringorderIdstringOptionalThe order that earned the points, when they come from an order.
storeCreditStoreCreditThe store credit the points are in.
idstringnamestringconversionRatenumberHow many points equal one unit of your store currency for this customer.
currency{ code: string; symbol: string }The currency for amounts of money, such as { code: "USD", symbol: "$" }.
rewardDisplayPreference"store_credit" | "usd" | "both"How your program shows amounts: in points ("store_credit"), in your store currency ("usd", whatever the currency is), or both, such as "200 Points ($2)".
Lists the redemption options available to the customer, in the order you set.
Works for guests. Each customer sees the options available to them right now: those for everyone or for their segments, within their schedule and redemption limits, and offered in their market. Compare amountToSpend with the customer's balance to see which ones they can afford.
idstringPass it to redeemByRule() as ruleId.
type"discount" | "free-shipping" | "free-gift" | "collectible" | "custom" | "tremendous" | "shopify-store-credit"What the customer gets.
amountToSpendnumberThe price, in points of your default store credit.
rewardMessagestringThe reward in words, in the storefront language, such as "$5 Discount", "Free shipping" or "Gift: Tote bag". The reward's name when you gave it one.
descriptionstringYour description of the reward; empty when there's none.
productVariantIdsstring[]OptionalFree gifts: the Shopify variant IDs of the products the customer can choose from.
settingsobjectOptionalThe reward's settings, which depend on type. For a discount, settings.type is "absolute", "percentage", "buy-x-get-y" or "dynamic", settings.amount is its value as a string, such as "5", and settings.minimumPurchaseAmount is the subtotal the code needs, in your store currency, or null.
Spends the customer's points on a redemption option and returns the reward, usually a discount code.
Deducts the option's amountToSpend from the customer's balance in your default store credit and issues the reward. Discounts, free shipping and free gifts come with a single-use code. For a free gift, openUrl is a checkout link with the gift and its code applied; when the gift has several variants, pass the one the customer chose as productVariantId. For a custom reward, code is your message after redemption, for Shopify Store Credit a message with the amount added, and for a Tremendous gift card a message that it's on its way by email. A collectible goes to the customer's collectibles.
Rejects when the customer doesn't have enough points or the option isn't available to them.
ruleIdstringRequiredThe id of an option from getRedemptionOptions().
productVariantIdstringFree gifts with several variants: the Shopify variant ID the customer chose, one of the option's productVariantIds.
codestring | nullThe code, or the message to show for custom, Shopify Store Credit and Tremendous rewards; null for collectibles.
openUrlstring | nullFree gifts: a checkout link with the gift in the cart and its code applied.
Turns an amount of the customer's points into a single-use discount code worth their value in your store currency.
Deducts amount points and creates a fixed-amount discount code that works once, in any of your stores. The redemption rule that applies to the customer sets its limits: the smallest and largest code they can create, the cart subtotal it needs, and the collections it discounts. You set these per redemption rule on the Loyalty page.
Rejects when the code's value is outside those limits, the cart doesn't reach the minimum spend, or the customer doesn't have enough points.
amountnumberRequiredThe points to spend. The code is worth amount divided by the customer's conversion rate: $5 for 500 points at 100 points per dollar.
storeCreditIdstringThe store credit to spend. Defaults to your default store credit.
codestringThe discount code.
Returns the customer's total code: a personal discount code or gift card that spends their balance at checkout.
Toki creates the code the first time you ask for it and returns the same one until it's used. It's worth the customer's balance in your store currency, up to the maximum you set, and follows it as it changes; Toki deducts the points when an order uses it. A new code starts working at checkout shortly after it's created.
A discount code is good for one order; after that, the next call returns a new one. A gift card keeps its code. If the customer's balance drops below the minimum, the code is removed.
available is false when no redemption rule applies to the customer and their cart ("no-redemption-rule"), or when their balance is empty or below the rule's minimum ("not-enough-balance").
storeCreditIdstringThe store credit whose total code you want, when your redemption rules give total codes in more than one.
availablebooleanWhether the customer has a code.
codestringOptionalWhat the customer enters at checkout, when available is true.
type"discount_code" | "gift_card"OptionalWhether the code is a Shopify discount code or gift card.
reason"no-redemption-rule" | "not-enough-balance"OptionalWhy there's no code, when available is false.
minimumBalancenumberOptionalWith "not-enough-balance": the balance, in your store currency, the customer needs for a code.
Lists the customer's unused discount codes in this store, newest first.
Includes the codes the customer got from spending points, referrals, activities such as a birthday reward, and automations.
discountsUnusedDiscount[]idstringcodestringtitlestringA short label, such as "$5.00 Off", "15% Off" or "Free Shipping".