Search Documentation
Search for a documentation page...
Loyalty API
REST API endpoints for configuring a points-based loyalty program, tiers, and bonus campaigns.
YNS loyalty is a points-based rewards program with three building blocks: settings (how points are earned and redeemed), tiers (membership levels reached by lifetime points, each with its own earning multiplier), and campaigns (time-boxed bonus multipliers scoped to specific products, categories, or collections). Settings and socials live in the store's JSON config, while tiers and campaigns are first-class records.
Get Loyalty Settings
Returns the store's loyalty config: points rate, redemption rules, and expiry. The loyalty field is null when the program has never been configured.
Response (200)
Update Loyalty Settings
Replaces the loyalty config wholesale.
Request Body
| Field | Type | Default | Description |
|---|---|---|---|
pointsPerUnit | number | 1 | Points earned per currency unit spent (positive) |
redemptionRate | number | 100 | Points required to redeem one currency unit (positive) |
minRedemption | number | 100 | Minimum points a customer must hold to redeem (positive) |
maxRedeemPercent | number | 50 | Maximum share of an order payable with points, 1-100 (positive) |
pointsExpiryMonths | number | null | null | Months until earned points expire (null = never) |
Response (200)
List Loyalty Tiers
Returns loyalty tiers. Members reach a tier once their lifetime points exceed its threshold.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 50 | Tiers per page (1-100) |
offset | number | 0 | Tiers to skip |
Response (200)
Create Loyalty Tier
Creates a tier. Members reach it once their lifetime points exceed the threshold, after which they earn points at the tier's multiplier.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Tier name, e.g. Gold |
threshold | number | Yes | Lifetime points required to reach this tier (integer ≥ 0) |
multiplier | number | Yes | Points-earning multiplier for members in this tier (positive, e.g. 1.5) |
color | string | Yes | Badge color hex, e.g. #FFD700 (must match #RRGGBB) |
sortOrder | number | No | Display order (integer ≥ 0, default: 0) |
Response (201)
Get Loyalty Tier
Returns a single loyalty tier by UUID. Returns 404 if no tier matches.
Update Loyalty Tier
Partially updates a loyalty tier. Send only the fields you want to change — all fields accept the same types and constraints as Create Loyalty Tier.
Response (200)
Returns the updated tier.
Delete Loyalty Tier
Deletes a loyalty tier by UUID. At least one tier must always remain — deleting the last tier returns 409.
Response (200)
Last Tier (409)
List Loyalty Campaigns
Returns loyalty bonus campaigns — time-boxed multipliers that boost points earned on specific products, categories, or collections.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | number | 50 | Campaigns per page (1-100) |
offset | number | 0 | Campaigns to skip |
activeOnly | boolean | — | Return only active campaigns |
Response (200)
Create Loyalty Campaign
Creates a bonus points-earning campaign. earnMultiplier boosts points earned, scope (with scopeIds) targets what it applies to, and startsAt/endsAt bound the active window.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Campaign name |
earnMultiplier | number | Yes | Points-earning multiplier during the campaign (positive, e.g. 2 = 2×) |
scope | string | Yes | One of ALL_PRODUCTS, PRODUCT_IDS, CATEGORY_IDS, COLLECTION_IDS |
scopeIds | string[] | Conditional | Product/category/collection UUIDs — required unless scope is ALL_PRODUCTS |
startsAt | string | null | No | ISO 8601 start (null = active immediately) |
endsAt | string | null | No | ISO 8601 end (null = no end). Must be after startsAt |
active | boolean | No | Whether the campaign is active (default: true) |
Response (201)
Get Loyalty Campaign
Returns a single loyalty campaign by UUID. Returns 404 if no campaign matches.
Update Loyalty Campaign
Partially updates a loyalty campaign. Fields accept the same types and constraints as Create Loyalty Campaign. The same cross-field guards apply: scopeIds is required when changing scope to anything other than ALL_PRODUCTS, and endsAt must be after startsAt.
Response (200)
Returns the updated campaign.
Delete Loyalty Campaign
Deletes a loyalty campaign by UUID.