client
Interfaces
CustomerRewardsPage
One page of getRewards(); pagination describes redeemed only.
Extends
Properties
available
available: AvailableReward[];Inherited from
customerPoints
customerPoints: number;The customer's balance, so a dynamic reward's slider can stop at the
largest whole step they can afford without a second call to /customer.
Inherited from
CustomerRewards.customerPoints
pagination
pagination: Pagination;redeemed
redeemed: RedeemedReward[];Inherited from
GetActivitiesParams
Cursor-pagination params for JoyClient.getActivities.
Properties
after?
after?: string;Return the page AFTER this activity id.
before?
before?: string;Return the page BEFORE this activity id.
limit?
limit?: number;Page size.
GetFreeGiftStockOptions
Options for JoyClient.getFreeGiftStock.
Properties
country?
country?: string;2-letter buyer country (ISO 3166-1 alpha-2, e.g. CN) so the server can
filter stock by Storefront market availability (@inContext(country)).
Omit to skip market filtering (server default: no market context).
GetImpactHistoryParams
Cursor-pagination params for JoyClient.getImpactHistory.
Properties
after?
after?: string;Return the page AFTER this impact-event id.
before?
before?: string;Return the page BEFORE this impact-event id.
limit?
limit?: number;Page size (default 20, clamped to 50 server-side).
GetInfoParams
Options for JoyClient.getInfo.
Properties
earnSignup?
earnSignup?: boolean;Ask /info to run signup-earn processing for this member (isEarnSignup=true,
the headless spelling of Liquid's su flag). The backend no longer forces it on
every member call, so send it ONCE per signed-in session — on the /info that
follows login / the first member load — not on every page view.
includeStoreCredit?
includeStoreCredit?: boolean;Include per-currency Store Credit balances — costs an extra Shopify call.
skipFields?
skipFields?: string[];Skip fetching these top-level response fields server-side — mirrors handleGetInfo's
own m list-skip (e.g. ['settings'] when the caller already has fresh settings from
elsewhere and only wants the rest).
GetReceivedRewardsParams
Cursor-pagination params for JoyClient.getReceivedRewards.
Properties
after?
after?: string;Return the page AFTER this gift id.
before?
before?: string;Return the page BEFORE this gift id.
limit?
limit?: number;Page size (default 10, clamped to 50 server-side).
GetReferralHistoryParams
Cursor-pagination params for JoyClient.getReferralHistory.
Properties
after?
after?: string;Return the page AFTER this referral-row id.
before?
before?: string;Return the page BEFORE this referral-row id.
GetRewardsParams
Options for JoyClient.getRewards. Paginates the redeemed list.
Properties
after?
after?: string;Return the page AFTER this reward id. Ignored when couponStatus is 'unavailable'.
before?
before?: string;Return the page BEFORE this reward id. Ignored when couponStatus is 'unavailable'.
couponStatus?
couponStatus?: "available" | "unavailable";Which coupons redeemed holds. 'available' (the default) is the
customer's live, still-usable coupons — omitting this param is identical.
'unavailable' is the used + expired ones, merged and deduped, mirroring
the widget's "Unavailable" tab. pagination.hasNext can be true, but
it is not pageable: before/after are ignored and there is currently no
cursor to fetch a next page. Consumers must not use this flag for a Next control.
limit?
limit?: number;Page size for redeemed.
GetStoreCreditTransactionsParams
Cursor-pagination params for JoyClient.getStoreCreditTransactions.
Properties
after?
after?: string;Return the page AFTER this Shopify cursor.
before?
before?: string;Return the page BEFORE this Shopify cursor.
limit?
limit?: number;Page size (default 10, clamped to 50 server-side).
JoyClient
Personalised client over the Bearer-JWT /customer/* endpoints.
Properties
isLoggedIn
readonly isLoggedIn: boolean;true while a token is held; flips to false after an unrecoverable 401.
Methods
cancelRedeem()
cancelRedeem(rewardId): Promise<CancelRedeemResult>;POST /customer/rewards/{rewardId}/cancel — cancel a cart redemption (Liquid
/popup/cancel-redeem parity): deactivates the unused code and refunds its points,
with no self-revoke limit. Used by <JoyRedeemCart>; Loyalty Page keeps revokeReward.
Parameters
| Parameter | Type |
|---|---|
rewardId | string |
Returns
Promise<CancelRedeemResult>
checkSegmentPrograms()
checkSegmentPrograms(segmentPrograms): Promise<SegmentEligibility>;POST /customer/segment-program — "is this customer inside the Shopify
segments that gate these spending programs?", answered as
{programId: boolean}.
Call it before showing a redeem list: a program whose userAvailability
is user_in_segment is otherwise rendered with a Redeem button that the
server will refuse. Programs with no segment gate do not belong in the
request.
A program the server could not establish membership for comes back
false (fail-closed). At most 50 entries per call; more is a BAD_REQUEST.
Parameters
| Parameter | Type |
|---|---|
segmentPrograms | SegmentProgramQuery[] |
Returns
Promise<SegmentEligibility>
claimBirthdayReward()
claimBirthdayReward(birthdayRewards?): Promise<BirthdayClaimResult>;POST /customer/birthday/claim — claim this customer's ANNUAL birthday
reward, for a program the merchant put on manual delivery (the shopper
pressing "Claim" during their birthday claim period). Pass birthdayRewards
to save the selection and claim in one shot; omit it when
JoyClient.setBirthdayRewards already stored it.
The reward is minted ASYNCHRONOUSLY: a resolved promise means the claim was ACCEPTED, NOT that a coupon exists. Re-fetch JoyClient.getCustomer and JoyClient.getRewards for the outcome — anything that reads a coupon straight off this call will read stale data.
Not JoyClient.earn. That endpoint ACCEPTS a birthday program, but does a different job: it records the birthday DATE and pays the one-off "completed your birthday info" bonus. It never mints the annual reward, because the guards that make the annual reward safe to expose (manual delivery, tier opt-out, once a year, inside the claim period) live only behind this route.
Every DELIBERATE refusal collapses to one CLAIM_UNAVAILABLE (400) with a
generic message — no program, automatic delivery, tier opted out, already
claimed this year, outside the claim period are NOT told apart, so a client
cannot probe a shop's birthday configuration. Treat it as "not available
right now" and show the server's message; do not retry.
CLAIM_FAILED (502) is the opposite and IS worth retrying: the claim was
eligible and a Firestore/Shopify call underneath it failed. Re-fetch before
retrying — the shopper's reward picks may already have been committed.
Also BAD_REQUEST (400) for a malformed map and NOT_ELIGIBLE (403) for
an opt-in guest who has not joined the loyalty program.
Parameters
| Parameter | Type |
|---|---|
birthdayRewards? | BirthdayRewardsMap |
Returns
Promise<BirthdayClaimResult>
claimMilestone()
claimMilestone(input): Promise<MilestoneClaimResult>;POST /customer/milestone/claim — claim a REACHED milestone step's reward. The reward is resolved SERVER-SIDE from the program and the customer's pending milestones: MilestoneClaimInput carries selections only, no reward definitions, so a crafted body can never inflate what is granted. The customer is taken from the token, so a client can never claim on behalf of anyone else.
Rejects (400) when the step is unknown or the milestone has not been reached (not yet claimable), and (400) when a free-gift step needs a variant selection the body did not carry.
Parameters
| Parameter | Type |
|---|---|
input | MilestoneClaimInput |
Returns
Promise<MilestoneClaimResult>
claimMilestoneStep()
claimMilestoneStep(programId, input): Promise<MilestoneLadderClaimResult>;POST /customer/milestones/{programId}/claim — claim the rewards of one
achieved milestone step: a step whose state is claimable (the
merchant configured "customer picks" and the shopper reached it but has
not yet chosen), or a granted step that still owes a free-gift variant
choice (rewards[].needsVariantChoice).
The customer is taken from the token, never input.
input.selectedRewardIds are INDEXES into the step's own rewards
array from JoyClient.getMilestones — a caller names which reward
it wants, never what that reward is.
NOTE: this is the ladder-route claim; the widget-V4 route has its own JoyClient.claimMilestone. Both are kept ON PURPOSE — decided 2026-09-08, do not "consolidate" them without re-reading why.
Only the CLAIM halves overlap. The read halves do not and must both
survive: JoyClient.getMilestoneProgress is one cheap call
returning counters for EVERY milestone program (what the V4 widget needs
to draw several bars at once), while JoyClient.getMilestones
returns ONE program's fully rendered ladder and is deliberately fetched
only when a shopper opens the modal. Neither can serve the other's job:
the counters carry no step configuration at all (see MilestoneProgress),
and serving the widget from the ladder would cost one call per program.
Rejects with INVALID_PROGRAM (400) when the program is not found, is
in another shop, or is not a milestone program. INVALID_STEP (400)
when no step matches claimKey. NOT_CLAIMABLE (400) when the step is
not pending for this customer (not yet reached, or already claimed).
INVALID_SELECTION (400) for the wrong number of rewards, an
out-of-range index, or a duplicate. GIFT_SELECTION_REQUIRED (400) when
a chosen reward offers several variants and none was sent.
GIFT_UNAVAILABLE (400) when the sent variant is not on the reward's
allow-list. NOT_ELIGIBLE (403) when earning is disabled for this
customer (test mode, B2B exclusion, opt-in guest not yet enrolled).
Parameters
| Parameter | Type |
|---|---|
programId | string |
input | MilestoneLadderClaimInput |
Returns
Promise<MilestoneLadderClaimResult>
claimPendingReward()
claimPendingReward(pendingId, input?): Promise<PendingRewardClaimResult>;POST /customer/pending-rewards/{pendingId}/claim — claim an ENTRY-pending
tier reward, minting the coupon NOW for the picked variant(s). pendingId
scopes to THIS customer server-side (a guessed/stolen id belonging to
another customer rejects 403), so a client can never claim on behalf of
anyone else. input.variantIds is the shopper's product pick; omit it when
the reward needs no selection.
Parameters
| Parameter | Type |
|---|---|
pendingId | string |
input? | { variantIds?: string[]; } |
input.variantIds? | string[] |
Returns
Promise<PendingRewardClaimResult>
createApplePass()
createApplePass(): Promise<AppleWalletPassResult>;POST /customer/wallet-pass/apple — create (or regenerate) this customer's Apple Wallet pass, returning its public download link plus a QR data URL of that link. Takes no input; the customer is taken from the token. The same call also updates Customer.createdApplePass/ Customer.qrCodeDownloadApplePass server-side — a later JoyClient.getCustomer reflects the new pass without calling this again.
Rejects with APPLE_PASS_GENERATION_FAILED (502) when pass
rendering/upload failed.
Returns
Promise<AppleWalletPassResult>
deleteAddress()
deleteAddress(addressId): Promise<AddressDeleteResult>;POST /customer/addresses/delete — delete one of this customer's saved
addresses. Same ownership guarantee as JoyClient.saveAddress:
addressId is checked against the customer taken from the token, and
Shopify itself rejects (ADDRESS_NOT_FOUND, 404) an id that does not
belong to them — it is never silently treated as a no-op success.
Rejects with BAD_REQUEST (400) when addressId is missing.
CUSTOMER_NOT_LINKED (404) when this customer has no Shopify customer
id. ADDRESS_DELETE_FAILED (502) when the Shopify Admin API call itself
failed.
Parameters
| Parameter | Type |
|---|---|
addressId | string | number |
Returns
Promise<AddressDeleteResult>
disconnectFacebook()
disconnectFacebook(): Promise<FacebookDisconnectResult>;POST /customer/social/facebook/disconnect — clear the current customer's Facebook link. Takes no input; the customer is taken from the token.
Returns
Promise<FacebookDisconnectResult>
earn()
earn(programId, context?): Promise<EarnResult>;POST /customer/earn — claim ANY earning program. The program's own event
decides which family runs — a caller can never pick the event it earns
for — so context only needs to carry that family's input; see
EarnContext for which fields go with which Program.key.
birthday also persists the date of birth (once a year) before awarding
points, same two steps as the widget's birthday modal.
Rejects with INVALID_PROGRAM (400) when the program is not found, is in
another shop, is not an earning program, or is one of the four events
this endpoint never serves (custom_program, write_review,
place_order, Instagram engagement — those are granted elsewhere).
INVALID_INPUT (400) when the family's required context field is
missing or malformed. LIMIT_REACHED (400) when a per-program, shop, or
global earning limit stopped the award. ALREADY_SUBMITTED (400) when
this period's claim — or the once-a-year birthday date — is already on
file. NOT_ELIGIBLE (403) when the customer does not qualify (opt-in
guest, B2B, test mode). EARN_FAILED (400) for any other processing
failure.
Parameters
| Parameter | Type |
|---|---|
programId | string |
context? | EarnContext |
Returns
Promise<EarnResult>
earnSocial()
earnSocial(programId): Promise<SocialEarnResult>;POST /customer/earn/social — claim points for a social earning program
(follow, share, join). The event is derived server-side from the program
data, so the caller only sends the program id. A repeat claim rejects
with LIMIT_REACHED rather than granting points twice. Rejects with
NOT_ELIGIBLE (403) when the customer is excluded (opt-in guest, B2B,
test mode).
Also rejects with LINE_NOT_LINKED (400) for a connected shop's join_line
program whose Program.lineJoinType is follow_oa. Its points are
awarded through LINE's verified flow, which requires linking AND following the shop's OA;
linking alone never earns them. Start with
JoyClient.getLineAuthUrl's popup instead, so branch on
lineJoinType before calling rather than treating this as retryable.
A thin wrapper over JoyClient.earn — kept as its own method
because it is published contract and the shipped Weaverse block calls it,
but it makes the same /customer/earn request with no context.
Parameters
| Parameter | Type |
|---|---|
programId | string |
Returns
Promise<SocialEarnResult>
generateQrCode()
generateQrCode(): Promise<QrCodeResult>;POST /customer/qrcode — render this customer's in-store scan code (the one a POS scanner reads) as a PNG data URL.
Takes no input at all: the encoded payload is derived server-side from the token's customer, so a client can never ask for someone else's code.
JoyClient.getInfo already reports the same string as
customer.qrImageUrl on every later fetch, once a code has been generated
at least once — a client that calls /info anyway does not need this to
re-render it.
Rejects with QR_GENERATION_FAILED (502) when the encoding failed.
Returns
Promise<QrCodeResult>
generateReferralLink()
generateReferralLink(params): Promise<GenerateReferralLinkResult>;POST /referral/generate-link — mint (or fetch the already-stored) referral link +
code for email. PUBLIC: unlike every other method here, this one takes NO Bearer
token — JoyClientOptions.shopDomain resolves the shop via ?shop= instead,
and the target customer is identified by email, not the JWT. Mirrors Liquid's
/referral/generateLinkReferral: when no customer exists yet for email, one is
created, so a brand-new guest can get a shareable link before joining the program.
Used both to auto-generate a signed-in shopper's own link (their email, on first widget open) and to serve the guest referral card's manual "Get my link" form. Once a link is cached, prefer JoyClient.getReferral to read it back.
Rejects with BAD_REQUEST (400) for a missing/malformed email.
REFERRAL_LINK_UNAVAILABLE (400) when the referral program is not available for
this shop, or this guest is not eligible (access restricted, opt-in enrollment
not joined). SHOP_NOT_FOUND (404) when JoyClientOptions.shopDomain
does not resolve to a Joy shop — same shared shop-resolution guard every other
?shop=-scoped public method uses.
Parameters
| Parameter | Type |
|---|---|
params | { email: string; } |
params.email | string |
Returns
Promise<GenerateReferralLinkResult>
getActivities()
getActivities(params?): Promise<ActivityPage>;GET /customer/activities — points history, one page.
Parameters
| Parameter | Type |
|---|---|
params? | GetActivitiesParams |
Returns
Promise<ActivityPage>
getAddresses()
getAddresses(): Promise<Address[]>;GET /customer/addresses — the customer's saved shipping addresses.
Returns
Promise<Address[]>
getCustomer()
getCustomer(): Promise<Customer>;GET /customer — points, tier, progress.
Returns
Promise<Customer>
getFreeGiftStock()
getFreeGiftStock(programId, options?): Promise<FreeGiftStock>;POST /customer/free-gift-stock — live stock for a free_product program's
gifts. Call it when a gift modal opens (not per rewards list — it hits
Shopify uncached) to disable sold-out variants before the shopper picks.
Rejects with INVALID_PROGRAM (400) when the program is not found, is in
another shop, or is not a free-gift program.
Parameters
| Parameter | Type |
|---|---|
programId | string |
options? | GetFreeGiftStockOptions |
Returns
Promise<FreeGiftStock>
getGoogleWalletPass()
getGoogleWalletPass(): Promise<GoogleWalletPassResult>;GET /customer/wallet-pass/google — build this customer's "Add to Google Wallet" save link. Takes no input; the customer is taken from the token.
Rejects with GOOGLE_PASS_GENERATION_FAILED (502) when pass/link
generation failed.
Returns
Promise<GoogleWalletPassResult>
getImpactHistory()
getImpactHistory(params?): Promise<ImpactHistory>;GET /customer/impact-history — this customer's environmental-impact
redemptions plus reconciled cumulative totals. connected: false means the
totals are the last-known cached values (GoodAPI was unreachable), not that
the customer has no impact.
Parameters
| Parameter | Type |
|---|---|
params? | GetImpactHistoryParams |
Returns
Promise<ImpactHistory>
getInfo()
getInfo(params?): Promise<JoyInfo>;GET /info — reuses Liquid's own /popup/info controller (handleGetInfo) behind an
optional-auth headless adapter, so it returns the SAME live payload the Liquid widget's own
"beat 2" merges into the storefront's AVADA_JOY global: fresh settings, translation, tiers, referral,
QR, store credit, and — only when this client holds a token — the rich
JoyInfoCustomer. JoyClientOptions.shopDomain is REQUIRED (?d= resolves
the shop; the Bearer JWT, when present, only proves the customer on top of it, and is
rejected with UNAUTHORIZED if it was issued for a different shop). With no token this
is the shop-level guest payload — it never 401s for that reason alone.
Parameters
| Parameter | Type |
|---|---|
params? | GetInfoParams |
Returns
Promise<JoyInfo>
getLineAuthUrl()
getLineAuthUrl(): Promise<LineAuthUrlResult>;POST /customer/social/line/auth-url — mint a LINE Login URL for the
current customer to open in a popup. Needed before a join_line program
whose Program.lineJoinType is follow_oa will pay out; every
other social event, join_link included, stays claim-on-click through
JoyClient.earnSocial.
LINE redirects back to a fixed Joy-owned callback, which links the account.
It awards points once only if the shopper currently follows the OA;
otherwise the follow webhook awards them later. There is no need to call
JoyClient.earnSocial afterwards. A successful popup message
(joy-line-link) may include followed and awarded booleans. Missing
flags mean false: keep the Follow OA step until follow is confirmed, and
refresh customer data to read the server-confirmed award.
Rejects with LINE_NOT_CONNECTED (400) when the shop has not connected
LINE at all.
Returns
Promise<LineAuthUrlResult>
getMilestoneProgress()
getMilestoneProgress(): Promise<MilestoneProgress>;GET /customer/milestone — this customer's milestone progress as a flat
{[typeMilestone]: number} map across every active milestone program. Pair
with JoyClient.getPrograms to draw each milestone's bar. Empty
object when the shop runs no milestone program.
Returns
Promise<MilestoneProgress>
getMilestones()
getMilestones(programId): Promise<MilestoneLadder>;GET /customer/milestones/{programId} — one milestone program's ladder, rendered for THIS customer: the step sentence, the reward lines, the progress percentage and the "how much is left" line, all print-ready — the client draws circles, connectors, a bar and radios, never a sentence.
Call this when the shopper OPENS the milestone, not with the program list — the counters behind it are the most expensive reads on this surface.
Rejects with INVALID_PROGRAM (400) when the program is not found, is
in another shop, is not an earning program, is not a milestone program,
or is disabled.
Parameters
| Parameter | Type |
|---|---|
programId | string |
Returns
Promise<MilestoneLadder>
getOrderActivities()
getOrderActivities(orderId): Promise<Activity[]>;GET /customer/activities-by-order?orderId= — the Joy point activities tied
to one order (server-filtered to this customer's own rows). orderId must
be numeric; a non-numeric value rejects with BAD_REQUEST (400).
Parameters
| Parameter | Type |
|---|---|
orderId | string |
Returns
Promise<Activity[]>
getOrderById()
getOrderById(orderId): Promise<Order | null>;GET /customer/orders?orderId= — a single order by its numeric Shopify id,
or null when the customer has no order with that id. orderId must be
numeric; a non-numeric value rejects with BAD_REQUEST (400).
Parameters
| Parameter | Type |
|---|---|
orderId | string |
Returns
Promise<Order | null>
getOrders()
getOrders(): Promise<Order[]>;GET /customer/orders — the customer's most recent orders (newest first, capped server-side). Money fields are integer cents; see Order.
Returns
Promise<Order[]>
getPendingTierRewardClaims()
getPendingTierRewardClaims(): Promise<PendingTierRewardClaim[]>;GET /customer/pending-rewards — this customer's own unclaimed tier-up
rewards. Each carries the id a claim call targets and the product picker
data for the shopper to choose from. Empty array when they have none.
Returns
Promise<PendingTierRewardClaim[]>
getPrograms()
getPrograms(params?): Promise<Program[]>;GET /customer/programs — the same programs the public endpoint serves, but with the earn text rendered for THIS customer: their own tier's rate on a place-order rule, their own tier's rewards on a birthday rule.
The public createJoyServerClient().getPrograms() cannot do that — its
response is CDN-shared, so it carries the shop's default rate instead.
Parameters
| Parameter | Type |
|---|---|
params? | { programType?: ProgramType; } |
params.programType? | ProgramType |
Returns
Promise<Program[]>
getReceivedRewards()
getReceivedRewards(params?): Promise<ReceivedRewardsPage>;GET /customer/received-rewards — the gifts FRIENDS sent this customer
("From friends"), 10 per page, newest first. A separate list from
getRewards(): these are not the customer's own redemptions, so a client
must not offer revoke or send-to-a-friend on them.
Only live gifts are returned (used, revoked and expired ones are filtered server-side), and a gift card's balance is re-checked on every call.
Parameters
| Parameter | Type |
|---|---|
params? | GetReceivedRewardsParams |
Returns
Promise<ReceivedRewardsPage>
getReferral()
getReferral(): Promise<Referral>;GET /customer/referral — referral link, code, rewards, stats.
Returns
Promise<Referral>
getReferralHistory()
getReferralHistory(params?): Promise<ReferralHistoryPage>;GET /customer/referral-history — this customer's referred friends, 5 per
page, newest first. Friend emails are obfuscated server-side. Only rows in
a known status (complete/pending/cancel) are returned.
Parameters
| Parameter | Type |
|---|---|
params? | GetReferralHistoryParams |
Returns
Promise<ReferralHistoryPage>
getRewards()
getRewards(params?): Promise<CustomerRewardsPage>;GET /customer/rewards — redeemable programs and already-redeemed coupons,
as two separate lists. params paginates redeemed only; available is
always the full eligibility-filtered set.
Parameters
| Parameter | Type |
|---|---|
params? | GetRewardsParams |
Returns
Promise<CustomerRewardsPage>
getStoreCreditTransactions()
getStoreCreditTransactions(params?): Promise<StoreCreditTransactionPage>;GET /customer/store-credit/transactions — this customer's OWN store-credit
history, one page at a time. The account is resolved server-side from the
JWT; there is no accountId to pass (IDOR fix — see
StoreCreditTransactionPage). Empty page for a customer with no
store credit; never an error for that reason.
Parameters
| Parameter | Type |
|---|---|
params? | GetStoreCreditTransactionsParams |
Returns
Promise<StoreCreditTransactionPage>
getTierRewards()
getTierRewards(): Promise<Tier[]>;GET /customer/tier-rewards — this customer's VIP tiers with their assigned
rewards (perks), filtered to the tiers they can see. Localised: tier
names/descriptions render in the client's locale.
Returns
Promise<Tier[]>
joinProgram()
joinProgram(joinFrom?): Promise<Customer>;POST /customer/join-program — self-enrol an opt-in guest into the
loyalty program. Only meaningful when Customer.type is
'guest' and the shop's ShopConfig.optInEnrollmentEnabled (from the
public server client) is true; calling it for an already-enrolled
customer is a no-op — it returns the same Customer shape as a
fresh join, not an error.
Rejects with OPT_IN_NOT_ENABLED (403) when the shop is not running
opt-in enrollment (manual assignment, or below Premium). NOT_ELIGIBLE
(403) when the customer has left the loyalty program, or is excluded as
a B2B account.
Parameters
| Parameter | Type |
|---|---|
joinFrom? | JoinFrom |
Returns
Promise<Customer>
linkInstagram()
linkInstagram(instagramUsername): Promise<InstagramLinkResult>;POST /customer/social/instagram/link — link a self-reported Instagram
username to the current customer, granting the shop's one-time "link your
Instagram" reward on the first successful link. Pass '' to unlink.
Self-reported: the server does NOT verify the shopper owns the account. The customer is taken from the token, so there is no way to link an account to anybody else.
Rejects with NOT_ELIGIBLE (403) when the customer has not joined the
loyalty program (opt-in guest), and USERNAME_TAKEN (409) when this
username is already linked to a DIFFERENT customer on this shop.
Parameters
| Parameter | Type |
|---|---|
instagramUsername | string |
Returns
Promise<InstagramLinkResult>
logout()
logout(): void;Drop the held token locally (setToken(null)), so isLoggedIn flips to
false. Does NOT revoke the token server-side — use the server-side revoke
(Hydrogen logout) for that.
Returns
void
redeem()
redeem(programId, options?): Promise<RedeemResult>;POST /customer/redeem — spend points on a program; points defaults server-side.
Pass RedeemOptions.recipient on a gift_card program to send it to a
friend instead of the redeemer's own account.
Rejects with NOT_ELIGIBLE (403) when the customer does not qualify (VIP
tier, segment, B2B). getRewards() already hides those, so it means
eligibility changed since the list was fetched — re-fetch, don't retry.
Parameters
| Parameter | Type |
|---|---|
programId | string |
options? | RedeemOptions |
Returns
Promise<RedeemResult>
revokeReward()
revokeReward(rewardId): Promise<RevokeRewardResult>;POST /customer/rewards/{rewardId}/revoke — give back a redeemed reward and refund its points.
Parameters
| Parameter | Type |
|---|---|
rewardId | string |
Returns
Promise<RevokeRewardResult>
saveAddress()
saveAddress(address): Promise<Address>;POST /customer/addresses — create or update one of this customer's saved
Shopify addresses. address.id present -> update that address, absent ->
create a new one; address.isDefault: true also sets it as the
customer's default address.
OWNERSHIP: the customer is ALWAYS taken from the token — a client can
never save an address on behalf of anyone else. When address.id is
present, Shopify itself rejects (ADDRESS_NOT_FOUND, 404) an id that is
not a child of THIS customer, so a client naming another customer's
address id can never mutate it.
Rejects with BAD_REQUEST (400) for a missing address or a missing/
non-string address1/city/country. CUSTOMER_NOT_LINKED (404) when
this customer has no Shopify customer id to attach an address to.
ADDRESS_SAVE_FAILED (502) when the Shopify Admin API call itself
failed.
Parameters
| Parameter | Type |
|---|---|
address | AddressInput |
Returns
Promise<Address>
saveBirthday()
saveBirthday(birthday, dateOfBirth?): Promise<BirthdaySaveResult>;Save the customer's birthday ONCE (POST /customer/birthday). birthday is
'MM/DD'; pass dateOfBirth as 'YYYY-MM-DD' on shops that collect a year.
A customer who already has a birthday on file rejects with
ALREADY_SUBMITTED — this is a one-time submission, not editable after.
Parameters
| Parameter | Type |
|---|---|
birthday | string |
dateOfBirth? | string |
Returns
Promise<BirthdaySaveResult>
saveTierPerkVariantSelection()
saveTierPerkVariantSelection(input): Promise<TierPerkSaveResult>;POST /customer/perk/save-variant-selection — persist a customer's variant
selection for a tier-PRIVILEGE "choice mode" perk (the confirm button on
joy-tier-perk-picker). The product-discount Rust function applies the
saved selection at checkout, so the server re-resolves the perk's allowed
variants from the program/tier config and rejects (400) any variant off
that allow-list — TierPerkSaveInput carries selections only, never
the reward definition, so a crafted body can never grant a discount on a
variant the merchant never offered. The customer is taken from the token.
Parameters
| Parameter | Type |
|---|---|
input | TierPerkSaveInput |
Returns
Promise<TierPerkSaveResult>
sendReferralEmail()
sendReferralEmail(refereeEmail): Promise<ReferralEmailResult>;POST /customer/referral/send-email — send THIS customer's referral invite
to a friend by email (automated sharing mode only). The referrer is
ALWAYS taken from the token; refereeEmail is the only input.
Rejects with INVALID_EMAIL_FORMAT (400) for a missing/malformed
address. REFERRAL_SELF_REFERRAL (400) when refereeEmail is the
caller's own address. REFERRAL_EMAIL_COOLDOWN (429) when this same
referrer/friend pair already got an invite in the last 24h.
REFERRAL_EMAIL_LIMIT_REACHED (429) on a sharing rate limit.
REFERRAL_EMAIL_SHARING_DISABLED (400) when the shop's referral program
is not on automated email sharing (or has none configured).
REFERRAL_EMAIL_NOTIFICATION_DISABLED (400) when the shop's referral
email notification is turned off.
Parameters
| Parameter | Type |
|---|---|
refereeEmail | string |
Returns
Promise<ReferralEmailResult>
sendRewardToFriend()
sendRewardToFriend(input): Promise<SendRewardResult>;POST /customer/send-reward-to-friend — gift a coupon THIS customer redeemed to a friend. The sender is taken from the token, so a client can never gift on behalf of anyone else.
Rejects with PROGRAM_NOT_FOUND (404) when the program is unknown;
SEND_REWARD_SELF_SEND (400) when the recipient is the sender;
SEND_REWARD_COUPON_NOT_OWNED (403) when the coupon is not a reward this
customer redeemed from this program (or was revoked);
SEND_REWARD_RECIPIENT_ALREADY_SENT (400) when that friend already got
this exact coupon; SEND_REWARD_COOLDOWN/SEND_REWARD_LIMIT_REACHED (429)
on rate limits; SEND_REWARD_DISABLED/SEND_REWARD_NOTIFICATION_DISABLED
(400) when the program/notification is off.
Parameters
| Parameter | Type |
|---|---|
input | SendRewardInput |
Returns
Promise<SendRewardResult>
setBirthdayRewards()
setBirthdayRewards(birthdayRewards): Promise<BirthdayRewardsResult>;POST /customer/birthday-rewards — record WHICH birthday reward(s) this customer picked, for a program whose ProgramBirthday.rewardOptions offers a choice. It CLAIMS NOTHING and grants no points: the selection is only resolved against the program later, when the annual reward is sent or when JoyClient.claimBirthdayReward runs.
REPLACES the stored map — it does not merge, so send previous years back
unchanged or they are lost. Read the current map from
getInfo().customer.birthdayRewards (the same place the Liquid widget
reads it); there is no dedicated GET for it.
Repeatable, unlike the once-per-lifetime birthday DATE — which is why it is its own endpoint rather than a field on the birthday-entry call.
Rejects with BAD_REQUEST (400) when the map breaks
BirthdayRewardsMap's shape or size bounds, NOT_ELIGIBLE (403) for
an opt-in guest who has not joined the loyalty program, and
BIRTHDAY_REWARDS_UPDATE_FAILED (502) when the write itself failed.
Parameters
| Parameter | Type |
|---|---|
birthdayRewards | BirthdayRewardsMap |
Returns
Promise<BirthdayRewardsResult>
setToken()
setToken(token): void;Replace (or clear, with null) the held token — e.g. after a fresh /api/joy-token.
Parameters
| Parameter | Type |
|---|---|
token | string | null |
Returns
void
updateProfile()
updateProfile(options): Promise<ProfileResult>;POST /customer/profile — update this customer's first/last name,
avatar, and/or marketing consent. The customer is ALWAYS taken from the
token — a client can never edit anyone else's name/avatar/consent. At
least one of UpdateProfileOptions.firstName/lastName/
avatarBase64/acceptsMarketing/acceptsSmsMarketing is required; an
omitted field is left unchanged (e.g. a marketing-consent-only toggle
never touches the name/avatar).
Rejects with BAD_REQUEST (400) when none of the five fields are
given, a non-string firstName/lastName, a missing/empty/over-10MB
avatarBase64, or a non-boolean acceptsMarketing/
acceptsSmsMarketing. PROFILE_UPDATE_FAILED when the underlying
update itself declined the write (400) or failed unexpectedly while
saving (502).
Parameters
| Parameter | Type |
|---|---|
options | UpdateProfileOptions |
Returns
Promise<ProfileResult>
uploadEarnImages()
uploadEarnImages(images): Promise<EarnUploadResult>;POST /customer/earn/upload — store receipt / submit-form images and get
back their URLs to pass into JoyClient.earn as context.images
(receipt) or context.imageUrls (submit form / survey). Images travel as
base64 — no multipart — so this runs unchanged on a React Native client
with no File/FormData.
Rejects with INVALID_INPUT (400) for zero or more than 5 images, a type
other than JPEG/PNG, an image over 10MB, or data that is not actually an
image of the declared type — the whole batch is rejected together, not
just the bad image. UPLOAD_FAILED (400) when storage itself failed.
Parameters
| Parameter | Type |
|---|---|
images | EarnImageUpload[] |
Returns
Promise<EarnUploadResult>
verifyApplePass()
verifyApplePass(): Promise<VerifyApplePassResult>;GET /customer/wallet-pass/apple/verify — confirm whether the pass record behind Customer.createdApplePass still exists. Self-healing: a missing record clears the stale flag server-side, so a later JoyClient.getCustomer stops reporting a pass that no longer exists. The customer is taken from the token.
Returns
Promise<VerifyApplePassResult>
JoyClientOptions
Options for createJoyClient / Joy.init.
Properties
apiUrl
apiUrl: string;Base URL of the Headless API, e.g. https://api.joy.so/app/api/v1/headless.
fetch?
fetch?: JoyFetch;Optional fetch implementation. Defaults to globalThis.fetch.
locale?
locale?: string;Language to render Joy's own text in — program titles, tier names, earn descriptions, redeem conditions. Sent on every request.
Whoever owns the URL owns the locale. On Hydrogen that is Hydrogen
(/fr/..., storefront.i18n), so pass its value down rather than letting
anything sniff navigator.language: a shopper standing on /fr/ getting
English cards because their browser says en-US is worse than no
detection at all. Omit and the shop's primary language is used — but
PASS the primary language explicitly when you know it (the metafield
blob's translation.primaryLanguage): /info only trims its translation
doc to one locale when ?l= is present; without it the response carries
every configured locale (~260KB on a multi-language shop).
onTokenExpired?
onTokenExpired?: OnTokenExpired;Refresh hook invoked once on a 401 before retrying — see OnTokenExpired.
shopDomain?
shopDomain?: string;The shop's myshopify domain — required for JoyClient.getInfo (shop-scoped by
?d=) and JoyClient.generateReferralLink (shop-scoped by ?shop=), the two
methods here that resolve their shop from THIS field rather than the JWT: getInfo
because its Bearer token, when present, proves the CUSTOMER only; generateReferralLink
because it takes no Bearer token at all — the target customer is identified by the
call's own email argument instead. Ignored by every other method, which resolve
their shop from the JWT/apiUrl instead.
token?
token?: string | null;Current customer JWT; omit/null for a guest (methods then 401 unless a refresher is set).
RedeemOptions
Options for JoyClient.redeem.
Properties
idempotencyKey?
idempotencyKey?: string;Optional caller-generated key that makes the redeem idempotent server-side: a retry of the SAME intent (network drop, double click) with the same key returns the original result instead of spending points twice. Generate one per redeem intent and reuse it across retries.
points?
points?: number;Points to spend. REQUIRED for a reward whose redeemType is dynamic —
its pointsCost is the step, not the price, so there is no sane default
and the server rejects the call with POINTS_REQUIRED. Omit for
fixed-cost rewards; the server uses the program's own cost.
recipient?
recipient?: SendRewardRecipient;For a gift_card reward: send it to a friend instead of keeping it. Omit
to redeem into the redeemer's own account — Shopify then emails ONLY the
friend, never the redeemer, and the redeemer's couponCode on the result
comes back masked rather than the spendable code. Ignored on every other
rewardType.
Rejects with REDEEM_FAILED (400) when recipient.email matches the
redeemer's own address — a customer cannot send a gift card to
themselves.
variantId?
variantId?: string;The gift the customer picked, for a free_product reward whose
giftSelectionMode is one. Must be one of the variant ids in that
reward's giftProducts, else the redeem fails GIFT_UNAVAILABLE (and no
points are spent). Omitting it on a reward that needs one fails
GIFT_SELECTION_REQUIRED.
Type Aliases
OnTokenExpired
type OnTokenExpired = () =>
| Promise<string | null | undefined>
| string
| null
| undefined;Caller-supplied token refresher. Returns a fresh JWT, or null/undefined
when the session is gone (e.g. the merchant /api/joy-token route answered
401 because the shopper logged out). Called at most once per request, on a
401, before a single retry.
Returns
| Promise<string | null | undefined>
| string
| null
| undefined
Variables
Joy
const Joy: object;Singleton facade for the one-session browser/native case: Joy.init(...)
once (e.g. inside JoyProvider), then reach the client anywhere via
Joy.getClient().
Type Declaration
getClient()
getClient(): JoyClient;The client from the last Joy.init. Throws if init was never called.
Returns
init()
init(options): JoyClient;Create the client and store it as the singleton, returning it. Re-callable to swap sessions.
Parameters
| Parameter | Type |
|---|---|
options | JoyClientOptions |
Returns
Functions
createJoyClient()
function createJoyClient(options): JoyClient;Create a personalised Joy client. Prefer Joy.init for the common single-session case; use this directly when you need more than one client instance (unusual).
Parameters
| Parameter | Type |
|---|---|
options | JoyClientOptions |
Returns
References
Activity
Re-exports Activity
ActivityPage
Re-exports ActivityPage
ActivityType
Re-exports ActivityType
Address
Re-exports Address
AddressDeleteResult
Re-exports AddressDeleteResult
AddressInput
Re-exports AddressInput
AppleWalletPassResult
Re-exports AppleWalletPassResult
AvailableReward
Re-exports AvailableReward
BirthdayClaimResult
Re-exports BirthdayClaimResult
BirthdayEarnContext
Re-exports BirthdayEarnContext
BirthdayRewardsMap
Re-exports BirthdayRewardsMap
BirthdayRewardsResult
Re-exports BirthdayRewardsResult
BirthdaySaveResult
Re-exports BirthdaySaveResult
Branding
Re-exports Branding
CancelRedeemResult
Re-exports CancelRedeemResult
Customer
Re-exports Customer
CustomerRewards
Re-exports CustomerRewards
CustomerSocial
Re-exports CustomerSocial
CustomerTierRef
Re-exports CustomerTierRef
CustomerType
Re-exports CustomerType
EarnContext
Re-exports EarnContext
EarnImageUpload
Re-exports EarnImageUpload
EarningLimit
Re-exports EarningLimit
EarnResult
Re-exports EarnResult
EarnStatus
Re-exports EarnStatus
EarnUploadResult
Re-exports EarnUploadResult
FacebookDisconnectResult
Re-exports FacebookDisconnectResult
FreeGiftStock
Re-exports FreeGiftStock
FreeGiftStockProduct
Re-exports FreeGiftStockProduct
FreeGiftStockVariant
Re-exports FreeGiftStockVariant
GenerateReferralLinkResult
Re-exports GenerateReferralLinkResult
GiftProduct
Re-exports GiftProduct
GiftSelectionMode
Re-exports GiftSelectionMode
GiftVariant
Re-exports GiftVariant
GoogleMapsReviewEarnContext
Re-exports GoogleMapsReviewEarnContext
GoogleReviewStatus
Re-exports GoogleReviewStatus
GoogleWalletPassResult
Re-exports GoogleWalletPassResult
ImpactEvent
Re-exports ImpactEvent
ImpactEventType
Re-exports ImpactEventType
ImpactHistory
Re-exports ImpactHistory
ImpactTotals
Re-exports ImpactTotals
InstagramLinkResult
Re-exports InstagramLinkResult
JoinFrom
Re-exports JoinFrom
JoyApiError
Re-exports JoyApiError
JoyEnvelope
Re-exports JoyEnvelope
JoyError
Re-exports JoyError
JoyFetch
Re-exports JoyFetch
JoyInfo
Re-exports JoyInfo
JoyInfoCustomer
Re-exports JoyInfoCustomer
JoySuccess
Re-exports JoySuccess
LineAuthUrlResult
Re-exports LineAuthUrlResult
LineJoinType
Re-exports LineJoinType
MilestoneClaimInput
Re-exports MilestoneClaimInput
MilestoneClaimResult
Re-exports MilestoneClaimResult
MilestoneEarnContext
Re-exports MilestoneEarnContext
MilestoneLadder
Re-exports MilestoneLadder
MilestoneLadderClaimInput
Re-exports MilestoneLadderClaimInput
MilestoneLadderClaimResult
Re-exports MilestoneLadderClaimResult
MilestoneProgress
Re-exports MilestoneProgress
MilestoneReward
Re-exports MilestoneReward
MilestoneRewardAction
Re-exports MilestoneRewardAction
MilestoneRewardLogic
Re-exports MilestoneRewardLogic
MilestoneState
Re-exports MilestoneState
MilestoneStep
Re-exports MilestoneStep
MilestoneStepProgress
Re-exports MilestoneStepProgress
MilestoneType
Re-exports MilestoneType
Order
Re-exports Order
OrderAddress
Re-exports OrderAddress
OrderCustomer
Re-exports OrderCustomer
OrderDiscount
Re-exports OrderDiscount
OrderFulfillmentStatus
Re-exports OrderFulfillmentStatus
OrderLineItem
Re-exports OrderLineItem
Pagination
Re-exports Pagination
PendingRewardClaimResult
Re-exports PendingRewardClaimResult
PendingTierRewardClaim
Re-exports PendingTierRewardClaim
PlaceOrderScope
Re-exports PlaceOrderScope
PlaceOrderScopeCollection
Re-exports PlaceOrderScopeCollection
PlaceOrderScopeProduct
Re-exports PlaceOrderScopeProduct
PointLabel
Re-exports PointLabel
ProfileResult
Re-exports ProfileResult
Program
Re-exports Program
ProgramBirthday
Re-exports ProgramBirthday
ProgramBirthdayRewardOption
Re-exports ProgramBirthdayRewardOption
ProgramForm
Re-exports ProgramForm
ProgramGoogleReview
Re-exports ProgramGoogleReview
ProgramReview
Re-exports ProgramReview
ProgramStreak
Re-exports ProgramStreak
ProgramType
Re-exports ProgramType
QrCodeResult
Re-exports QrCodeResult
ReceiptEarnContext
Re-exports ReceiptEarnContext
ReceivedReward
Re-exports ReceivedReward
ReceivedRewardsPage
Re-exports ReceivedRewardsPage
RedeemedReward
Re-exports RedeemedReward
RedeemResult
Re-exports RedeemResult
RedeemType
Re-exports RedeemType
Referral
Re-exports Referral
ReferralEmailResult
Re-exports ReferralEmailResult
ReferralHistoryEntry
Re-exports ReferralHistoryEntry
ReferralHistoryPage
Re-exports ReferralHistoryPage
ReferralHistoryStatus
Re-exports ReferralHistoryStatus
ReferralStats
Re-exports ReferralStats
RevokeRewardResult
Re-exports RevokeRewardResult
RewardCollectionRef
Re-exports RewardCollectionRef
RewardProductRef
Re-exports RewardProductRef
RewardStatus
Re-exports RewardStatus
RewardType
Re-exports RewardType
SegmentEligibility
Re-exports SegmentEligibility
SegmentProgramQuery
Re-exports SegmentProgramQuery
SendRewardInput
Re-exports SendRewardInput
SendRewardRecipient
Re-exports SendRewardRecipient
SendRewardResult
Re-exports SendRewardResult
ShopConfig
Re-exports ShopConfig
SocialEarnResult
Re-exports SocialEarnResult
StoreCreditTransaction
Re-exports StoreCreditTransaction
StoreCreditTransactionPage
Re-exports StoreCreditTransactionPage
SubmitFormEarnContext
Re-exports SubmitFormEarnContext
Tier
Re-exports Tier
TierPerk
Re-exports TierPerk
TierPerkSaveInput
Re-exports TierPerkSaveInput
TierPerkSaveResult
Re-exports TierPerkSaveResult
TierProgress
Re-exports TierProgress
TierRewardDefinition
Re-exports TierRewardDefinition
UpdateProfileOptions
Re-exports UpdateProfileOptions
VerifyApplePassResult
Re-exports VerifyApplePassResult