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

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:
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
  • Always set Content-Type: application/json on POST requests
  • All responses are JSON
  • Successful responses wrap data inside a "data" key
  • Error responses include an "error" object with code and message
See the API Introduction for a full overview of request and response formats.

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.
Full API reference → 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.
The request carries product and variant IDs only, with no prices or quantities, so the cart amount Yuko calculates with is always 0. As a result the endpoint currently returns points_earned: 0 for every request. With the display logic below, the earn message stays hidden. Confirm it returns non-zero values for the merchant’s earn rules before you rely on it.
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:
  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.
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.
Full API reference → 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

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

A 201 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

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

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 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 an error object with a code and a message:

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

Always send requests to the https:// base URL so the API key is never sent unencrypted.

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

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

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

Test Endpoint 2 with real cart items

Verify: the request returns HTTP 200 with 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 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 or is store credit)
6

Test Endpoint 2 for guest checkout

Verify: Returns HTTP 200 with no 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/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.