Overview
When a customer reaches your checkout, this integration lets you show them three things from Yuko — in real time:| What the customer sees / does | API endpoint |
|---|---|
| Their current points balance | GET /customers/rewards/redeemable |
| Rewards available to redeem right now | GET /customers/rewards/redeemable |
| Spend their points to get a discount code or store credit | POST /customers/rewards/redeem |
| Points they will earn on this purchase | POST /points/estimate |
How It Works
Both API calls must be made from your backend server — never directly from the customer’s browser. See Security Rules for details.
Before You Start
What the merchant needs to do
The merchant must have Yuko installed on their Shopify store. Once installed:What your team needs
- The customer’s Shopify Customer ID at checkout time — required for Endpoint 1, only available when the customer is logged in
- Shopify Product IDs and Variant IDs for every item in the cart — required for Endpoint 2
Authentication
Yuko uses Bearer Token Authentication. Every API request must include the merchant’s API key in theAuthorization header.
Base URL
All Yuko API requests start with:General rules
- Always use HTTPS — plain HTTP requests are rejected
- Always set
Content-Type: application/jsonon POST requests - All responses are JSON
- Successful responses wrap data inside a
"data"key - Error responses include a
"message"key
Endpoint 1 — Get Points Balance & Redeemable Rewards
This is the primary endpoint for your checkout loyalty panel. One call returns everything:- The customer’s current points balance
- All rewards they can redeem (with a flag showing if they have enough points for each)
- Coupon codes they’ve already redeemed but haven’t applied yet
/customers/rewards/redeemable is a single endpoint that covers both the points balance and the full rewards list. You do not need a separate “get balance” call.GET /customers/rewards/redeemable
Request
Query parameter
The Shopify Customer ID of the logged-in customer. This is mandatory — do not call this endpoint for guest checkouts.Example:
9049402769586Required token scope
Your API token must haverewards:read enabled. The merchant configures this in Shopify Admin → Apps → Yuko Loyalty → Account Settings → Integrations → REST API.
Example request
Example response (200)
Response fields
The customer’s current redeemable points balance. Display this prominently at the top of your loyalty panel.Example:
650All rewards the merchant has configured, enriched with affordability data for this specific customer.
Coupon codes the customer has already redeemed (converted points into a discount code) but not yet applied at checkout.
Display logic
Endpoint 2 — Points Estimate at Checkout
This endpoint tells the customer how many loyalty points they will earn when they complete this purchase. This is a public endpoint — no Shopify Customer ID is required. It works for both logged-in customers and guests. Full API reference →POST /points/estimate
Request
Request body
Optional. Include only if the customer is logged in. Omit entirely for guest checkouts.
The line items in the cart. Must contain at least one item.
Example request — logged-in customer
Example request — guest checkout
Example response (200) — points earned
Example response (200) — no active campaign
Response fields
The number of loyalty points the customer will earn after completing the purchase.Example:
120A ready-to-display string. You can show this directly in your UI without additional formatting.Example:
"You will earn 120 points after completing this purchase"Will be null if no earning campaign matches the cart.Display logic
Endpoint 3 — Redeem a Reward (Burn Points)
This is the endpoint your checkout calls when a customer actively chooses to spend their points on a reward. When the customer clicks “Redeem” on an available reward, call this endpoint. Yuko will:- Deduct the required points from the customer’s balance
- Generate a fresh Shopify discount code for that reward
- Return the discount code so you can apply it to the order
This endpoint is triggered by a customer action — not automatically at checkout load. Only call it when the customer explicitly clicks “Redeem” on a reward option.
POST /customers/rewards/redeem
Request
Required headers
| Header | Value |
|---|---|
Authorization | Bearer YOUR_API_KEY |
Content-Type | application/json |
Request body
The Shopify Customer ID of the logged-in customer.Example:
"9049402769586"The UUID of the reward the customer wants to redeem. Get this from the
rewards[].id field in the Endpoint 1 response (GET /customers/rewards/redeemable).Example: "90424fa7-e8a9-4ef4-b43a-72c9b2028db5"Example request
Example response (201 — Created)
A201 status means the redemption was successful and a new coupon code has been generated.
Response fields
The newly generated Shopify discount code (e.g.
YUKO-TVJ-BL1). Apply this directly through your checkout’s discount flow.Will be null for store_credit reward types — the credit is added to the customer’s account automatically.The number of points deducted from the customer’s balance.Example:
500The type of reward that was redeemed. Possible values:
fixed_discount, percentage_discount, free_shipping, free_product, store_credit.The discount amount or percentage associated with the coupon.
- For
fixed_discount: this is the rupee/dollar amount (e.g.5means $5 off) - For
percentage_discount: this is the percentage (e.g.10means 10% off) - Will be
nullforfree_shippingandfree_productreward types
When the generated coupon expires.
null if the reward has no expiry.Example: "2026-06-01T00:00:00+00:00"Error responses for this endpoint
| Code | Scenario | What to do |
|---|---|---|
422 | Customer doesn’t have enough points | This shouldn’t happen if you used can_redeem from Endpoint 1 correctly. Show the customer a message: “You don’t have enough points for this reward.” |
422 | Reward not found or is inactive | The reward may have been deactivated by the merchant. Refresh the rewards list by calling Endpoint 1 again. |
404 | Customer not found | The customer_id is not in Yuko. |
401 | Invalid API key | Check the Authorization header. |
Display logic after a successful redemption
Full Checkout Flow
Step 1 — Collect what you need at checkout
- Shopify Customer ID — only if the customer is logged in (needed for Endpoint 1)
- Product IDs and Variant IDs for every item in the cart (needed for Endpoint 2)
Step 2 — Decide which endpoints to call
| Customer state | Call Endpoint 1? | Call Endpoint 2? | Call Endpoint 3? |
|---|---|---|---|
| Logged in, Shopify Customer ID available | ✅ Yes | ✅ Yes — include customer field | ✅ Yes — when customer clicks “Redeem” |
| Guest checkout | ❌ No — skip | ✅ Yes — omit customer field | ❌ No — guests can’t redeem points |
Step 3 — Fire both calls in parallel
Do not wait for one to finish before starting the other. Running them in parallel keeps checkout fast.Step 4 — Render the loyalty panel - Example
Combine both responses to display the loyalty section: Its an example. Customize as per your UI.Step 5 — Handle the “Redeem” button click
When a customer clicks “Redeem” on an available reward, call Endpoint 3 with theircustomer_id and the reward_id of the reward they selected.
201 response:
- Take the
coupon_codefrom the response and apply it to the checkout order - Update the displayed points balance:
new_balance = old_balance - points_spent - Remove the redeemed reward from the UI rewards list
The
reward_id is the id field from the rewards[] array in the Endpoint 1 response. You should store these IDs when you render the rewards list so they’re ready when the customer clicks.Error Handling
Full list of error codes → Errors referenceHTTP status codes
| Code | Meaning | What to do |
|---|---|---|
200 | Success | Use the response data |
400 | Bad request — missing or malformed parameters | Check your request structure |
401 | Unauthorized — API key missing or incorrect | Check the Authorization header and key value |
403 | Forbidden — token missing the right scope | Ask the merchant to regenerate a token with rewards:read scope |
404 | Customer not found | The customer_id doesn’t exist in Yuko — hide the panel silently |
422 | Validation error — logically incorrect request | Check the message field in the response |
429 | Rate limit exceeded | Wait 1 second and retry once — see Rate Limits |
500 | Yuko internal error | Retry once. If it persists, hide the panel and let checkout continue. |
503 | Yuko temporarily unavailable | Same as 500 — retry once, then fail gracefully |
Error response format
All error responses from Yuko return amessage field:
Recommended handling pattern
Rate Limits
See full details → Rate Limits reference| Limit | Value |
|---|---|
| Requests per second (per API token) | 10 |
| Error when exceeded | HTTP 429 Too Many Requests |
| Reset interval | 1 second |
- Don’t poll. Call both endpoints once when the customer arrives at checkout.
- Retry with a delay. On a 429, wait 1 second and retry once. Never retry immediately.
Security Rules
Rule 1 — Never expose the API key on the frontend. The key is a secret. It must only ever live on your backend server.- ❌ Never put it in browser-side JavaScript
- ❌ Never put it in a mobile app binary
- ❌ Never commit it to a public code repository
- ✅ Make all Yuko API calls from your backend — pass only the results to your frontend
https://. Plain HTTP will be rejected.
Authentication Setup Options
Choose whichever approach fits your architecture.- Token-Based (Easy Quick Start)
- OAuth-Based (Recommended)
This is the simplest approach. No OAuth flow required.How it works:Pros: Fast to set up. No OAuth flow required.
Cons: The merchant must manually copy-paste the token. If they regenerate it, it needs to be updated on your side.
Merchant generates a token
The merchant goes to Shopify Admin → Apps → Yuko Loyalty → Account Settings → Integrations → REST API and creates a token with
rewards:read scope.Merchant shares the token
The merchant copies the token and pastes it into your checkout platform’s merchant settings.
Cons: The merchant must manually copy-paste the token. If they regenerate it, it needs to be updated on your side.
Testing
Step 1 — Get a test API key
Contact the Yuko team for a test key, or use a real merchant’s key on a development Shopify store.Step 2 — Verify authentication
data.points_balance in the response body.If you get HTTP 401, the API key is wrong — check for extra spaces or incorrect values.
Step 3 — Test Endpoint 1 with a real customer
points_balancereturns a numberrewards[]is populated with the merchant’s reward optionscan_redeemcorrectly reflects the customer’s balancecustomer_rewards[]returns any existing coupons
Step 4 — Test Endpoint 2 with real cart items
points_earned returns a non-zero value if the merchant has active earning campaigns configured.
Step 5 — Test Endpoint 3 — Redeem a reward
Use areward_id from the Endpoint 1 response (choose one where can_redeem === true).
- Response is HTTP
201(not 200) coupon_codeis returned and is a valid Shopify discount codepoints_spentmatches thepoints_costof the reward you redeemedexpires_atis present (ornullif the reward has no expiry)
Step 6 — Test Endpoint 2 for guest checkout
customer field in the request body.
Step 7 — Test error cases
| Test | How to trigger | Expected result |
|---|---|---|
| Wrong API key | Use Bearer wrong_key | HTTP 401 |
| Unknown customer | Use customer_id=0000000 | HTTP 404 |
| Missing items | Send "items": [] | HTTP 422 |
| Guest checkout | Omit customer entirely | HTTP 200 |
| Redeem with insufficient points | Use a reward_id where can_redeem === false | HTTP 422 |
| Redeem with invalid reward ID | Use a made-up UUID as reward_id | HTTP 422 |
Step 8 — Test UI edge cases
- Customer with 0 points — panel shows rewards, all greyed out
- Customer with no prior redemptions —
customer_rewards[]is an empty array — handle without crashing - Guest customer — Endpoint 1 and Endpoint 3 are not called; only show earn estimate from Endpoint 2
points_earned === 0— hide the earn message; do not show “0 points”- After a successful redemption — UI updates the balance and removes the redeemed reward from the list
Go-Live Checklist
Security- API key stored as an environment variable — not hardcoded anywhere
- All Yuko API calls made from the backend server — not the browser
- HTTPS used for all requests
GET /customers/rewards/redeemableworking and returning correct dataPOST /points/estimateworking for both logged-in and guest customersPOST /customers/rewards/redeemworking — returns201with a validcoupon_code- Endpoints 1 and 2 fire in parallel at checkout load — not sequentially
- Endpoint 3 is only called on an explicit customer “Redeem” click — not at page load
- If any call fails, checkout continues without breaking
- Points balance displayed clearly
- Redeemable rewards shown with a “Redeem” button for rewards where
can_redeem === true - Rewards with insufficient points shown as greyed-out with “X more points needed”
- Unused coupon codes from
customer_rewards[]surfaced with an apply action - Points earn estimate shown when
points_earned > 0 - After a successful redemption: balance updates, redeemed reward is removed from list, new coupon code is surfaced or auto-applied
- No loyalty UI shown for guest checkouts
- Empty
customer_rewards[]handled gracefully — no crash, no blank space
- Retry logic in place for HTTP 429 — wait 1 second, retry once
- No polling within a single checkout session
- Plan in place for token rotation if the merchant regenerates their API key
API Reference Links
Get Redeemable Rewards
Points balance, available rewards, and unused coupons for a customer.
Redeem a Reward
Burn a customer’s points and generate a discount code.
Points Estimate
How many points a customer earns on a given cart.
Authentication
How Bearer Token authentication works in the Yuko API.
Errors
Full list of HTTP error codes and what they mean.
Rate Limits
Request limits and how to handle 429 errors.
Support
Book a call with Ramesh
For integration questions, OAuth setup, and onboarding support.
API Documentation
Full Yuko API reference.
Built by Flycart — the team behind 100K+ WooCommerce plugin installs.
Discount Rules · WPLoyalty · Yuko