Skip to main content
IMPORTANT: This guide is only applicable for checkout providers in Shopify platform

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

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:
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 Account Settings → Integrations → REST API.
4

Create an API token

Create a new token and enable the rewards:read scope.
5

Share the API key

Copy the API key and share it securely with your team. It looks like this:
Each merchant generates their own API key. If you are integrating across multiple merchants, each one will have a different key.

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 the Authorization header.
This header is required on every single request — no exceptions.
Full authentication details are in the Authentication reference.

Base URL

All Yuko API requests start with:

General rules

  • Always use HTTPS — plain HTTP requests are rejected
  • Always set Content-Type: application/json on POST requests
  • All responses are JSON
  • Successful responses wrap data inside a "data" key
  • Error responses include a "message" key
See the API Introduction for a full overview of request and response formats.

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.
Full API reference → GET /customers/rewards/redeemable

Request

Query parameter

string
required
The Shopify Customer ID of the logged-in customer. This is mandatory — do not call this endpoint for guest checkouts.Example: 9049402769586

Required token scope

Your API token must have rewards:read enabled. The merchant configures this in Shopify Admin → Apps → Yuko Loyalty → Account Settings → Integrations → REST API.

Example request

Example response (200)

Response fields

integer
The customer’s current redeemable points balance. Display this prominently at the top of your loyalty panel.Example: 650
array
All rewards the merchant has configured, enriched with affordability data for this specific customer.
array
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

object
Optional. Include only if the customer is logged in. Omit entirely for guest checkouts.
array
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) — points earned

Example response (200) — no active campaign

Response fields

integer
The number of loyalty points the customer will earn after completing the purchase.Example: 120
string | null
A 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:
  1. Deduct the required points from the customer’s balance
  2. Generate a fresh Shopify discount code for that reward
  3. 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.
Full API reference → POST /customers/rewards/redeem

Request

Required headers

Request body

string
required
The Shopify Customer ID of the logged-in customer.Example: "9049402769586"
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: "90424fa7-e8a9-4ef4-b43a-72c9b2028db5"

Example request

The reward_id comes directly from the rewards[].id field in the Endpoint 1 response. Store these IDs when you render the rewards list so you have them ready when the customer clicks “Redeem”.

Example response (201 — Created)

A 201 status means the redemption was successful and a new coupon code has been generated.

Response fields

string | null
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.
integer
The number of points deducted from the customer’s balance.Example: 500
enum | null
The type of reward that was redeemed. Possible values: fixed_discount, percentage_discount, free_shipping, free_product, store_credit.
number | null
The discount amount or percentage associated with the coupon.
  • For fixed_discount: this is the rupee/dollar amount (e.g. 5 means $5 off)
  • For percentage_discount: this is the percentage (e.g. 10 means 10% off)
  • Will be null for free_shipping and free_product reward types
string (datetime) | null
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

Display logic after a successful redemption

After a successful redemption, the customer’s points balance has decreased. If you have the old balance cached, subtract points_spent from it to show the updated balance without making another API call.

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

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 their customer_id and the reward_id of the reward they selected.
On a 201 response:
  • Take the coupon_code from 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

The loyalty panel is an enhancement to checkout — it must never block or break the purchase. If any Yuko API call fails, hide the loyalty panel silently and let checkout continue.
Full list of error codes → Errors reference

HTTP status codes

Error response format

All error responses from Yuko return a message field:

Rate Limits

See full details → Rate Limits reference
Cache the rewards list. The rewards[] catalogue changes infrequently — you can cache it for 5–15 minutes. The points_balance and customer_rewards[] are customer-specific and should be fetched fresh each checkout session.
  • 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

These rules are not optional. Violating them exposes the merchant’s API key and puts their store at risk.
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. All requests to Yuko must use https://. Plain HTTP will be rejected.

Authentication Setup Options

Choose whichever approach fits your architecture.
This is the simplest approach. No OAuth flow required.How it works:
1

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.
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.
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.

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

Expected: HTTP 200 with 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

Verify:
  • points_balance returns a number
  • rewards[] is populated with the merchant’s reward options
  • can_redeem correctly reflects the customer’s balance
  • customer_rewards[] returns any existing coupons

Step 4 — Test Endpoint 2 with real cart items

Verify: points_earned returns a non-zero value if the merchant has active earning campaigns configured.

Step 5 — Test Endpoint 3 — Redeem a reward

Use a reward_id from the Endpoint 1 response (choose one where can_redeem === true).
Verify:
  • Response is HTTP 201 (not 200)
  • coupon_code is returned and is a valid Shopify discount code
  • points_spent matches the points_cost of the reward you redeemed
  • expires_at is present (or null if the reward has no expiry)

Step 6 — Test Endpoint 2 for guest checkout

Verify: Returns HTTP 200 with no customer field in the request body.

Step 7 — Test error cases

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
API Integration
  • GET /customers/rewards/redeemable working and returning correct data
  • POST /points/estimate working for both logged-in and guest customers
  • POST /customers/rewards/redeem working — returns 201 with a valid coupon_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

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