Overview
When a customer reaches your checkout, this integration lets you show them three things from Yuko — in real time:
Three API calls. One seamless checkout experience.
How it works
All Yuko 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:1
Open Shopify Admin
Go to the merchant’s Shopify Admin Dashboard.
2
Open Yuko
Click Apps → Yuko Loyalty.
3
Go to API settings
Navigate to Integrations → REST API and click Create new key.
4
Create an API token
Choose Custom Key and give the key Read/Write Access on Rewards (
write:rewards, needed to redeem) and Read Access on Points (read:points, needed for the estimate).5
Share the API key
Copy the API key and share it securely with your team. It looks like this:
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
- Always set
Content-Type: application/jsonon POST requests - All responses are JSON
- Successful responses wrap data inside a
"data"key - Error responses include an
"error"object withcodeandmessage
Endpoint 1: Get points balance and 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)
- Rewards already issued to the customer (with their discount codes and status)
/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
Requires the
read:rewards scope (or write:rewards). The merchant configures this in Shopify Admin → Apps → Yuko Loyalty → Integrations → REST API. See Scopes.Query parameters
string
required
The Shopify Customer ID of the logged-in customer, for example
9049402769586. This is mandatory — do not call this endpoint for guest checkouts.Example request
Example response
200
Response fields
object
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. No Shopify Customer ID is required (you still need the API key), so it works for both logged-in customers and guests. Full API reference →POST /points/estimate
Requires the
read:points scope. See Scopes.Request
Request body
object
Optional. Include only if the customer is logged in. Omit entirely for guest checkouts. If you send it, include at least
id or email.object[]
required
The line items in the cart. Must contain at least one item.
Example request: logged-in customer
Example request: guest checkout
Example response
200
Response fields
object
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.
The request has no points amount, so only rewards with a fixed points cost can be redeemed here. A reward whose
reward_rule.method is increment (customer chooses how many points to spend) always fails with Insufficient points balance, even when can_redeem is true. Hide the Redeem button for those rewards.POST /customers/rewards/redeem
Requires the
write:rewards scope. Read-only keys can’t redeem. See Scopes.Request
Required headers
Request body
string
required
The Shopify Customer ID of the logged-in customer.
string<uuid>
required
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 request
Example response
A201 Created status means the redemption was successful and a new coupon code has been generated.
201
Response fields
object
Errors
Display logic after a successful redemption
Full checkout flow
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)
2
Decide which endpoints to call
3
Fire both calls in parallel
Do not wait for one to finish before starting the other. Running them in parallel keeps checkout fast.
4
Render the loyalty panel
Combine both responses to display the loyalty section. This is only an example; adapt it to your UI.
5
Handle the Redeem button click
When a customer clicks “Redeem” on an available reward, call Endpoint 3 with their On a
customer_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
Error response format
All error responses from Yuko return anerror object with a code and a message:
Recommended handling pattern
Rate limits
See full details → Rate Limits reference- 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
Rule 2: Use HTTPS everywhere
Always send requests to thehttps:// base URL so the API key is never sent unencrypted.
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.
1
Merchant generates a token
The merchant goes to Shopify Admin → Apps → Yuko Loyalty → Integrations → REST API and creates a Custom Key with
write:rewards and read:points.2
Merchant shares the token
The merchant copies the token and pastes it into your checkout platform’s merchant settings.
3
Your backend uses the token
Your backend reads the token from your settings and includes it in every Yuko API request for that merchant.
Cons: The merchant must manually copy-paste the token. If they regenerate it, it needs to be updated on your side.
Testing
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.
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.
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
4
Test Endpoint 2 with real cart items
points_earned and message. points_earned is currently always 0 (see the warning in Endpoint 2).5
Test Endpoint 3: redeem a reward
Use a Verify:
reward_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 or is store credit)
6
Test Endpoint 2 for guest checkout
customer field in the request body.7
Test error cases
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
API integration
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
UI
- 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
Rate limiting
- Retry logic in place for HTTP 429 — wait 1 second, retry once
- No polling within a single checkout session
Authentication
- 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.