# API keys Source: https://developers.loyaltylion.com/api-reference/authentication/api-keys API keys can be used to authenticate with the LoyaltyLion API. Each API key has a unique token, set of permissions (scopes) and can be disabled or deleted at any time. LoyaltyLion partners can use API keys to build integrations, but we recommend using [OAuth](/api-reference/authentication/oauth) instead as it offers an improved user experience for merchants. ## Create an API key Sign in to your LoyaltyLion account and then go to `Manage > API keys`, then click `Create API key` and follow the steps to create a new API key with the permissions you need. The API token will be displayed after creation; be sure to save it in a secure location as it cannot be seen again. ## Use an API key To use an API key, pass it as a `Bearer` token in the `Authorization` header of your request. ```bash theme={null} # access_token: pat_e1c752f1b5cd8b743148a586e573b679 curl \ --header 'Authorization: Bearer pat_e1c752f1b5cd8b743148a586e573b679' \ --header 'Content-Type: application/json' \ --url 'https://api.loyaltylion.com/v2/customers' ``` > [!WARNING] > > **Only ever use API keys server-side.** Depending on its permissions, anyone > holding it can read all your customers' data and redeem rewards on their > behalf. Never send an API key to a browser, bundle it into a mobile app, or > embed it in a POS client. If it has been exposed, disable and rotate it > immediately. ## API key scopes Each API key has a set of permissions (scopes) that determine the actions it can perform. These scopes can be changed at any time. In principle, you should only select the scopes you need. Our webhooks API is available to all access tokens, but you can only create webhooks for resources permitted by the token's scope. For example, a token without any `*_customers` scopes will not be able to register a `customers/update` webhook. | Scope | Description | | - | - | | `read_customers` | Read-only access to customers, including their points, tiers, rewards and activities. Doesn't include orders. | | `write_customers` | Read and write access to customers. Can add and remove customer points, change tiers and trigger customer activities. | | `read_unsubscribes` | Read-only access to the loyalty email unsubscribes list and unsubscribes webhook | | `write_unsubscribes` | Read and write access to the loyalty email unsubscribes list. Can add emails to the list. | | `read_orders` | Read-only access to orders. | | `write_orders` | Read and write access to orders. Can create, update and cancel orders. | | `write_configuration` | Modify program configuration, such as rules and rewards | | `read_reviews` | Read-only access to reviews. | | `write_reviews` | Read and write access to reviews. Can create, update and delete reviews. | # OAuth Source: https://developers.loyaltylion.com/api-reference/authentication/oauth As a LoyaltyLion partner, you can authenticate with our API as an OAuth client. Our server implements the [OAuth 2.0 specification](https://tools.ietf.org/html/rfc6749). > [!WARNING] > > OAuth authentication is designed **only** for LoyaltyLion partners building > apps to be used across many stores. If you're building an integration for a > single store, [use an API key](/api-reference/authentication/api-keys). ## Register your OAuth app Before you can authenticate with OAuth, you'll need to register your app with LoyaltyLion. To register a new OAuth app with LoyaltyLion, please email [partnersupport@loyaltylion.com](mailto:partnersupport@loyaltylion.com) with the following information: | Required | Description | | - | - | | `name` | Your company/app name | | `description` | Short description (max 150 characters) of your app | | `url` | URL to your company/app | | `image_url` | Copy of your company logo or link to a press pack | | `install_url` | Your install URL, must be `https` \[!NOTE] Merchants who initiate installation from their LoyaltyLion account are sent here. It should require login / signup to your app. Once the merchant is authenticated with your app, it should redirect into the [LoyaltyLion OAuth approval flow](#initiate-oauth-2-0-approval). | | `redirect_url` | Your redirect URL, must be `https` \[!NOTE] We redirect merchants here once they approve access for your app, for example: `https://app.example.com/auth/loyaltylion`. Landing on this page should initiate [token exchange](#acquire-an-access-token) | > [!TIP] > > Once we've approved your OAuth 2.0 app, we'll provide you with a **client id** > and **secret**. Your client secret must be kept private. If you believe it has > been compromised, please contact us immediately. ## Perform the OAuth 2.0 flow ### Initiate OAuth 2.0 approval To kick off the OAuth flow, start by sending the user to our authorize URL, `https://app.loyaltylion.com/oauth/authorize`, with the following parameters: | Param | Required | Description | | - | - | - | | `client_id` | yes | Your client id | | `scope` | yes | A comma separated list of [resource scopes](#resource-scopes) | | `redirect_uri` | yes | The return URL, which must match the URL provided to us at registration | | `state` | no | An encoded string that can be used to lookup and restore the previous state of your app, for example to identify users who are sent back to your app after authorization is complete | #### Example authorize URL: ```bash theme={null} # client_id: 317979793529 # scope: read_customers # redirect_uri: https://api.example.com/auth/loyaltylion https://app.loyaltylion.com/oauth/authorize?client_id=317979793529&scope=read_customers&redirect_uri=https%3A%2F%2Fapi.example.com%2Fauth%2Floyaltylion ``` > [!TIP] > > When a user is redirected to the authorize URL, we'll show them your app name, > description and logo and ask them to approve the requested scopes. ### Acquire access token If the user approves the request, we'll redirect them to your `redirect_uri` including a `code` as query param you can swap for an `access_token`. For example: ``` https://app.example.com/auth/loyaltylion?code=fe53739dab6d76cc ``` To exchange the code for a permanent access token, your server should make a `POST` request with the code, your client id and your client secret. ```bash theme={null} # client_id: 317979793529 # client_secret: 97b0dc6dde30f189 # code: fe53739dab6d76cc curl --request POST \ --url 'https://app.loyaltylion.com/oauth/access-token' \ --data 'client_id=317979793529&client_secret=97b0dc6dde30f189&code=fe53739dab6d76cc' \ --include ``` If the exchange is successful, we'll return a JSON response containing your permanent access token and a comma separated list of the approved scopes: ```json theme={null} { "access_token": "e1c752f1b5cd8b743148a586e573b679", "scope": "read_customers" } ``` ### Use access token Once you've received the access token, use it to make authenticated API requests allowed by the approved scopes. To do so, pass the access token using the [bearer authentication scheme](https://tools.ietf.org/html/rfc6750). ```bash theme={null} # access_token: e1c752f1b5cd8b743148a586e573b679 curl \ --header 'Authorization: Bearer e1c752f1b5cd8b743148a586e573b679' \ --header 'Content-Type: application/json' \ --url 'https://api.loyaltylion.com/v2/customers' ``` *** ## Resource scopes Scopes let you specify the type of access your app needs, and limit the capability of the associated access tokens. When making your initial request to our authorize URL, you should pass through the scopes needed by your app as a comma separated list. Our webhooks API is available to all access tokens, but you can only create webhooks for resources permitted by the token's scope. | Scope | Description | | - | - | | `read_customers` | Read-only access to customers, including their points, tiers, rewards and activities. Doesn't include orders. | | `write_customers` | Read and write access to customers. Can add and remove customer points, change tiers and trigger customer activities. | | `read_unsubscribes` | Read-only access to the loyalty email unsubscribes list and unsubscribes webhook | | `write_unsubscribes` | Read and write access to the loyalty email unsubscribes list. Can add emails to the list. | | `read_orders` | Read-only access to orders. | | `write_orders` | Read and write access to orders. Can create, update and cancel orders. | | `write_configuration` | Modify program configuration, such as rules and rewards | | `read_reviews` | Read-only access to reviews. | | `write_reviews` | Read and write access to reviews. Can create, update and delete reviews. | # Overview Source: https://developers.loyaltylion.com/api-reference/authentication/overview The LoyaltyLion API supports two recommended methods of authentication - API keys and OAuth, and one deprecated method, token & secret. > [card] [API keys](/api-reference/authentication/api-keys) > > Merchants can create API keys to authenticate requests to the LoyaltyLion API. > Each API key has a unique token, set of permissions (scopes) and can be > disabled or deleted at any time. > [card] [OAuth](/api-reference/authentication/oauth) > > If you're a LoyaltyLion partner, OAuth is the recommended method of accessing > our API. It provides the best experience for merchants as they don't need to > manage API keys manually. > [card] [Token and secret (deprecated)](/api-reference/authentication/token-secret) > > Each LoyaltyLion site has a single token and secret which can be used to > authenticate API requests. This method of authentication is deprecated and > will be removed in future, because it doesn't support permissions or > credential rotation. # Token & secret (deprecated) Source: https://developers.loyaltylion.com/api-reference/authentication/token-secret > [!WARNING] > > Token and secret authentication is **deprecated** and should not be used for > authentication with the API, and will only be supported until **January 10, 2027**. > > Please migrate your authentication to [API keys](/api-reference/authentication/api-keys/), > which provide scoped access to your LoyaltyLion account and can be easily disabled and rotated. The LoyaltyLion API supports Basic Authentication as defined in [RFC2617](http://www.ietf.org/rfc/rfc2617.txt) using your token and secret. These can be found in your [LoyaltyLion settings](https://app.loyaltylion.com/go/manage/settings/). Use the `token` as the username, and the `secret` as the password. For example, using cURL: ```bash theme={null} curl \ --user 'token:secret' \ --url 'https://api.loyaltylion.com/v2/customers' \ --header 'Content-Type: application/json' ``` ## Migrating to API keys ### Merchants If you're a merchant using the LoyaltyLion API, simply [create a new API key](/api-reference/authentication/api-keys) in your LoyaltyLion account and use it instead of your token and secret. ### LoyaltyLion partners > [!NOTE] > > If you're a LoyaltyLion partner and are *only* using OAuth to authenticate > with our API, you do not need to do anything If you're a LoyaltyLion partner using token and secret authentication, you will need to do the following before **January 10, 2027**. Alternatively, you can migrate to using [OAuth](/api-reference/authentication/oauth/) instead. **1. Update your setup guides and documentation** Update any merchant-facing setup guides and documentation so it requests an API key from the merchant instead of a token and secret. If you aren't sure which API scopes you need to ask for, [let us know](mailto:support@loyaltylion.com). **2. Update your backend code to use API keys** Update your backend code where you're calling the LoyaltyLion API, so it can [authenticate using an API key](/api-reference/authentication/api-keys). Note that, for a transition period, you'll need to support both forms of authentication, as you'll likely have some merchants still using token and secret, and newer merchants using API keys. **3. Update all existing merchant integrations with API keys** Finally, you'll need to update all existing merchant integrations to have an API key instead of a token and secret. To do this quickly and easily, you can provide us with a list of LoyaltyLion token & secret pairs that you have, and we'll create and provide a suitable API key for each, which you can then begin using immediately. To do this, email us at [support@loyaltylion.com](mailto:support@loyaltylion.com), indicating that you're a LoyaltyLion partner and would like to migrate to API keys. **Do not include any token or secret pairs in your email.** # Introduction Source: https://developers.loyaltylion.com/api-reference/introduction You can use the LoyaltyLion Admin API to: * push orders and activities to LoyaltyLion so they can trigger rules * modify customers, for example, remove points or update birthday * read information about customers and their activities > [!NOTE] > > **Admin API or Headless API?** > > The [Admin API](/api-reference/introduction) is intended for moving data in and > out of LoyaltyLion, such as retrieving customers and transactions, or tracking > orders placed on custom ecommerce platforms. In general, if you need to interact > with LoyaltyLion from your own backend - without any shopper interaction - the > Admin API is what you need. > > The [Headless API](/headless-api/introduction) is designed for merchants and > partners who want to build custom shopper-facing interfaces for their loyalty > program, or integrate LoyaltyLion into a native mobile or POS app. ## IP addresses If you need to allow outbound connections to `api.loyaltylion.com` from your servers, you can use the following IPv4 addresses: * `35.71.187.221` * `52.223.19.105` ## Rate limits The API enforces a rate limit of **20 requests per second** for all endpoints, unless otherwise stated. # Pagination Source: https://developers.loyaltylion.com/api-reference/pagination ## Cursor-based pagination Most API endpoints return a `cursor` which can be used to get the previous or next page of results. This is usually better than using `since_id` to paginate because: * the results are always ordered in descending order (newest first) * no need to manually keep track of the last ID * `null` cursor indicate that no more results are available * the cursor includes any filters applied in the initial request, so subsequent requests need only provide the single `cursor` param to retrieve the next page with the same filters applied These endpoints include a `cursor` property in the response object, for example: ```json theme={null} { "customers": [...], "cursor": { "prev": null, "next": "eyJsYXN0SWQiOjE0NjgsImRpcmVjdGlvbiI6Im5leHQifQ" } } ``` If either cursor is `null` it means there are no more pages available in that direction. > [!TIP] > > Cusors are also included in the `Link` header of the response. This is useful > if you are retrieving results in CSV format, in which case the response body > will not include the cursors To retrieve the previous or next page of results, pass the cursor as a `cursor` query param. You **do not** need to pass any other params; if you initially provided other params to filter the response, these will be part of the cursor already, and any other filtering params will be ignored. Only the `limit` parameter will be recognized. For example: ```bash theme={null} curl \ --url 'https://api.loyaltylion.com/v2/customers?cursor=eyJsYXN0SWQiOjE0NjgsImRpcmVjdGlvbiI6Im5leHQifQ' \ --header 'Content-Type: application/json' ``` ## `since_id` parameter pagination All collection endpoints support a `since_id` parameter. When a `since_id` is specified, the collection is ordered by `id` ascending, and contains only resources with an id greater than the specified `since_id`. To fully paginate through a collection, follow the algorithm: 1. Initialize your `since_id` to `0` 2. Specify a `limit` 3. Make a request with your current `since_id` and `limit` 4. If the number of resources returned is less than your `limit`, finish 5. Otherwise, set `since_id` equal to the `id` of the last resource in the response and repeat ### Example > [!NOTE] > > Some data is omitted from the example responses for clarity. ```bash First request theme={null} curl \ --url 'https://api.loyaltylion.com/v2/customers?since_id=0&limit=2' \ --header 'Content-Type: application/json' ``` ```json First response theme={null} { "customers": [ { "id": 123, "merchant_id": "2134606599", "email": "jessica@example.com" }, { "id": 168, "merchant_id": "6246262", "email": "kevin@example.com" } ] } ``` ```bash Second request theme={null} curl \ --url 'https://api.loyaltylion.com/v2/customers?since_id=168&limit=2' \ --header 'Content-Type: application/json' ``` ```json Second response theme={null} { "customers": [ { "id": 185, "merchant_id": "5234262462", "email": "larry@example.com" } ] } ``` # Create Activity Source: https://developers.loyaltylion.com/api-reference/v2/resources/activities/create-activity api-reference/v2/openapi.json POST /v2/activities Use this endpoint to track an activity to LoyaltyLion. When tracking an activity, if an applicable rule exists, it will be triggered based on the name of the activity. For the Clickthrough/Visit rule, you also need to specify the destination URL in the properties. You shouldn't use this API to track and reward purchases. Instead you should use the [Orders API](/api-reference/v2/resources/orders/create-order) which allows you to send important information specific to orders, such as the order total and payment status. > [!NOTE] > > If you're using the Activities API to award points for [custom > activities](https://help.loyaltylion.com/en/articles/1965598-activity-custom), > please note that only enrolled customers will receive points when they > complete them. Guest customers are not eligible to earn points and **will > not** receive those points retroactively after signing up to the program. # List Activities Source: https://developers.loyaltylion.com/api-reference/v2/resources/activities/list-activities api-reference/v2/openapi.json GET /v2/activities Activities in LoyaltyLion represent actions that added or removed points from a customer. These are most commonly triggered by a Rule, such as giving points for placing an order or enrolling in the program, but can also be created in other situations such as manual point adjustments or point expirations. # Update Activity Source: https://developers.loyaltylion.com/api-reference/v2/resources/activities/update-activity api-reference/v2/openapi.json PUT /v2/activities/{name}/{merchant_id} Use this endpoint to inform us about a change to an activity. For example, if you track a review activity which defaults to `pending` and your moderator then approves the review, you can send LoyaltyLion an update informing us it has been approved. To update an activity you'll need the activity name (for example, review) and the merchant_id you sent to LoyaltyLion when you first tracked the activity. ## Difference between `void` and `decline` Pending activities can be declined, while approved activities can be voided. If you aren't sure if an activity is pending or approved, you should update the state to `declined`. This will be treated as `void` if the activity is approved. # Add Points Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/add-points api-reference/v2/openapi.json POST /v2/customers/{merchant_id}/points # Create Export Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/exports/create-export api-reference/v2/openapi.json POST /v2/customers/exports Start a bulk export of your customers. The export runs in the background: poll [Get Export](/api-reference/v2/resources/customers/exports/get-export) until its status is `completed`, then fetch the file from `download_url`. The filters are the ones [List Customers](/api-reference/v2/resources/customers/list-customers) takes, and each line of the file is one customer in the shape that endpoint returns. An empty body exports every customer. A program may have one export pending or processing at a time. A second request returns `409` naming the export already running. See the [customer exports guide](/api-reference/v2/resources/customers/exports/overview) for the full flow. # Get Export Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/exports/get-export api-reference/v2/openapi.json GET /v2/customers/exports/{id} Poll this to follow an export's progress and to collect its file. A completed export carries a fresh `download_url` on every response, valid for six hours, so fetch the file soon after reading one, or read this endpoint again for a new link. Seven days after completing, the file is deleted and the export reports `expired`. # List Exports Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/exports/list-exports api-reference/v2/openapi.json GET /v2/customers/exports Return this program's exports, newest first: any still pending or processing, those whose file is still downloadable, and any that failed in the last seven days. # Customer exports Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/exports/overview Export every customer in your program, or every customer matching a filter, as one file. This replaces paging through [List Customers](/api-reference/v2/resources/customers/list-customers) when you need the whole result set, such as a nightly sync to your own systems. An export runs in the background. You create it, poll it until it completes, then download the file. > [!NOTE] > > Customer exports require a [program API > key](/api-reference/authentication/api-keys) or > [OAuth](/api-reference/authentication/oauth) with the `read_customers` scope. > The site token and secret is not accepted. ## Create an export [Create a customer export](/api-reference/v2/resources/customers/exports/create-export) takes the same filters as List Customers. An empty body exports every customer. ```bash theme={null} curl \ --request POST \ --header 'Authorization: Bearer pat_e1c752f1b5cd8b743148a586e573b679' \ --header 'Content-Type: application/json' \ --url 'https://api.loyaltylion.com/v2/customers/exports' \ --data '{ "updated_at_min": "2026-09-01T00:00:00Z" }' ``` The response is `202 Accepted` with the new export in status `pending`. A program can have one export pending or processing at a time. A second request returns `409` with the id of the export already running. ## Poll for progress [Get a customer export](/api-reference/v2/resources/customers/exports/get-export) returns the export's current state. Poll it every few seconds until the status is `completed` or `failed`. | Status | Meaning | | - | - | | `pending` | Queued and not yet started | | `processing` | Running. `progress.rows_processed` counts rows written so far; `progress.rows_total` is an estimate | | `completed` | The file is ready. The response includes `download_url`, `row_count` and `file_size` | | `expired` | The file was deleted seven days after completion. Create a new export for a fresh file | | `failed` | The export could not finish and will not be retried. Create a new export | `rows_total` is an estimate taken when processing starts, and may be `null` if none was available. `rows_processed` is exact. ## Download the file A `completed` export carries a `download_url`. The link is signed and valid for six hours from the response that returned it; read the export again for a fresh link. The file itself is available for seven days after completion, after which the export reports `expired`. The file is [JSON Lines](https://jsonlines.org): one customer per line, in the same shape as List Customers returns. It is not compressed. ```json theme={null} {"id": 1468, "merchant_id": "8237", "email": "one@example.com", "points_approved": 120, ...} {"id": 1469, "merchant_id": "8241", "email": "two@example.com", "points_approved": 0, ...} ``` Rows are ordered by `id` ascending. ## Find earlier exports [List customer exports](/api-reference/v2/resources/customers/exports/list-exports) returns the program's exports, newest first: anything still running, any whose file is still downloadable, and any that failed in the last seven days. > [!TIP] > > To keep a copy of your customers up to date, run one full export, then either > run periodic exports with `updated_at_min` or subscribe to the > [`customers/update`](/api-reference/v2/webhooks/events/customers-update) > webhook for changes as they happen. # List Customers Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/list-customers api-reference/v2/openapi.json GET /v2/customers # List Transactions Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/list-transactions api-reference/v2/openapi.json GET /v2/customers/{merchant_id}/transactions Retrieve a list of transactions for this customer. Unlike activities and rewards, transactions are immutable. For example, if an activity is triggered and then voided, it will typically create two transactions, one which adds points and a second which removes points. # Remove Points Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/remove-points api-reference/v2/openapi.json POST /v2/customers/{merchant_id}/remove_points # List Available Rewards Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/rewards/list-available-rewards api-reference/v2/openapi.json GET /v2/customers/{merchant_id}/available_rewards Returns a list of the rewards currently available to this customer. Rewards are available to a customer for the purposes of this API if: * The reward is enabled * If a customer is in a loyalty tier, the reward is available on that tier * The reward is supported based on your platform (see table below) Rewards will be returned even if the customer does not currently have enough points to redeem them. ## Supported rewards by platform | Platform | Supported rewards | | - | - | | Shopify | [one-off discount rewards](https://help.loyaltylion.com/en/articles/5998069-reward-discount-flat-and-percentage), [custom rewards](https://help.loyaltylion.com/en/articles/1965661-reward-custom-reward), [checkout rewards](https://help.loyaltylion.com/en/articles/1965711-shopify-plus-points-slider-checkout-redemption), [free product vouchers](https://help.loyaltylion.com/en/articles/1965659-rewards-free-product-voucher), [seamless free products](https://help.loyaltylion.com/en/articles/1965660-reward-free-product-seamless) | | Adobe Commerce (Magento) | [one-off discount rewards](https://help.loyaltylion.com/en/articles/5998069-reward-discount-flat-and-percentage), [custom rewards](https://help.loyaltylion.com/en/articles/1965661-reward-custom-reward), [free product vouchers](https://help.loyaltylion.com/en/articles/1965659-rewards-free-product-voucher) | | BigCommerce | [one-off discount rewards](https://help.loyaltylion.com/en/articles/5998069-reward-discount-flat-and-percentage), [custom rewards](https://help.loyaltylion.com/en/articles/1965661-reward-custom-reward), [free product vouchers](https://help.loyaltylion.com/en/articles/1965659-rewards-free-product-voucher) | | Custom | [custom rewards](https://help.loyaltylion.com/en/articles/1965661-reward-custom-reward) | # Redeem Reward Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/rewards/redeem-reward api-reference/v2/openapi.json POST /v2/customers/{merchant_id}/claimed_rewards # Refund Reward Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/rewards/refund-reward api-reference/v2/openapi.json POST /v2/customers/{merchant_id}/claimed_rewards/{claimed_reward_id}/refund # Update Customer Source: https://developers.loyaltylion.com/api-reference/v2/resources/customers/update-customer api-reference/v2/openapi.json PATCH /v2/customers/{merchant_id} # Create Unsubscribe Source: https://developers.loyaltylion.com/api-reference/v2/resources/emails/create-unsubscribe api-reference/v2/openapi.json POST /v2/loyalty_emails/unsubscribes Add a new email to the LoyaltyLion email unsubscribe list. Emails on this list will not receive any emails from LoyaltyLion. Returns a `201` status code if the email was added to the list, or `200` if it was already on the list. # List Unsubscribes Source: https://developers.loyaltylion.com/api-reference/v2/resources/emails/list-unsubscribes api-reference/v2/openapi.json GET /v2/loyalty_emails/unsubscribes Retrieve the LoyaltyLion unsubscribe list. Emails on this list will not receive any emails from LoyaltyLion. # Create Order Source: https://developers.loyaltylion.com/api-reference/v2/resources/orders/create-order api-reference/v2/openapi.json POST /v2/orders Add a new order to LoyaltyLion. This may trigger rules and award points to a customer. Merchants using a supported platform such as Shopify should usually *not* use this endpoint, as LoyaltyLion will retrieve orders from the platform via webhooks instead. # Get Order Source: https://developers.loyaltylion.com/api-reference/v2/resources/orders/get-order api-reference/v2/openapi.json GET /v2/orders/{merchant_id} Retrieve an order by its ID in your platform or ecommerce store. # List Orders Source: https://developers.loyaltylion.com/api-reference/v2/resources/orders/list-orders api-reference/v2/openapi.json GET /v2/orders Retrieve orders for the program. LoyaltyLion will only hold orders that have been created via the LoyaltyLion API or webhooks from an e-commerce platform. # Update Order Source: https://developers.loyaltylion.com/api-reference/v2/resources/orders/update-order api-reference/v2/openapi.json PUT /v2/orders/{merchant_id} Use this endpoint to update an existing order in LoyaltyLion, using your internal (from your ecommerce platform) `merchant_id` to identify the order. This is a full update and must include the order's current payment, cancellation and refund status, including any relevant totals if required (`total_paid` and `total_refunded`). The update endpoint is idempotent, so it’s safe to call it every time an order is updated in your system. # Create Review Source: https://developers.loyaltylion.com/api-reference/v2/resources/reviews/create-review api-reference/v2/openapi.json POST /v2/reviews/{platform} > [!NOTE] > > Required scope: `write_reviews` > > This endpoint is in preview, and is only available to partners and merchants who > have opted-in Use this endpoint to create a review in LoyaltyLion. When a review is created, if an applicable rule exists, it will be triggered based on the review's status. If you are a review platform partner, use your platform identifier as the `platform` parameter. If you are a merchant integrating a custom reviews app, use `custom`. Reviews must be connected to a customer in LoyaltyLion, matched using their `merchant_id`. If you are a review partner, this must be the ID of the customer in the connected store, e.g. a Shopify customer ID. # Delete Review Source: https://developers.loyaltylion.com/api-reference/v2/resources/reviews/delete-review api-reference/v2/openapi.json DELETE /v2/reviews/{platform}/{merchant_id} > [!NOTE] > > Required scope: `write_reviews` > > This endpoint is in preview, and is only available to partners and merchants who > have opted-in Use this endpoint to delete a review. Deleting a review cannot be undone, and will void any associated customer activities triggered by the review rule. To delete a review you'll need the `platform` and the `merchant_id` you sent to LoyaltyLion when you first created the review. # Update Review Source: https://developers.loyaltylion.com/api-reference/v2/resources/reviews/update-review api-reference/v2/openapi.json PUT /v2/reviews/{platform}/{merchant_id} > [!NOTE] > > Required scope: `write_reviews` > > This endpoint is in preview, and is only available to partners and merchants who > have opted-in Use this endpoint to inform us about a change to a review. For example, if a review is initially created with a `pending` status and is later approved, you can send LoyaltyLion an update informing us it has been approved. To update a review you'll need the `platform` and the `merchant_id` you sent to LoyaltyLion when you first created the review. # Disable Reward Source: https://developers.loyaltylion.com/api-reference/v2/resources/rewards/disable-reward api-reference/v2/openapi.json POST /v2/rewards/{reward_id}/disable > [!NOTE] > > This endpoint only supports API and OAuth keys, and requires the > `write_configuration` scope Disable a reward by its ID. This will immediately prevent it from being redeemed by customers, and it will no longer be shown as an available reward in LoyaltyLion UI components or API responses. This endpoint is idempotent: if the reward is already disabled, this endpoint will return a `200` response, and the `updated` property in the response will be `false`. # Enable Reward Source: https://developers.loyaltylion.com/api-reference/v2/resources/rewards/enable-reward api-reference/v2/openapi.json POST /v2/rewards/{reward_id}/enable > [!NOTE] > > This endpoint only supports API and OAuth keys, and requires the > `write_configuration` scope Enable a reward by its ID. This will allow it to be redeemed by customers, and it will be shown as an available reward in LoyaltyLion UI components and API responses. This endpoint is idempotent: if the reward is already enabled, this endpoint will return a `200` response, and the `updated` property in the response will be `false`. # Create WebView Session Source: https://developers.loyaltylion.com/api-reference/v2/resources/sites/create-webview-session api-reference/v2/openapi.json POST /v2/sites/{site_id}/webviews/sessions > [!NOTE] > > Required scopes: `write_customers` > > This endpoint has a rate limit of 100 requests per second Create a short-lived WebView session for a site. This session includes a URL that can be used to [render an embedded Loyalty Page in a WebView](/sdk/webviews/render-in-webview). If you have an authenticated customer, you can include their ID and email when creating the session. This will allow rendering a WebView with a customer context, allowing the customer to view their points and redeem rewards. > [!WARNING] > > You must only include a customer when generating an WebView session if you > have already authenticated them in your app, i.e. using Shopify's own > authentication, or multipass. # List Sites Source: https://developers.loyaltylion.com/api-reference/v2/resources/sites/list-sites api-reference/v2/openapi.json GET /v2/sites Return a list of sites that belong to the authenticating program. This endpoint cannot be called using legacy token & secret authentication. For multi-site programs, a list of all sites within the program will be returned, in order of creation (newest first). For single-site programs, a list with a single site will be returned. Any of the returned `sites[].id` fields can be used to interact with the [Headless API](/headless-api/introduction). # List Transactions Source: https://developers.loyaltylion.com/api-reference/v2/resources/transactions/list-transactions api-reference/v2/openapi.json GET /v2/transactions Retrieve a list of transactions for the program. Each transaction represents an addition or removal of points from a customer. Unlike activities and rewards, transactions are immutable. For example, if an activity is triggered and then voided, it will typically create two transactions, one which adds points and a second which removes points. # Create Webhook Source: https://developers.loyaltylion.com/api-reference/v2/resources/webhooks/create-webhook api-reference/v2/openapi.json POST /v2/webhooks # Delete Webhook Source: https://developers.loyaltylion.com/api-reference/v2/resources/webhooks/delete-webhook api-reference/v2/openapi.json DELETE /v2/webhooks/{webhook_id} # List Webhooks Source: https://developers.loyaltylion.com/api-reference/v2/resources/webhooks/list-webhooks api-reference/v2/openapi.json GET /v2/webhooks # Who Am I Source: https://developers.loyaltylion.com/api-reference/v2/resources/whoami api-reference/v2/openapi.json GET /v2/identity/whoami Check your API caller identity with the LoyaltyLion API. This will return an `identity` object with details about the authenticating API method and its associated permissions. If your API authentication is invalid, this endpoint will return a `401` response. # customers/update Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/customers-update This webhook is triggered anytime a customer changes in LoyaltyLion. Examples of when this could trigger include earning/redeeming points or moving into a new loyalty tier. To subscribe to this webhook, your API token needs to have the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "customers/update", "created_at": "2025-01-01T03:00:05.000Z", "customer": { "id": 1001, "email": "alice@example.com", "guest": false, "blocked": false, "birthday": "1970-01-01", "enrolled": true, "metadata": {}, "created_at": "2020-11-23T17:28:25.362Z", "properties": { "name": "Alice Blue", "last_name": "Blue", "first_name": "Alice" }, "updated_at": "2025-02-13T00:00:11.535Z", "enrolled_at": "2023-05-12T20:46:40.377Z", "merchant_id": "5000001", "referral_id": null, "referred_by": null, "points_spent": 0, "referral_url": "https://prz.io/a", "points_pending": 0, "points_approved": 500, "rewards_claimed": 0, "rewards_used": 0, "insights_segment": null, "loyalty_tier_membership": { "manual": false, "expires_at": null, "started_at": "2024-12-17T02:03:15.378Z", "loyalty_tier": { "id": 100, "name": "Bronze", "hidden": false, "number": 1, "default": true, "position": 0, "lower_bound": "0.00", "upper_bound": "249.99" } }, "tier_eligibility": { "kind": "points", "valid_until": null, "tier_points": { "now": 150, "at_expiration": null }, "points_needed_for_renewal": null, "points_needed_for_upgrade": 100, "upgrade_tier": { "id": 101, "name": "Silver", "threshold": 250 }, "forecasted_tier": null } } } ``` # loyalty_emails/unsubscribe Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/loyalty-emails-unsubscribe This webhook is triggered when a customer unsubscribes from any email sent by LoyaltyLion. To subscribe to this webhook, your API token needs to have the `read_unsubscribes` scope. ## Payload **customer** `object` *required* **properties** **id** `number` *required* The LoyaltyLion ID of the customer **email** `string` *required* The email address of the customer ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "loyalty_emails/unsubscribe", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "unsubscribe": { "customer": { "id": 6936, "email": "sarah@example.com" } } } } ``` # program_events/customer.claimed_reward Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-claimed-reward This webhook is triggered when a customer has claimed a reward. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. > [!NOTE] > > This webhook is currently only triggered for **voucher** and **gift card** > rewards ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **title** `string` *required* Title of the reward that was claimed **reward_type** `enum\` *required* The type of the claimed reward. One of: `voucher` or `gift_card` **discount_type** `enum\` *required* The type of discount provided. One of: `flat` or `percentage` **voucher_code** `string | null` *required* The voucher (coupon) code linked to the claimed reward. Only included if the reward type is `voucher` **discount_amount** `number | null` *required* The discount provided by the claimed reward as a decimal value, e.g. \$5 will be `5`. Only included if the reward type is `voucher` **gift_card_last_characters** `string | null` *required* The final four characters of the gift card applied. Only present if the claimed reward was a gift card **currency** `string | null` *required* The currency of the gift card. Only present if the claimed reward was a gift card **initial_value** `integer | null` *required* The initial balance of the gift card as a decimal value, e.g. \$5 will be `5`. Only present if the claimed reward was a gift card **balance** `integer | null` *required* The current balance of the gift card as a decimal value, e.g. \$5 will be `5`. Only present if the claimed reward was a gift card ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.claimed_reward", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "properties": { "title": "$5 voucher", "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "reward_type": "voucher", "voucher_code": "LL-PQ8V63", "discount_type": "flat", "discount_amount": 20 } } } ``` # program_events/customer.enrolled Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-enrolled This webhook is triggered when a customer has enrolled into the program. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **enrollment** `object` *required* **properties** **date** `string` *required* `ISO 8601` timestamp indicating when the customer enrolled **trigger** `string` *required* The trigger that caused the enrollment ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.enrolled", "created_at": "2025-01-01T03:00:05.000Z", "payload": { "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "enrollment": { "date": "2025-01-01T02:55:00.000Z", "trigger": "account_creation" } } } } ``` # program_events/customer.points_earned Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-points-earned This webhook is triggered when the customer has earned points. It includes an `available_rewards` array of rewards that are actionable, in stock, enabled, and affordable by the customer. To subscribe to this webhook, your access token needs to contain the read_customers scope. > [!TIP] > > As many customers redeem their points immediately after earning them, and the > payload includes a list of available rewards, this webhook is only sent after > a 5 minute delay. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **transaction** `object` *required* Transaction object with the same shape as the [Transactions API](/api-reference/v2/resources/transactions/list-transactions#response-transactions) response. This is the transaction associated with this particular points earning event **available_rewards** `object[]` *required* Array of Reward objects with the same shape as the [List Available Rewards API](/api-reference/v2/resources/customers/rewards/list-available-rewards#response-rewards) response ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.points_earned", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "transaction": { "id": "5432", "points_approved": "1200", "points_pending": "0", "created_at": "2018-01-01T03:00:05.000Z", "activity": { "id": "7653", "merchant_id": "3452672", "value": "50", "state": "pending", "created_at": "2018-01-01T03:00:05.000Z", "rule": { "id": "8632145", "name": "$purchase", "title": "Make a purchase" } } }, "available_rewards": [ { "id": 121013, "kind": "cart_discount_voucher", "title": "10% Off", "method": "voucher", "content": {}, "site_id": 12, "claim_url": "https://email.storerewards.co/track/a3hvr8d1808pvlpvvryt/click?p=2290s8fopfnsd0E/sh7292ksdp0", "order_type": "all", "point_cost": 500, "description": null, "target_site": { "id": 12, "url": "https://www.example.com", "name": "Example Store" }, "target_type": "all", "usage_limit": 1, "discount_type": "percentage", "minimum_spend": null, "discount_amount": 100, "session_options": null, "target_products": [], "max_free_shipping": null, "target_collections": [], "max_redemption_amount": 1, "min_redemption_amount": 1 } ] } } } ``` # program_events/customer.recurring_reward_available_reminder Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-recurring-reward-available-reminder This webhook is triggered on a rolling interval, starting 1 month after you first register for it. It will fire for customers on the program who have not received a `reward_available_notification` within the same month. The `available_rewards` array contains rewards that are actionable, in stock, enabled, and affordable by the customer. The `points_approved_in_interval` property contains the number of points the customer has earned within that month, and the `points_interval_start_date` describes when that month started. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **available_rewards** `object[]` *required* Array of Reward objects with the same shape as the [List Available Rewards API](/api-reference/v2/resources/customers/rewards/list-available-rewards#response-rewards) response **points_approved_in_interval** `number` *required* The number of points the customer has earned within that month **points_interval_start_date** `string` *required* `ISO 8601` timestamp indicating when the current interval started ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.recurring_reward_available_reminder", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "available_rewards": [ { "id": 121013, "kind": "cart_discount_voucher", "title": "10% Off", "method": "voucher", "content": {}, "site_id": 12, "claim_url": "https://email.storerewards.co/track/a3hvr8d1808pvlpvvryt/click?p=2290s8fopfnsd0E/sh7292ksdp0", "order_type": "all", "point_cost": 500, "description": null, "target_site": { "id": 12, "url": "https://www.example.com", "name": "Example Store" }, "target_type": "all", "usage_limit": 1, "discount_type": "percentage", "minimum_spend": null, "discount_amount": 100, "session_options": null, "target_products": [], "max_free_shipping": null, "target_collections": [], "max_redemption_amount": 1, "min_redemption_amount": 1 } ], "points_interval_start_date": "2018-01-01T03:00:05.000Z", "points_approved_in_interval": 100 } } } ``` # program_events/customer.referral_complete Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-referral-complete This webhook is triggered when a customer follows a referral link and completes an order. To subscribe to this webhook, your access token needs to contain the `read_customers` and `read_orders` scopes. ## Payload **referring_customer** `object` *required* The referring customer. An object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **referred_customer** `object` *required* The new customer who has been referred. An object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **activity** `object` *required* The referral activity triggered by the referring customer. An object with the same shape as the [Activities API](/api-reference/v2/resources/activities/list-activities#response-activities) response **order** `object` *required* The new referred customer's order that triggered the referral. An object with the same shape as the [Orders API](/api-reference/v2/resources/orders/get-order) response ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.referral_complete", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "properties": { "referring_customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "referred_customer": { "id": 45254, "merchant_id": "2104789172", "email": "bill@example.com", "points_approved": 0, "points_pending": 0, "points_spent": 0, "rewards_claimed": 0, "rewards_used": 0, "properties": { "name": "Bill Smith" }, "metadata": {}, "birthday": "1990-07-18", "blocked": false, "guest": true, "enrolled": false, "enrolled_at": "2019-12-10T03:00:00.000Z", "referral_id": null, "referred_by": { "id": 6932, "merchant_id": "2134606599" }, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "order": { "id": 194572858, "total": "45.96", "metadata": {}, "total_tax": "0", "created_at": "2021-08-19T05:50:42.797Z", "total_paid": "45.96", "updated_at": "2021-08-19T05:50:42.797Z", "merchant_id": "4158567448655", "refund_status": "not_refunded", "payment_status": "paid", "total_refunded": "0", "total_shipping": "5.99", "merchant_number": "263961", "total_discounts": "10.00", "fulfillment_status": "not_fulfilled", "cancellation_status": "not_cancelled" }, "activity": { "id": 239638566, "rule": { "id": 149623, "name": "$referral", "title": "Refer friends" }, "state": "pending", "value": 1000, "merchant_id": null, "created_at": "2018-01-01T03:00:05.000Z" } } } } ``` # program_events/customer.reward_available_notification Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-reward-available-notification This webhook is triggered when the customer has a new reward available. The `available_rewards` array contains rewards that are actionable, in stock, enabled and affordable by the customer. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. > [!NOTE] > > This webhook has a 7 day cool-down period per individual customer > [!TIP] > > As many customers redeem their points immediately after earning them, this > webhook is only sent after a 5 minute delay. If after 5 minutes the customer > has redeemed their points and no longer has any rewards available, the webhook > will not be sent ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **available_rewards** `object[]` *required* Array of Reward objects with the same shape as the [List Available Rewards API](/api-reference/v2/resources/customers/rewards/list-available-rewards#response-rewards) response ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.reward_available_notification", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "available_rewards": [ { "id": 121013, "kind": "cart_discount_voucher", "title": "10% Off", "method": "voucher", "content": {}, "site_id": 12, "claim_url": "https://email.storerewards.co/track/a3hvr8d1808pvlpvvryt/click?p=2290s8fopfnsd0E/sh7292ksdp0", "order_type": "all", "point_cost": 500, "description": null, "target_site": { "id": 12, "url": "https://www.example.com", "name": "Example Store" }, "target_type": "all", "usage_limit": 1, "discount_type": "percentage", "minimum_spend": null, "discount_amount": 100, "session_options": null, "target_products": [], "max_free_shipping": null, "target_collections": [], "max_redemption_amount": 1, "min_redemption_amount": 1 } ] } } } ``` # program_events/customer.rule_completed Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-rule-completed This webhook is triggered when a customer completes an activity by triggering a rule. To subscribe to this webhook, your access token needs to contain the `read_customers` and `read_orders` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **activity** `object` *required* The activity that was completed. An object with the same shape as the [Activities API](/api-reference/v2/resources/activities/list-activities#response-activities) response **order** `object | null` The order linked to this activity, if any. An object with the same shape as the [Orders API](/api-reference/v2/resources/orders/get-order) response **social_link** `string | null` If this activity was linked to a social media rule, e.g. "Follow on Instagram", this will be the URL of the social media profile that was involved **review** `object | null` If this activity was linked to a review rule, this will contain information about the review **properties** **kind** `string` *required* The kind of review. This is usually the name of the review platform in use **rating** `number` *required* Numeric rating of the review ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.rule_completed", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "order": { "id": 194572858, "total": "45.96", "metadata": {}, "total_tax": "0", "created_at": "2021-08-19T05:50:42.797Z", "total_paid": "45.96", "updated_at": "2021-08-19T05:50:42.797Z", "merchant_id": "4158567448655", "refund_status": "not_refunded", "payment_status": "paid", "total_refunded": "0", "total_shipping": "5.99", "merchant_number": "263961", "total_discounts": "10.00", "fulfillment_status": "not_fulfilled", "cancellation_status": "not_cancelled" }, "activity": { "id": 239638566, "rule": { "id": 149623, "name": "$purchase", "title": "Make a purchase" }, "state": "pending", "value": 1000, "merchant_id": null, "created_at": "2018-01-01T03:00:05.000Z" } } } } ``` # program_events/customer.tier_downgraded Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-tier-downgraded This webhook is triggered when a customer moves down a tier. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. > [!NOTE] > > This webhook is not triggered when a customer moves into their **first** tier ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **previous_tier** `object` *required* **properties** **id** `number` *required* Unique LoyaltyLion ID of the tier **name** `string` *required* The name of the tier **number** `number` *required* The sequential, ordered number of the tier. The default (first) tier will be `1` **default** `boolean` *required* Indicates if this is the default (first) tier in the program **hidden** `boolean` *required* Indicates if this is a hidden tier **lower_bound** `string` *required* The lower bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` **upper_bound** `string | null` *required* The upper bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` This will be `null` if there is no upper bound for the tier. **new_tier** `object` *required* **properties** **id** `number` *required* Unique LoyaltyLion ID of the tier **name** `string` *required* The name of the tier **number** `number` *required* The sequential, ordered number of the tier. The default (first) tier will be `1` **default** `boolean` *required* Indicates if this is the default (first) tier in the program **hidden** `boolean` *required* Indicates if this is a hidden tier **lower_bound** `string` *required* The lower bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` **upper_bound** `string | null` *required* The upper bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` This will be `null` if there is no upper bound for the tier. ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.tier_downgraded", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "id": "332d90cd-1ba1-4a7b-abd1-79e643b4b89f", "created_at": "2018-01-01T03:00:05.000Z", "kind": "customer.tier_downgraded", "unique_until": null, "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": "a4e", "referred_by": { "id": 3958, "merchant_id": "192838592" }, "loyalty_tier_membership": { "started_at": "2017-03-03 00:00:00Z", "expires_at": null, "manual": false, "loyalty_tier": { "id": 16, "name": "Silver", "position": 2, "default": false, "hidden": false, "lower_bound": "200.01", "upper_bound": "400.00" } }, "tier_eligibility": { "kind": "points", "valid_until": null, "tier_points": { "now": 220, "at_expiration": null }, "points_needed_for_renewal": null, "points_needed_for_upgrade": 180, "upgrade_tier": { "id": 17, "name": "Gold", "threshold": 400 }, "forecasted_tier": null }, "insights_segment": "Loyal", "referral_url": "https://prz.io/KzByQ2Fa", "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "previous_tier": { "id": 15, "name": "Bronze", "number": 1, "default": true, "hidden": false, "lower_bound": "0.00", "upper_bound": "200.00" }, "new_tier": { "id": 16, "name": "Silver", "number": 2, "default": false, "hidden": false, "lower_bound": "200.01", "upper_bound": "400.00" } } } } ``` # program_events/customer.tier_upgraded Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-tier-upgraded This webhook is triggered when a customer moves up a tier. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. > [!NOTE] > > This webhook is not triggered when a customer moves into their **first** tier ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **previous_tier** `object` *required* **properties** **id** `number` *required* Unique LoyaltyLion ID of the tier **name** `string` *required* The name of the tier **number** `number` *required* The sequential, ordered number of the tier. The default (first) tier will be `1` **default** `boolean` *required* Indicates if this is the default (first) tier in the program **hidden** `boolean` *required* Indicates if this is a hidden tier **lower_bound** `string` *required* The lower bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` **upper_bound** `string | null` *required* The upper bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` This will be `null` if there is no upper bound for the tier. **new_tier** `object` *required* **properties** **id** `number` *required* Unique LoyaltyLion ID of the tier **name** `string` *required* The name of the tier **number** `number` *required* The sequential, ordered number of the tier. The default (first) tier will be `1` **default** `boolean` *required* Indicates if this is the default (first) tier in the program **hidden** `boolean` *required* Indicates if this is a hidden tier **lower_bound** `string` *required* The lower bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` **upper_bound** `string | null` *required* The upper bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` This will be `null` if there is no upper bound for the tier. ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.tier_upgraded", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "id": "332d90cd-1ba1-4a7b-abd1-79e643b4b89f", "created_at": "2018-01-01T03:00:05.000Z", "kind": "customer.tier_upgraded", "unique_until": null, "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": "a4e", "referred_by": { "id": 3958, "merchant_id": "192838592" }, "loyalty_tier_membership": { "started_at": "2017-03-03 00:00:00Z", "expires_at": null, "manual": false, "loyalty_tier": { "id": 16, "name": "Silver", "position": 2, "default": false, "hidden": false, "lower_bound": "200.01", "upper_bound": "400.00" } }, "tier_eligibility": { "kind": "points", "valid_until": null, "tier_points": { "now": 250, "at_expiration": null }, "points_needed_for_renewal": null, "points_needed_for_upgrade": 150, "upgrade_tier": { "id": 17, "name": "Gold", "threshold": 400 }, "forecasted_tier": null }, "insights_segment": "Loyal", "referral_url": "https://prz.io/KzByQ2Fa", "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "previous_tier": { "id": 15, "name": "Bronze", "number": 1, "default": true, "hidden": false, "lower_bound": "0.00", "upper_bound": "200.00" }, "new_tier": { "id": 16, "name": "Silver", "number": 2, "default": false, "hidden": false, "lower_bound": "200.01", "upper_bound": "400.00" } } } } ``` # receipts/manual_approval_required Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/receipts-manual-approval-required This webhook is triggered when a customer uploads a receipt that requires manual review before it can be approved or declined. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **receipt** `object` *required* **id** `number` *required* The LoyaltyLion ID of the receipt **status** `string` *required* The status of the receipt. Will be `awaiting_manual_review` for this event **retailer_name** `string | null` *required* The name of the retailer on the receipt **total_paid** `number | null` *required* The total amount paid, in the receipt's currency **tax_paid** `number | null` *required* The tax amount paid, in the receipt's currency **currency** `string | null` *required* The ISO 4217 currency code of the receipt **fraud_score** `number | null` *required* The fraud score of the receipt, from 0 to 100 **duplicate** `boolean | null` *required* Whether the receipt was detected as a duplicate **retailer_receipt_date** `string | null` *required* The date on the receipt, as an ISO 8601 timestamp **created_at** `string` *required* When the receipt was uploaded, as an ISO 8601 timestamp **rule** `object` *required* **id** `number` *required* The LoyaltyLion ID of the retail purchase rule **name** `string` *required* The name of the rule ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "receipts/manual_approval_required", "created_at": "2025-03-15T10:30:00.000Z", "payload": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 0, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2025-03-15T10:30:00.000Z" }, "receipt": { "id": 42, "status": "awaiting_manual_review", "retailer_name": "Walmart", "total_paid": 85.5, "tax_paid": 7.5, "currency": "USD", "fraud_score": 55, "duplicate": false, "retailer_receipt_date": "2025-03-14T00:00:00.000Z", "created_at": "2025-03-14T18:22:00.000Z" }, "rule": { "id": 1234, "name": "$retail_purchase" } } } ``` # rewards/store_fulfilment Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/rewards-store-fulfilment This webhook is triggered when a customer claims a custom reward which has had a fulfilment webhook URL configured. You cannot subscribe to this webhook topic via the LoyaltyLion API. Instead, the webhook is managed automatically by LoyaltyLion. To change the webhook URL, update the custom reward in your LoyaltyLion admin. > [!NOTE] > > When you respond to this webhook with a successful response (a `2xx` status > code), we'll consider this particular redemption to have been successful ## Payload **test** `boolean` *required* Indicates if this is a test webhook. A webhook with this value set to `true` will be sent when you create or update a custom reward, to confirm that the URL is valid and your server is responding **reward_fulfilment_id** `number` *required* The LoyaltyLion ID of the fulfilment for this redemption **reward_id** `number` *required* The LoyaltyLion ID of the reward that was redeemed **reward_identifier** `string` *required* The custom reward identifier set by you when creating the reward **customer_id** `number` *required* The LoyaltyLion ID of the customer redeeming this reward **customer_merchant_id** `string` *required* The ID of the customer in your platform or ecommerce store **customer_email** `string | null` *required* The email address of the customer redeeming this reward ## Example ```json Example theme={null} { "test": false, "reward_fulfilment_id": 1823, "reward_id": 6, "reward_identifier": "surprise-gift-next-order", "customer_id": 5, "customer_merchant_id": "2075071365", "customer_email": "jesca.blue@example.com" } ``` # Introduction Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/overview Use webhooks to receive notifications about events that happen in LoyaltyLion, such as a customer earning points or moving into a new tier. This is more efficient than polling our API periodically. ## Subscribing to webhooks Use the [Webhook API](/api-reference/v2/resources/webhooks/create-webhook) to view, subscribe and unsubscribe to webhooks. Webhook subscriptions are scoped to the OAuth app (Client ID) that created them. That is, an OAuth client can only view their own webhook subscriptions. Webhooks created using API keys are never visible to OAuth clients. ## Receiving webhooks Once you have subscribed to a webhook, LoyaltyLion issues an HTTP `POST` request to the specified URL every time that event occurs. Some webhook events may have a cool-down period, which will be indicated on their documentation page. > [!NOTE] > > Webhooks are delivered with at-least-once delivery semantics. In rare > situations you may receive duplicate webhooks. If strict exactly-once > semantics are required, you can deduplicate events based on the `id` field in > the webhook request body. ### Request body The webhook request body will be a `JSON` object containing webhook metadata and the event-specific payload. > [card] > > **id** `string` > > Unique ID for this webhook event, which can be used to deduplicate events > > **topic** `string` > > The topic of the webhook event > > **created_at** `string` > > An `ISO 8601` timestamp representing the date this webhook was sent. This > may be different from the date the event occurred > > **payload** `object` > > The event-specific payload as a JSON object. See the respective page in the > documentation for each event for a description of its payload. ### Verifying requests The webhooks we deliver have a `x-loyaltylion-hmac-sha256` header, which is a base64 encoded sha256 HMAC of the raw JSON request body and the relevant secret key: * for webhooks registered with an [an OAuth client](/api-reference/authentication/oauth), use OAuth client secret * for other webhooks, use your site secret Example code to verify a webhook: ```typescript TypeScript (Express) theme={null} import crypto from 'crypto' import express from 'express' import bodyParser from 'body-parser' const LOYALTYLION_SECRET = 'secret' const app = express() function verifyWebhook(data, signature) { const ourSignature = crypto .createHmac('sha256', LOYALTYLION_SECRET) .update(data) .digest('base64') return ourSignature === signature } app.use( bodyParser.json({ verify: (req, res, buffer) => { if (!verifyWebhook(buffer, req.get('x-loyaltylion-hmac-sha256'))) { throw new Error('Webhook verification failed') } }, }), ) ``` ```ruby Ruby on Rails theme={null} class WebhookController < ApplicationController LOYALTYLION_SECRET = 'secret' def handle_webhook verified = verify_webhook( request.raw_post, request.headers['x-loyaltylion-hmac-sha256'], ) unless verified return head(422) end # handle the webhook end def verify_webhook(body, hmac) digest = OpenSSL::Digest.new('sha256') our_hmac = Base64.encode64( OpenSSL::HMAC.digest(digest, LOYALTYLION_SECRET, body), ).strip hmac == our_hmac end end ``` ```php PHP theme={null} define("LOYALTYLION_SECRET", "abc"); function verify_webhook($data, $hmac) { $our_hmac = base64_encode( hash_hmac("sha256", $data, LOYALTYLION_SECRET, true) ); return $our_hmac == $hmac; } $verified = verify_webhook( file_get_contents("php://input"), $_SERVER["X-LOYALTYLION-HMAC-SHA256"] ); if ($verified) { // handle webhook } ``` ## Responding to webhooks Your app must acknowledge it received the webhook event by responding with a `200` status code within 5 seconds. When we see a response status outside the 2xx range, or a response isn't received within the 5s timeout, that delivery is considered failed. ### Webhook retries Failed webhook events are retried with an exponential backoff until a success response is received or the webhook subscription is removed: * After 5 failed attempts, you receive an email alert * For OAuth subscriptions, we'll email the address you used to register the OAuth app. For other kinds of webhook subscriptions, we'll email the owner of the LoyaltyLion account * After 30 failed attempts, the webhook subscription is removed and you are notified again # Custom rewards Source: https://developers.loyaltylion.com/docs/features/custom-rewards Create custom rewards to perform actions or provide rewards that don't fit into the standard LoyaltyLion reward types. These rewards can be fulfilled in one of two ways: manually or via a webhook. ## Manual fulfilment When you create a custom reward with manual fulfilment, LoyaltyLion will track a pending fulfilment each time a customer redeems the reward, and send you an email. You can manage pending fulfilments from the custom reward page in the LoyaltyLion admin. Once you've handled a fulfilment, you can mark it as complete. ## Webhook fulfilment When you create a custom reward with a webhook, we'll create a new webhook subscription for the URL you specify. Every time a customer redeems that reward, we'll dispatch a webhook to that URL. Apart from being managed by LoyaltyLion, the webhook works the same as any other webhook, and can be [verified using the provided signature](/api-reference/v2/webhooks/overview#verifying-requests). If your server responds with a `2xx` status code, we'll consider the redemption to have been fulfilled. Otherwise, we'll keep retrying until a `2xx` code is returned. > [card] [rewards/store_fulfilment](/api-reference/v2/webhooks/events/rewards-store-fulfilment) > > Find out more about the `rewards/store_fulfilment` webhook # Emails Source: https://developers.loyaltylion.com/docs/features/emails LoyaltyLion can send emails to your customers: * When they create an account, welcoming them to your loyalty program * When they earn enough points for a reward, providing them with one-click reward redemption from their inbox * Every month, if they have enough points for a reward By default, your loyalty emails start out turned off so you can tweak them before we'll start sending them to your customers. Log in to your LoyaltyLion account and click the 'Emails' tab to edit and preview all your emails. For more information, see our [emails guide](https://help.loyaltylion.com/en/articles/1965842-loyaltylion-emails). *** ## Edit emails Every email in LoyaltyLion can be fully customized using the [Liquid markup language](https://github.com/Shopify/liquid/wiki/Liquid-for-Designers). Please see below for a reference of available variables you can use in your email HTML. > [accordion] Variables > > **\{\{ program_name }}** > > The name of your loyalty program > > **\{\{ store_name }}** > > The name of your store > > **\{\{ customer.first_name }}** > > The first name of the customer > > **\{\{ customer.full_name }}** > > The full name of the customer > > **\{\{ customer.email }}** > > The email address of the customer > > **\{\{ customer.points_approved }}** > > The number of approved (can be redeemed for rewards) points the customer has > > **\{\{ customer.points_pending }}** > > The number of pending (not yet redeemable) points the customer has > > **\{\{ customer.referral_url }}** > > The customer's unique referral URL, for example, `https://prz.io/KzByQ2Fa` *** ## Track email results When a customer follows a link to your store in one of our emails, it contains `ll_eid` parameter in the URL. You can use this in your own analytics to determine how many people are visiting your store from our emails. We can also show you how much revenue has been generated because of our emails, that is, customers who clicked a link to visit your store and then immediately made a purchase. If you're on Shopify or Adobe Commerce, we'll track this for you automatically. If you've integrated LoyaltyLion using our API, you'll need to send us the email tracking ID with purchases ## Manage unsubscribes All emails sent by LoyaltyLion contain an unsubscribe link. When clicked, we'll add that customer to our unsubscribe list and won't send them loyalty emails in future. You can manage and view unsubscribes using our APIs, or subscribe to a webhook to receive a notification anytime a customer unsubscribes. > [card] [Unsubscribe API](/api-reference/v2/resources/emails/list-unsubscribes) > > Find out more about our APIs to manage unsubscribes > [card] [Unsubscribe webhook](/api-reference/v2/webhooks/events/loyalty-emails-unsubscribe) > > Find out more about our unsubscribe webhook # In-cart rewards Source: https://developers.loyaltylion.com/docs/features/in-cart-rewards In-cart rewards lets your shoppers redeem their points for free products, without the use of any voucher code. These products are added directly to the cart, for free, and can be checked out as normal. To set up in-cart rewards on your store, please refer to our [reference documentation](https://github.com/loyaltylion-docs/shopify-incart-rewards-reference). # Referrals Source: https://developers.loyaltylion.com/docs/features/referrals LoyaltyLion has a built-in referral solution, which can be used to track and reward referrals. Customers can refer friends by sharing their unique referral link. Referral links look like `https://prz.io/a482k` and are permanent 301 redirects to your site, so you get the SEO benefits of them being shared. Each share location (Twitter, Facebook, email, etc) is tracked separately, so you'll be able to see in your LoyaltyLion dashboard which source is generating the most referrals. ## Enable referrals To activate the referral feature, you need to add an activity rule to reward referrals. If you didn't do this during setup, you can do so by going to the Manage area in your LoyaltyLion account and creating a new "Refer a friend" rule. When referrals are enabled, the "Refer friends" page appears automatically in the Loyalty Page component. From here, your customers can refer their friends via email, social media channels and a direct link. You can also use our separate [referral modal](/sdk/modal-components/referral-modal/) component, which can pop up automatically on page load or on demand (for example, on click). ## Track referrals > [!NOTE] > > We automatically track referrals on Shopify, BigCommerce and Adobe Commerce. When someone follows one of our referral links they'll be redirected to your site with an `ll_ref_id` (referral id) parameter, for example, `https://store.example.com?ll_ref_id=a482k`. You'll need to capture this referral id, store it in your session, and send it to us when the new customer registers or places an order. Refer to our [activities API](/api-reference/v2/resources/activities/create-activity) for more information. If you're on a headless storefront or a mobile app, the Headless API supports the full referral flow, including exchanging the referral id for the referee's discount code — see the [Headless API referrals guide](/headless-api/guides/referrals). # Adobe Commerce 2 Source: https://developers.loyaltylion.com/docs/installation/adobe-commerce-2 | Adobe Commerce edition | Minimum compatible version | | - | - | | Magento 2 Open Source | 2.1 | | Adobe Commerce 2 | 2.1 | ## Understand the LoyaltyLion module The LoyaltyLion module for Adobe Commerce 2 (formerly Magento 2) has three primary responsibilities: * We add a single frontend block to your layout, which loads the [LoyaltyLion SDK](/sdk/) to provide customer UI * We add observers to your order and customer lifecycle, to keep LoyaltyLion in sync as this data changes * We use your REST API (rooted at `/rest/V1`) to retrieve store configuration and manage price rules > [!NOTE] > > We don't modify your database schema, add cron jobs, or modify customer data > within your database. This minimizes the risk of incompatibility between > LoyaltyLion and other modules. ## Install the module > [!WARNING] > > Installing Adobe Commerce modules is a complex process. We recommend giving > these instructions to the person responsible for maintaining your Adobe > Commerce setup rather than attempting to install the module yourself. **1. Install the module with composer and the Adobe Commerce command-line tools** In your Adobe Commerce project directory: ```sh theme={null} composer require loyaltylion/core magento setup:upgrade ``` **2. Provide API access** LoyaltyLion needs access to your store API to manage Price Rules and retrieve store configuration. First, make sure that you're logged into your LoyaltyLion account. Head to `System` → `Integrations`: ![Integrations](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/adobe-commerce-2/system-integrations-m2.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=e634c79f5ae324c7699701e85ed95b6c) Hit `Activate` on the LoyaltyLion integration and follow the prompts through to completion: ![Activate](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/adobe-commerce-2/activate-integration-m2.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=23706a666839a335936feed314eef40d) **3. Configure the module** > [!NOTE] > > Your Loyalty Program is completely hidden from your customers until you choose > to launch using the button on the LoyaltyLion admin dashboard. First, find the LoyaltyLion configuration section at `Stores` → `Configuration` → `Customers` → `LoyaltyLion`: ![Configuration](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/adobe-commerce-2/configuration-loyaltylion-m2.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=a976989477d710a07009128437202056) Next, pick your configuration scope. Pick the **website** you wish to set up a Loyalty Program for. LoyaltyLion isn't visible or active for customers on other **websites** hosted on the same Adobe Commerce server. ![Choose scope](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/adobe-commerce-2/choose-scope-m2.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=278c92e7f50cbcb30b3eb4131683e08b) Then, enter your LoyaltyLion `secret` and `token`. You can find these by referring to your setup page. > [!WARNING] > > Each token-secret pairing may only be used once. If you wish to install LoyaltyLion on multiple websites, then you need a secondary program. Please email [support@loyaltylion.com](mailto:support@loyaltylion.com) if you wish to add one. ![Enter token and secret](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/adobe-commerce-2/enter-token-secret-m2.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=a86d63f68eb979a3517cc30f2d65031b) Don't forget to save your configuration. ![Save configuration](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/adobe-commerce-2/save-configuration-m2.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=60296d7b9559047c4cd80a63b8aa236d) **4. Validate your installation** > [!TIP] > > You can now return to [setup page](https://app.loyaltylion.com/go/setup/validate-magento-install) and check to see if LoyaltyLion was installed correctly. # Custom Source: https://developers.loyaltylion.com/docs/installation/custom ## Before you start In order for an integration with LoyaltyLion to be possible, there are a few key concepts and behaviors that your ecommerce store must support. ## Customer identity You must have a customer account system with a single notion of customer identity. > [!NOTE] > > Customers don't sign up for a separate "loyalty account" with the loyalty > program - your store is responsible for their account membership status, and > having an account with your store is equivalent to being enrolled in the > loyalty program. A good choice for this identity is the row ID associated with a customer's record in your database, but it can be anything - **as long as it's unique per customer and doesn't change**. You'll use this throughout as the `customer_id` field for the customer - for example, when [submitting orders](/api-reference/v2/resources/orders/list-orders). This is how we reconcile all their activity with a single loyalty program membership. ## Discount vouchers **Your checkout must support single-use fixed discount voucher codes** (for example, \$5 off), as these form the basic rewards available from your loyalty program. You must be able to bulk pre-generate these voucher codes for import into LoyaltyLion (so we can issue them to your customers). When a customer claims a reward in exchange for points, we issue one of these pre-generated voucher codes for use in your checkout. We don't implement the behaviour of those codes - that's fully up to your store or ecommerce platform's checkout. ## Integration points To complete the integration with LoyaltyLion, complete the following steps: > [accordion] Tell us when customers create an account with your store > > When a customer signs up for an account with your store, you should submit a > `$signup` event via the LoyaltyLion API. This tells us that the customer has > upgraded from a guest account to a full membership, and it lets us give them > points for signing up if you have that rule enabled. See the [activities > endpoint](/api-reference/v2/resources/activities/create-activity) for exact details on > the payload to submit. > > > [!NOTE] > > > > If a customer requests to leave your loyalty program, you can submit a > > request to [our support team](mailto:support@loyaltylion.com) to delete > > their account and personal information in line with GDPR. > [accordion] Tell us when orders are placed, paid, refunded and cancelled > > When an order is placed, edited, paid, refunded, or cancelled, you should tell us via the [orders endpoints](/api-reference/v2/resources/orders/update-order). > > * The `merchant_id` field is the ID of the order within your system > * The `customer_id` field is your [customer identity](#customer-identity) > * The `discount_codes` field should contain all discount codes used with this order. Vouchers previously [issued as rewards](#create-rewards-and-import-voucher-codes) are marked as used within our system, and any unknown vouchers are ignored. > [accordion] Load the LoyaltyLion SDK and customer UI > > The LoyaltyLion SDK gives you tools to display a loyalty program UI to your customers. > > To use it: > > 1. [Install the SDK snippet](/sdk/installation) on all pages on your store > 2. [Authenticate your customers](/sdk/customer-authentication/) with a server-side generated HMAC based on your [customer identity](#customer-identity) > 3. [Initialize the SDK](/sdk/initialize-sdk/), using that HMAC when a customer is logged in > > Once the core SDK is installed and customers are authenticated, you can add UI components, like [the loyalty page](/sdk/embeddable-components/loyalty-page/) to your store. > [accordion] Create rewards and import voucher codes > > The last step is to set up some rewards for your customers to claim: > > 1. [Create a new reward](https://help.loyaltylion.com/en/articles/2585614-use-rewards-to-improve-customer-engagement/) > 2. In your store backend, create at least 500 unique voucher codes for use with that reward & import them into the reward you've created in LoyaltyLion > 3. Validate that you've created working codes on your store by [claiming a reward yourself](https://help.loyaltylion.com/en/articles/2370834-how-to-claim-and-redeem-rewards/) and attempting to use it in your checkout. On top of this, you can offer extra loyalty program features with: * [Referrals](/docs/features/referrals) * [Custom rewards](/docs/features/custom-rewards) * [Custom rules](/api-reference/v2/resources/activities/create-activity) * More advanced UI [customisation](/sdk/#customisation) # Headless Shopify Source: https://developers.loyaltylion.com/docs/installation/headless-shopify LoyaltyLion has support for headless Shopify stores. Install LoyaltyLion via Shopify as normal, and follow the steps below to handle the frontend implementation of the SDK on your side. In order for LoyaltyLion UI to show on the page, you need to: 1. [Install the SDK](/sdk/installation) 2. [Initialize the SDK](/sdk/initialize-sdk/) > [!WARNING] > > The SDK should be loaded on every page on your store, otherwise your > customers might not be able to view the loyalty program. 3. [Handle customer authentication](/sdk/customer-authentication/) ## Reward support on headless Shopify ### Supported rewards: * [Discount (flat and percentage)](https://help.loyaltylion.com/en/articles/5998069-reward-discount-flat-and-percentage) * [Free shipping](https://help.loyaltylion.com/en/articles/1965657-reward-free-shipping) * [Free product (voucher)](https://help.loyaltylion.com/en/articles/1965659-rewards-free-product-voucher) * [Subscription rewards](https://help.loyaltylion.com/en/articles/1965665-reward-subscription-rewards) * [Gift cards](https://help.loyaltylion.com/en/articles/1965669-shopify-plus-gift-cards) (Shopify only) ### Unsupported rewards: On a headless storefront, features that interact with the frontend Shopify API are not expected to work. These include the following rewards: * [Free product (seamless)](https://help.loyaltylion.com/en/articles/1965660-reward-free-product-seamless) * [In-cart product rewards](https://help.loyaltylion.com/en/articles/1965666-in-cart-rewards-and-instant-points) (Shopify only) ## Feature support on headless Shopify ### Supported features: * [Shopify Scripts](https://help.loyaltylion.com/en/articles/4283200-shopify-plus-shopify-script-editor-instruction-manual) (legacy) * [Notifications](https://help.loyaltylion.com/en/articles/6359870-notifications) (includes enhanced notifications) * [Redeem at checkout](https://help.loyaltylion.com/en/articles/7135405-reward-redeem-points-at-checkout) (standard Shopify checkout only) # Magento 1 Source: https://developers.loyaltylion.com/docs/installation/magento-1 LoyaltyLion has support for Magento 1. You still install LoyaltyLion via Magento as normal, however you will need to handle the frontend implementation of the SDK yourself. > [!WARNING] > > Magento 1.x hit end-of-life in June 2020. We do not accept new Magento 1.x > signups. ## Version support LoyaltyLion has full support for Magento 1, both the community and enterprise editions. This is the guide for Magento 1.x. | Magento edition | Minimum compatible version | | - | - | | Magento 1 Community | 1.7 | | Magento 1 Enterprise | 1.12 | ## Understand the LoyaltyLion extension The LoyaltyLion extension for Magento 1 has three primary responsibilities: * We add a single frontend block to your layout, which loads the [LoyaltyLion SDK](/sdk/) to provide customer UI * We add observers to your order and customer lifecycle, to keep LoyaltyLion in sync as this data changes * We add an additional REST API endpoint to manage price rules and rewards > [!NOTE] > > We don't modify your database schema, add cron jobs, or modify customer data > within your database. This minimizes the risk of incompatibility between > LoyaltyLion and other modules. ## Install Magento 1 Download the [LoyaltyLion for Magento 1.x](https://s3-eu-west-1.amazonaws.com/loyaltylion-static/magento/LoyaltyLion-1.7.0.tgz) package file. **1. Install the extension** Once downloaded, sign in to the back office as an administrator and navigate to `System > Magento Connect Manager`. ![Magento Connect Manager](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/magento-1/connect-manager.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=674ba6136f3bd16d49c65da12e5909c4) Select the LoyaltyLion package file you just downloaded and click **Upload**. ![Upload package](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/magento-1/upload-package.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=0c01670f2116a21eba3f971ea2ca5e25) > [!WARNING] > > You must now logout of the back office and then log back in again for the module to be fully loaded in your shop. **2. Configuration** > [!NOTE] > > Your Loyalty Program is completely hidden from your customers until you choose > to launch using the button on the LoyaltyLion admin dashboard. First, you need to enable the extension. In Magento, head to `System > Configuration` and then click the **LoyaltyLion** option, in the left menu under **Customers**. ![LoyaltyLion configuration](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/magento-1/configuration-loyaltylion.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=3a6bba248561b7b7a0cec9977990c382) Next, you need to pick your configuration scope. Pick the **website** you wish to set up a Loyalty Program for. LoyaltyLion isn't visible or active for customers on other **websites** hosted on the same Magento server. > [!NOTE] > > Each token-secret pairing may only be used once. If you wish to install LoyaltyLion on multiple websites, then you need a secondary program. Please email [support@loyaltylion.com](mailto:support@loyaltylion.com) if you wish to add one. ![LoyaltyLion configuration scope](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/magento-1/choose-scope.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=73d60f2e5a3a0e5dd3fdf9cccb34dc45) **3. Connect and authenticate** Enter your LoyaltyLion `secret` and `token`. You can find these by referring to your setup page. Click on the **LoyaltyLion configuration** bar and enter the following details in the boxes provided, then press **Configure API access**: ![API configuration](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/documentation/magento-1/api-configure.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=1fd371607f712f0e69aa18af20e1c165) > [!TIP] > > You can now return to the setup page and check to see if LoyaltyLion was > installed correctly. **4. Cache configuration** > [!TIP] > > Customers are authenticated with the LoyaltyLion SDK based on a server-generated token. [Before launching your loyalty program, ensure that the `loyaltylion_sdk` block isn't cached](https://help.loyaltylion.com/en/articles2197829-ee-cache-debugging-on-magento). # Shopify Source: https://developers.loyaltylion.com/docs/installation/shopify LoyaltyLion has full support for Shopify and Shopify Plus. When you install the LoyaltyLion app on Shopify, we'll automatically integrate with your store. ## Install LoyaltyLion Shopify app If you haven't already, you can install the app from here: [https://apps.shopify.com/loyaltylion/](https://apps.shopify.com/loyaltylion/) ## Add the SDK to your theme During setup journey, you'll enable the LoyaltyLion App Embed Block on your store. This will load the [LoyaltyLion SDK](/sdk/) - without any edits to your theme. Don't worry - nothing will be visible to your customers until you hit the **Launch** button. ## Legacy `loyaltylion.liquid` If you installed LoyaltyLion on Shopify before December 2023, we'll have created a file called `loyaltylion.liquid` and included it automatically in your `theme.liquid`. We recommend that you migrate to use app embed blocks to load your SDK. To do so, follow our [migration guide](https://help.loyaltylion.com/en/articles/8608718-enable-loyaltylion-via-shopify-app-embeds). # Introduction Source: https://developers.loyaltylion.com/docs/introduction Welcome to the LoyaltyLion technical documentation. These docs will help you get up and running with LoyaltyLion and add our advanced features to your store. ## Installation > [card] [Shopify](/docs/installation/shopify) > > Install on Shopify or Shopify Headless > [card] [Adobe Commerce 2](/docs/installation/adobe-commerce-2) > > Install on Adobe Commerce 2 (formerly Magento 2) > [card] [Custom](/docs/installation/custom) > > Install on a custom platform using our API ## Questions? We're always happy to help with using our API and SDK. Contact us at [support@loyaltylion.com](mailto:support@loyaltylion.com) for help or feedback on these docs # Configuration Source: https://developers.loyaltylion.com/sdk/configuration The LoyaltyLion SDK can be configured using the `loyaltylion.configure` function. ## Class-based isolation We apply a set of 'isolation' styles to ensure that our components look good regardless of a theme's existing CSS. By default, this is implemented by rendering the root of our component trees with an `id="loyaltylion"` element, allowing us to target our isolation styles using `#loyaltylion ... { ... }` which enables robust and reliable isolation. This has the potential side effect of rendering more than one element on the page with the `#loyaltylion` id, which can raise warnings with some web standards validation tools. If you prefer to use class-based isolation, you can use a configuration option to do so: ```javascript theme={null} loyaltylion.configure({ useClassIsolator: true, }) ``` This causes our components to render with a new `lion-isolator`, and subsequently your CSS customisations need to use this as well. From the example above, this now looks like: ```css theme={null} /* instead of #loyaltylion */ .lion-isolator .lion-loyalty-panel-sidebar__title { font-weight: bold; } ``` > [!NOTE] > > Note that class-based isolation is inherently less robust than id based > isolation, and using it may require you to implement additional CSS overrides > to address any conflicts that arise between your theme's styles and our > components. #### Preview class-based isolation To facilitate easy adoption of class-based isolation, you can enable it for a single pageview by adding a `?ll_use_class_isolator=1` query param. This allows you to try it out and see what additional CSS you may need to apply to address any style conflicts. ## Disable our default styles It's possible to prevent our default styles from loading entirely, so you can start from a completely blank slate. To do this, set the `disableBundledCSS` option to `true` when you configure the LoyaltyLion SDK: ```javascript theme={null} loyaltylion.configure({ disableBundledCSS: true, }) ``` ## Disable our default fonts By default, we load the `Source Sans Pro` font, when using your own font your should disable ours to avoid loading an unnecessary font. To do this, set the `disableBundledFonts` option to `true` when you configure the LoyaltyLion SDK: ```javascript theme={null} loyaltylion.configure({ disableBundledFonts: true, }) ``` ## Indicate your Shopify frontend type By default, we'll assume that you're running on a native Shopify theme, and the SDK uses Shopify frontend APIs such as [`cart.js`](https://shopify.dev/docs/api/ajax/reference/cart). If you're running a headless Shopify store, these APIs may not be available. To explicitly configure the SDK not to use these APIs, you can specify the `shopifyFrontend` configuration option. This turns off some features which depend on those APIs, such as [in-cart rewards](/docs/features/in-cart-rewards): ```javascript theme={null} loyaltylion.configure({ shopifyFrontend: 'unknown', }) ``` # Customer authentication Source: https://developers.loyaltylion.com/sdk/customer-authentication When a customer is logged in, the LoyaltyLion SDK needs to authenticate them to display their information (points, rewards) and allow them to perform actions like earning points and claiming rewards. > [!NOTE] > > Customer authentication is performed automatically on Shopify, BigCommerce and > Adobe Commerce. Authentication in LoyaltyLion leverages your existing customer accounts so a customer doesn't need to sign in twice or have a separate account with LoyaltyLion. It works by generating a secure server-side Message Authentication Token (MAC) which is passed through to LoyaltyLion on the next page load. LoyaltyLion verifies the auth token and if it checks out, considers the customer authenticated. ## Create the auth token The auth token is a `SHA-1` hash of the following concatenated items, in order: * the customer's unique `id`, holding no whitespace and nothing that reads as a date, such as `2026-01-31` * the current date, as an `ISO 8601` timestamp carrying a UTC offset, such as `2026-01-31T10:00:00Z` or `2026-01-31 10:00:00+0000`: the full date, then `T` or a space, then hours, minutes and seconds, then `Z` or an offset like `+01:00`. Fractional seconds are allowed. A timestamp with no offset, with no seconds, or with the date written without its dashes, is refused * the customer's email address * [your LoyaltyLion secret](https://app.loyaltylion.com/go/manage/settings/) This auth token must be generated server-side, that is, in your template. Your LoyaltyLion secret should never be exposed. The generated token can then be sent to the client and used in a call to [`loyaltylion.init`](/sdk/initialize-sdk/) or [`loyaltylion.authenticateCustomer`](/sdk/customer-authentication#authentication-after-initialization) to authenticate the customer. #### Auth token creation example ```ruby Ruby theme={null} date = DateTime.now.iso8601 secret = 'YOUR_SECRET' auth_token = Digest::SHA1.hexdigest( current_user.id.to_s + date + current_user.email + secret ) ``` ```php PHP theme={null} $date = date('c'); $secret = 'YOUR_SECRET'; $auth_token = sha1( $user->id . $date . $user->email . $secret ); ``` ```ruby Shopify (liquid) theme={null} {% assign date = 'now' | date: "%Y-%m-%dT%H:%M:%S%z" %} {% assign auth_token = customer.id | append: date | append: customer.email | append: 'YOUR_LOYALTYLION_SECRET' | sha1 %} date: {{ date }} auth token: {{ auth_token }} ``` *** ## Authentication with initialization The best way to authenticate the customer is by passing the customer and auth data to the `loyaltylion.init` call. This ensures the customer is authenticated as soon as the LoyaltyLion SDK is ready. You should call `loyaltylion.init` conditionally on the customer's logged in state, that is, passing just the site token [(initialize example without customer)](/sdk/initialize-sdk#initialize-example-without-customer) if a customer isn't logged in, or passing the customer information and authentication data [(initialize example with customer)](/sdk/initialize-sdk#initialize-example-with-customer) if a customer is logged in. The date passed in the `auth` object must be the same timestamp used to generate the [auth token](#create-the-auth-token). ## Authentication after initialization If you need to authenticate the customer later (for example, if they're able to log in without a full page reload or authentication happens after the page load), you still need to call `loyaltylion.init` at the same time as loading the snippet, with just the site token and no customer information. You can later pass the customer information and authentication data in the `loyaltylion.authenticateCustomer` method. This method accepts the same `customer` and `auth` properties as `loyaltylion.init`. It needs a [server-side generated auth token](/sdk/customer-authentication/#create-the-auth-token). The date passed in the `auth` object must be the same timestamp used to generate the [auth token](#create-the-auth-token). #### Authentication after initialization example ```javascript theme={null} loyaltylion.authenticateCustomer({ customer: { id: '1001', // unique customer ID email: 'alice@example.com', // customer email address }, auth: { date: '2018-01-01T10:00:00Z', // ISO 8601 timestamp, must be same as that used to create the token token: 'AUTH_TOKEN', // token, generated server-side }, }) ``` ## Log a customer out of LoyaltyLion You can log out a customer using the `logoutCustomer` method. This removes the signed-in customer's data and refreshes the LoyaltyLion UI without requiring a full page reload. This can be particularly useful for single page applications (SPA) that support customers logging in / out without full page reloads. Note that this is an asynchronous method. If no customer is currently signed in you will see a warning message in the console. ```js theme={null} // with async/await await loyaltylion.logoutCustomer() // with promises loyaltylion.logoutCustomer().then(() => { console.log('Customer is logged out!') }) ``` # Challenges Source: https://developers.loyaltylion.com/sdk/embeddable-components/challenges > [!NOTE] > > Available on the **Advanced plan** and above. Use this component to render the customer's active [loyalty challenges](https://help.loyaltylion.com/en/articles/15420753-challenges) anywhere on your storefront — the same challenges shown on your loyalty page, embedded on their own. Each challenge renders as a progress tracker toward its point and reward milestones. When more than one challenge is active, they display as a stacked list or, if you enable the Tabs layout in your theme settings, behind a tabbed selector showing one at a time. > [!NOTE] > > This component requires a logged-in customer. If the customer isn't logged in, > or has no active challenges, it renders nothing. ## Code ```html theme={null}
``` # Claimed rewards list Source: https://developers.loyaltylion.com/sdk/embeddable-components/claimed-rewards-list > [!NOTE] > > Available on the **Advanced plan** and above. Use this component to render a list of all the claimed rewards owned by the current customer. If a customer is logged in, a list of claimed reward items is displayed. Each item contains a "View reward" button which opens a [claimed reward modal](/sdk/modal-components/claimed-reward-modal/) when clicked. Without a customer this component doesn't render anything. ## Code ```html theme={null}
``` ## Preview ![Claimed rewards list](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/claimed-rewards-list.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=cc61b175496d35454ccbb5bfa4d9dac6) ## Options You can also hide all the used and/or void (refunded) claimed rewards from the list. For example, to show only claimed rewards that the customer can use, include both of the appropriate data attributes in the element like so: ```html theme={null}
``` # Drops Source: https://developers.loyaltylion.com/sdk/embeddable-components/drops Use this component to show a shopper your drops anywhere on your storefront. It renders the same drop card as the campaigns section of your loyalty page, so you can use drops without building your loyalty page in the Theme Editor. The card shows the drop most relevant to the shopper, and names up to three other live or upcoming drops underneath it. When there is more than one drop, an "All drops" link opens a window listing all of them. ## Code ```html theme={null}
``` ## Behaviour The component renders for every shopper, logged in or not: | Shopper state | What renders | | - | - | | Not logged in | A running or upcoming drop, locked, with a link to join your program. | | Member with a drop of their own | That drop: upcoming, live, sold out, or the last one they took part in. | | Member with no drop of their own | A running or upcoming drop for another tier, locked and labelled with the tiers that can claim it. | | No drop applies | Nothing. The component renders no markup. | The card updates without a page reload when an upcoming drop opens or a drop ends. The card uses the styling you set for drops in the Theme Editor, and is wrapped in an element with the `lion-campaigns` class. Unlike the loyalty page section, it has no heading. > [!NOTE] > > Drops are available on Shopify stores whose subscription includes them, > through the plan or the Drops add-on. Otherwise this component renders > nothing. # History table Source: https://developers.loyaltylion.com/sdk/embeddable-components/history-table > [!NOTE] > > Available on the **Advanced plan** and above. Use this component to render a table containing the current customer's loyalty program history. This table will include: * rewards claimed * activities completed * miscellaneous transactions (for example, points added manually or points expired) All rows, except transactions, have a clickable `Status` field. This opens a [history info modal](/sdk/modal-components/history-info-modal/) that corresponds to the item. ## Code ```html theme={null}
``` ## Preview ![History table](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/history-table.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=e18910831d3bb9f357930cee88e6528a) # Join the program Source: https://developers.loyaltylion.com/sdk/embeddable-components/join-program Render a "Join the program" button anywhere on your storefront, so shoppers can enroll in your loyalty program from a page you have built yourself out of embeddable components. This is intended for programs using **manual opt-in** enrollment, where a shopper has to actively join before they earn points. The built-in loyalty page already includes a join button — this component gives you the same action on a custom page. ## Code ```html theme={null}
``` ## Behaviour The button adapts to the shopper's state: | Shopper state | What renders | | - | - | | Not logged in | A button linking to your store's sign-up page — a store account is required. | | Logged in, not yet enrolled | A button that enrolls them in the program in place, without leaving the page. | | Already enrolled | Nothing. The component renders no markup. | While enrollment is in progress the button shows a loading state and is disabled. If enrollment fails, an inline error message is shown beneath the button and the shopper can try again. Once enrollment succeeds, other components on the page that require an enrolled member — such as points balance, referral URL, or tier progress — begin rendering without a page reload. > [!NOTE] > > If your program enrolls customers automatically, every logged-in shopper is > already a member, so this component renders nothing for them. Blocked > customers are treated as members too, so they see nothing rather than an > invitation to re-join. ## Styling The button uses the same `lion-action-button` class as other LoyaltyLion buttons, so any custom CSS you already apply to them applies here too. The inline failure message is a `lion-join-program__error` element, which you can style to match your page. # Loyalty page Source: https://developers.loyaltylion.com/sdk/embeddable-components/loyalty-page The Loyalty Page is a standalone page that displays a customer's loyalty information. The Loyalty Page is a monolithic, self-contained component which lets customers interact with all aspects of the loyalty program, for example, viewing ways to earn points, redeeming rewards. This is our "plug and play" component. Adding it onto a page is the fastest way to get started with LoyaltyLion. The Loyalty Page is fully responsive and switches to a more compact, mobile friendly view on smaller screens. ## Code ```html theme={null}
``` ## Preview ### Customer view ![Loyalty page](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/loyalty-page-member-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=d03c9f6733ba6a7cc2fa175f34cb08f5) ### Guest view ![Loyalty page](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/loyalty-page-guest-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=f8416e03fbff194dce5d395e25f1434c) # Loyalty panel Source: https://developers.loyaltylion.com/sdk/embeddable-components/loyalty-panel > [!WARNING] > > Loyalty panel and widget are a legacy interface, that we are slowly retiring. If you still use loyalty panel - we'll be in touch with you, when it's your time to upgrade. > > If you'd like to make the change earlier and take advantage of our new UI, contact us at [support@loyaltylion.com](mailto:support@loyaltylion.com). > > Please note that if you joined LoyaltyLion after 2022, you will not have access to this UI. The Loyalty Panel is a monolithic, self-contained component which lets a customer interact with all aspects of the loyalty program, for example, viewing ways to earn points, redeeming rewards. This is our "plug and play" component. Dropping this onto a page (or having it open in a modal) is the fastest way to get started with LoyaltyLion. The Loyalty Panel is fully responsive and switches to a more compact, mobile friendly view on smaller screens. When no customer is logged in, this component switches to rendering a simpler "Loyalty Splash" designed to introduce your program to guest shoppers. ## Live preview ### Guest view ![Loyalty Panel - Guest view](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/loyalty-panel-guest-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=43e9dbe9ea38989dad1d351702c296d0) ### Customer view ![Loyalty Panel - Customer view](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/loyalty-panel-customer-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=f4fc9b63e16fa317cd6683377f30666c) ## Embed panel on a page Use the following code to embed the Loyalty Panel on a page: ```html theme={null}
``` By default, the Loyalty Panel expands horizontally to fill the available space. For best results, don't add anything to either side of the panel. You can make the Loyalty Panel open on a specific page when it loads by including a `tab` parameter in the URL of the page containing the embedded component: ``` https://example.com/page/rewards?tab=help ``` > [!NOTE] > > The embedded Loyalty Panel is only visible for programs that have been > launched. ## Open in a modal You can open the Loyalty Panel in a modal by adding the `data-lion-account-link` attribute to any element. You can open it on a specific page by passing a value to this attribute. The available pages you can open on are: * `redeem` (default) * `earn` * `refer` * `history` * `help` ```html theme={null} Access your Rewards About our Loyalty Program ``` *** If you have the [Loyalty Widget](/sdk/simple-components/loyalty-widget/) enabled, it opens the Loyalty Panel in a modal on click. # Rewards list Source: https://developers.loyaltylion.com/sdk/embeddable-components/rewards-list > [!NOTE] > > Available on the **Advanced plan** and above. Use this component to render a list of available rewards. If a customer is logged in, the reward items are interactive and contain a "Get reward" button. When clicked, this opens a [redeem reward modal](/sdk/modal-components/redeem-reward-modal/) that provides more information about the reward and allow it to be redeemed. ## Code ```html theme={null}
``` ## Preview ### Customer view ![Rewards list](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/rewards-list-customer-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=e8afcba0cbe945a90af7e40488542579) ### Guest view ![Rewards list](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/rewards-list-guest-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=4bdfa9b0133761f8d6747e9e515c5744) # Rules list Source: https://developers.loyaltylion.com/sdk/embeddable-components/rules-list > [!NOTE] > > Available on the **Advanced plan** and above. Use this component to render a list of rule items, which are how customers can earn points. If a customer is logged in, the rule items are interactive. When a rule item is clicked, its corresponding [rule modal](/sdk/modal-components/rule-modal/) opens, which tells them more about the rule, and (for some rule types) allow them to complete the action within the modal. ### Referral rule If you have the referral rule enabled, instead of displaying a rule modal on click, the [referral modal](/sdk/modal-components/referral-modal/) is shown instead. ## Code ```html theme={null}
``` ## Preview ### Guest view ![Rules list - guest view](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/rules-list-guest-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=e54cc26387e525d64fc7459127186ee0) ### Customer view ![Rules list - customer view](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/rules-list-customer-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=0fb1976f40b045acbb94611e88391843) # Tier benefits compare Source: https://developers.loyaltylion.com/sdk/embeddable-components/tier-benefits-compare Use this component to render a comparison of the benefits available to each tier. These are (by default) be color coded based on the tier's color, but can be overridden using CSS. Each `td` has a CSS class indicating the tier it is a part of (numbered based on position, from 0). For example, to select the benefit status circles in tier-0: ``` .lion-tier-benefits-compare__row-cell--tier-0 .lion-tier-benefits-compare__benefit-status-circle ``` If a benefit is enabled for a tier, it contains a `--enabled` modifier: ``` .lion-tier-benefits-compare__benefit-status--enabled ``` If customer is logged in, it attaches a `--current` modifier to the tier that customer is currently in: ``` .lion-tier-benefits-compare__benefit-status--current ``` ## Code ```html theme={null}
``` ## Preview ![Tier benefits compare](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/tier-benefits-compare.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=881ff219acebe23ca5663e2000a94c70) # Tier overview Source: https://developers.loyaltylion.com/sdk/embeddable-components/tier-overview Use this component to render an overview of your loyalty tier program, containing the current customer's loyalty tier membership (if logged in). This overview includes: * Tier names * Tier conditions * Tier purchase rule value * Tier benefits If customer is logged in, it shows: * Footer indicating the current tier * Progress towards the next tier > [!WARNING] > > If you use our legacy [loyalty panel](/sdk/embeddable-components/loyalty-panel/) - to add the text for Tier benefits, please submit a request to our [support](mailto:support@loyaltylion.com) team with the benefits you want to add for each tier. > > If you use our new Loyalty Page interface, you can add tier benefits yourself in the [Tiers](https://app.loyaltylion.com/go/manage/tiers/) tab. ## Code ```html theme={null}
``` ## Preview ![Tier overview](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/tier-overview.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=20550bd613b9fd7f4e69254053b3190b) # Tier progress Source: https://developers.loyaltylion.com/sdk/embeddable-components/tier-progress > [!NOTE] > > Available on the **Advanced plan** and above. Display a progress bar of the customer's tier position and membership status. The component will render information about points-, spend- or order-count-based tiers based on your tier settings. > [!NOTE] > > For points-based tiers: Please note that unlike approved points, tier points > do not go down when points are redeemed for a reward. Read more about > [customer tier > progress](https://help.loyaltylion.com/en/articles/9042359-customer-tier-progress). > [!NOTE] > > For order-count tiers: an order counts once it is paid or partially paid, and > stops counting if it is cancelled or fully refunded. A partially refunded > order still counts as one order. If your program sets a minimum qualifying > order value, an order only counts when its value, net of refunds and gift > cards, meets that minimum, and the component shows the minimum next to the > order count. ## Multi-tier Displays the customer's progress through all tiers. ![Tier progress - multi tier](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/tier-progress-multi.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=1d450c9a7eca600cd532354f1c0baadf) ```html theme={null}
``` ## Single-tier Displays the customer's progress within their current tier. ![Tier progress - single tier](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/tier-progress-single.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=545cbd9e4444e04f88027623013a5164) ```html theme={null}
``` # Tier rewards compare Source: https://developers.loyaltylion.com/sdk/embeddable-components/tier-rewards-compare Use this component to render a comparison of rewards available and their costs for each tier. If a reward isn't available for a certain tier, it renders an empty cell. Each `td` has a CSS class indicating the tier it is a part of (numbered based on position, from 0). For example, to select the reward costs in tier-0: ``` .lion-tier-rewards-compare__row-cell--tier-0 .lion-tier-rewards-compare__reward-cost ``` If customer is logged in, it attaches a `--current` modifier to the tier that customer is currently in: ``` .lion-tier-rewards-compare__row-cell--current ``` ## Code ```html theme={null}
``` ## Preview ![Tier rewards compare](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/tier-rewards-compare.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=4cf7953b6b67aa714cdd5220eda324b2) # Tier rules compare Source: https://developers.loyaltylion.com/sdk/embeddable-components/tier-rules-compare Use this component to render a comparison of rules available and their point values for each tier. If a rule isn't available for a certain tier, it renders an empty cell. Each `td` has a CSS class indicating the tier it is a part of (numbered based on position, from 0). For example, to select the rule values in tier-0: ``` .lion-tier-rules-compare__row-cell--tier-0 .lion-tier-rules-compare__rule-value ``` If customer is logged in, it attaches a `--current` modifier to the tier that customer is currently in: ``` .lion-tier-rules-compare__row-cell--current ``` ## Code ```html theme={null}
``` ## Preview ![Tier rules compare](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/tier-rules-compare.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=04c444cc8775d7feadd562fee825d4a3) # Initialize the SDK Source: https://developers.loyaltylion.com/sdk/initialize-sdk You can interact with the LoyaltyLion SDK using its JavaScript API. You can use this to initialize and authenticate the SDK, configure various settings, and listen to events emitted when customers take various actions. The LoyaltyLion SDK adds itself to the `window.loyaltylion` variable. ## Initialization > [!NOTE] > > `loyaltylion.init` is called automatically for Shopify, BigCommerce and Adobe > Commerce installations. `loyaltylion.init` should be called once per page load to initialize the LoyaltyLion SDK and (if applicable) authenticate the current logged in customer. You'll need your [LoyaltyLion site token](https://app.loyaltylion.com/go/manage/settings/) to identify your store. ### Initialize example without customer ```js theme={null} loyaltylion.init({ token: 'YOUR_SITE_TOKEN', }) ``` > [!WARNING] > > `loyaltylion.init` should only ever been called once per page load. Calling > this method more than once throws an exception error and result in a slower > user experience. If a customer is logged in, their information and authentication data should be passed in, using a [server-side generated auth token](/sdk/customer-authentication#create-the-auth-token). ### Initialize example with customer ```js theme={null} loyaltylion.init({ token: 'YOUR_SITE_TOKEN', // site token customer: { id: '1001', // unique customer ID email: 'alice@example.com', // customer email address }, auth: { date: '2018-01-01T10:00:00Z', // date in ISO 8601 format token: 'AUTH_TOKEN', // token, generated server-side, different than the site token }, }) ``` # SDK installation Source: https://developers.loyaltylion.com/sdk/installation > [!NOTE] > > We automatically install the LoyaltyLion SDK into your theme on Shopify, > BigCommerce and Adobe Commerce. The LoyaltyLion SDK needs to be added into your store's template or theme to identify customers and render UI components. ## Add the SDK snippet to your template Copy the following snippet into your template's ``. ```html [expandable] theme={null} ``` ## Initialize the SDK Once you've added the snippet, the LoyaltyLion SDK begins loading and assigns itself to `window.loyaltylion`, but is inactive until you initialize it with the `loyaltylion.init` method. Refer to [the initialization section](/sdk/initialize-sdk/) for more information. ## Add our UI components When the SDK is initialized, you can start adding our UI components to your pages. The quickest way to get started is use our combined [Loyalty Page](/sdk/embeddable-components/loyalty-page/) component, which can be embedded on a page. # Live updating Source: https://developers.loyaltylion.com/sdk/live-updating > [!WARNING] > > The SDK doesn't automatically observe our components or their inputs for > changes. It's up to you to implement an update flow that is appropriate for > your use case. If you have a dynamic cart, you may have some function that runs when the cart updates. Or in some other cases you may have be dynamically creating or removing the span above as the user navigates your page. Regardless of your approach, the SDK supports a function that *refreshes* the page as necessary: ```javascript theme={null} window.loyaltylion.ui.refresh() ``` ### If the component has been removed after pageload and is then re-added * Render the component to the screen * call `window.loyaltylion.ui.refresh()` ### If the component's value needs to be updated * Update the component's attribute value * call `window.loyaltylion.ui.refresh()` #### Example Let's say you have a span showing the [points for cart](/sdk/simple-components/points-for-cart/) for the initial cart total: ```html theme={null} ``` And you have some dynamic cart functionality *(note: intended to illustrate flow and order of events only, your dynamic page content code likely looks different)*: ```javascript theme={null} // function that runs whenever the cart is updated function onCartUpdate(event, updatedCart) { const newValue = updatedCart.total // ... something that updates the prices shown in the cart window.ajaxCart.updateValues(updatedCart) // ... something that renders the new item that was just added to the cart window.ajaxCart.renderCartDrawer() // now we must find and update the cart-points span's data attribute document .getElementById('ll-cart-points') .setAttribute('data-lion-points-for', '7999') // now that we've updated the element, we tell the sdk to refresh window.loyaltylion && window.loyaltylion.ui.refresh() } ``` # Claimed reward modal Source: https://developers.loyaltylion.com/sdk/modal-components/claimed-reward-modal This modal displays information about a reward that has already been claimed. It always shows the cost of the reward in points, the date it was claimed and its status (`approved` or `void` if the reward has been refunded). Depending on the reward type, we show additional information: * **voucher** rewards show the voucher code and if the voucher has been used * **gift card** rewards show the gift card code and remaining balance * **custom** rewards indicate if the reward has been fulfilled ## Preview ![Claimed reward modal](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/claimed-reward-modal.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=3e89d2f9354cf27d5487f836efd20690) # History info modal Source: https://developers.loyaltylion.com/sdk/modal-components/history-info-modal This modal displays more information about a row in the [history table](/sdk/embeddable-components/history-table/) or the history page of the [Loyalty Page](/sdk/embeddable-components/loyalty-page/). The modal always shows: * name of history item (for example, the activity or reward name) * number of points involved * date * status Depending on the item's kind, additional information is displayed: * rewards * reward information displayed (for example, the voucher code) with the same information as the [claimed reward modal](/sdk/modal-components/claimed-reward-modal/) * activities * if status is `pending`, it shows information about when it'll be approved (for example, for purchase activities, in 10 days) * if status is `declined` or `void`, it shows information about why (for example, the associated purchase was refunded) ## Preview ![history info modal](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/history-info-modal.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=1f279c76312d7cac85fb8c24c83a18ea) # Redeem reward modal Source: https://developers.loyaltylion.com/sdk/modal-components/redeem-reward-modal This confirmation modal is shown when a customer attempts to claim a reward, either within the [Loyalty Page](/sdk/embeddable-components/loyalty-page/) or in the [standalone rewards list](/sdk/embeddable-components/rewards-list/). If the customer proceeds with claiming the reward - and it's successful - this modal transitions to show information about the newly claimed reward (for example, its voucher code). ## Preview ![redeem reward modal](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/redeem-reward-modal.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=65e63d020f73fb55c81f4b00865ee117) ### Upon successful claim ![redeem reward modal with voucher code](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/redeem-reward-voucher-code.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=b1bb1ba7db44e91b90e167dc779f9e6c) # Referral modal Source: https://developers.loyaltylion.com/sdk/modal-components/referral-modal This standalone modal allows a logged in customer to refer their friends via various channels. If no customer is logged in, it asks them to log in first and display log in and sign up buttons. > [!NOTE] > > Available on the **Advanced plan** and above. ## Open the referral modal ### On click You can open the referral modal by adding the `data-lion-refer` attribute to any element. When that element is clicked, we'll display the referral modal. ```html theme={null} Refer your friends and get $10 ``` ### On page load You can set the referral modal to open automatically on page load. To do this, in the link to your store include the parameter `ll_act=refer`. ``` https://example.com/?ll_act=refer ``` ## Preview ![referral modal](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/referral-modal.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=f9be92575aac1c3847a83039e9fef3a5) # Referee Welcome Modal With referral rule enabled, anyone who lands on your store via a referral link is greeted with this modal, which tells them about the offer and how to claim it. To enable the referral friend offer, go to the [Rules](https://app.loyaltylion.com/go/manage/rules/) section in the LoyaltyLion admin, select the referral rule and set it up in the "Friend offer" section. ## Preview ![referee welcome modal](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/referee-welcome-modal.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=9010e0f6d9eeb7de0e4079e3642b6788) # Overview Source: https://developers.loyaltylion.com/sdk/overview LoyaltyLion JavaScript SDK allows shoppers to see and interact with your loyalty program. The simplest LoyaltyLion UI uses our combined [Loyalty Page component](/sdk/embeddable-components/loyalty-page/) which can be embedded onto a page or opened as a modal on demand. If you need something more customized, there are many smaller components which can be used to construct your own interface. ## Customisation We've designed all our components to be easy to style with your own CSS as part of your normal workflow. Every component adopts [BEM methodology](https://en.bem.info/) so it's easy to target individual elements without worrying about our default CSS misbehaving. To isolate our default styles from the rest of the page, we wrap all our components inside a container with id `loyaltylion` and target this element with our default CSS (class based isolation is also available, see below). Therefore, to target any of our elements with your own CSS you'll need to ensure your selectors include `#loyaltylion`. # Customer points Source: https://developers.loyaltylion.com/sdk/simple-components/customer-points > [!NOTE] > > Available on the **Advanced plan** and above. Display the logged in customer's points on the page using customer points component. Whenever we find this component on the page, we'll set its innerHTML to the requested value. If there is no logged in customer, or the current customer has been blocked from the program, all values are `0`. *** ## Total points Total points present the sum of customer's approved and pending points ```html theme={null} ``` *** ## Approved points Approved points present customer's redeemable points that can be used to claim reward ```html theme={null} ``` *** ## Pending points Pending points shows customer's points that are yet to be approved. Points get approved automatically after the approval period passes or manually. ```html theme={null} ``` *** ## Spent points This components shows points that customer has spent in the program until now. ```html theme={null} ``` *** ## Lifetime points Lifetime points components shows the sum of customer's approved, pending, spent and expired points. ```html theme={null} ``` # Customer referral URL Source: https://developers.loyaltylion.com/sdk/simple-components/customer-referral-url > [!NOTE] > > Available on the **Advanced plan** and above. Use this component to display the current customer's unique referral URL. ## Explanation Whenever we find this component on the page, we'll set its innerHTML to the current logged in customer's personal referral URL. If no customer is logged in, we'll leave it blank. *** ## Code ```html theme={null} ``` # Loyalty widget Source: https://developers.loyaltylion.com/sdk/simple-components/loyalty-widget > [!WARNING] > > Loyalty panel and widget are a legacy interface, that we are slowly retiring. If you still use loyalty panel - we'll be in touch with you, when it's your time to upgrade. > > If you'd like to make the change earlier and take advantage of our new UI, contact us at [support@loyaltylion.com](mailto:support@loyaltylion.com). > > Please note that if you joined LoyaltyLion after 2022, you will not have access to this UI. The Loyalty Widget is a small, floating bar which can be shown at the bottom of the page. If a customer is logged in, it displays the number of points they have. When the Loyalty Widget is clicked, it opens the [Loyalty Panel](/sdk/embeddable-components/loyalty-panel/) in a modal view. You can't add the Loyalty Widget to your page directly. Instead, you can enable it from [your LoyaltyLion admin](https://app.loyaltylion.com/go/manage/customise/widgets/loyalty_widget/). *** ## Preview ### Guest view ![Loyalty widget guest view](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/loyalty-widget-guest-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=fa1c9399220bc375f2afc6ef1e8ff404) ### Customer view ![Loyalty widget customer view](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/loyalty-widget-customer-view.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=35df8283da063ad38dc8486e3ac21618) # Points for cart Source: https://developers.loyaltylion.com/sdk/simple-components/points-for-cart > [!NOTE] > > Available on the **Advanced plan** and above. Use this component to display how many points a customer would earn for their entire cart. ## Explanation The attribute value should be the total server-side value of the current cart. If you're using Shopify, you can get this value in Liquid using `{{ cart.total_price }}` > [!NOTE] > > The points shown are worked out the same way as the points for an order of > this amount, including the customer's tier and any campaign that applies to > every product. The amount names no products, so [collection > exclusions](https://help.loyaltylion.com/en/articles/1965585-activity-make-a-purchase#h_531103629b), > [point modifiers](https://help.loyaltylion.com/en/articles/6777829-points-modifier) > and [bonus > points](https://help.loyaltylion.com/en/articles/3459309-promotion-bonus-points-on-a-product-collection) > aren't included. Neither is the rule that buying a gift card earns nothing > where your program gives points for spending gift cards instead, so an > amount that includes one can show more than the order earns. > > A customer who isn't signed in sees the points they'd earn on joining, at > your default tier. Campaigns with a minimum spend aren't included for them, > and a change to your rules or campaigns can take up to an hour to show. > > The attribute value should be in cents, as the component divides the amount > by 100 before applying the purchase rule multiplier (This applies even for > currencies without subunits, this component is *not* currency aware. If your > currency doesn't have subunits, please multiply amounts by 100). *** ## Code ### Example for Shopify ```html theme={null} ``` `{{ cart.total_price }}` value is only set by Shopify on initial render on the server. If you use an ajax cart, or other functionality to dynamically update the DOM, please see the section on [live updating](/sdk/live-updating). ### Example for custom value ```html theme={null} ``` > [!NOTE] > > If you have a dynamic cart, a single page app, or anything that changes the > DOM containing loyaltylion UI components without a full page reload, you might > need to [trigger a UI refresh](/sdk/live-updating) in order for LoyaltyLion > elements to refresh upon change. # Points for product Source: https://developers.loyaltylion.com/sdk/simple-components/points-for-product > [!NOTE] > > Available on the **Advanced plan** and above. Use this component to display how many points a customer earns for purchasing a particular product. ## Explanation To show the points that are gained for purchasing a particular product, two attributes are needed. The first, `data-lion-price-for-product-id`, must be added to an element whose text content is the price of the product. The value of this attribute should be equal to the ID of the product. The second attribute, `data-lion-points-for-product-id`, sets the innerHTML of its element to the computed points value of the matching `data-lion-price-for-product-id` attribute on the page. > [!NOTE] > > The points shown are worked out the same way as the points for an order of > this product at the price on the page, including the customer's tier, > [collection > exclusions](https://help.loyaltylion.com/en/articles/1965585-activity-make-a-purchase#h_531103629b), > [point > modifiers](https://help.loyaltylion.com/en/articles/6777829-points-modifier), > [bonus > points](https://help.loyaltylion.com/en/articles/3459309-promotion-bonus-points-on-a-product-collection) > and running campaigns. Tax, shipping and discounts entered at checkout aren't > known yet, so they aren't included. > > The component knows the product and its price on the page, not which variant > the customer picks, whether they subscribe or whether the product is a gift > card. Modifiers and bonus points set for one variant or SKU, or for > subscriptions, aren't included. Where your program gives points for spending > gift cards rather than buying them, a gift card still shows the points an > ordinary product would earn. > > A customer who isn't signed in sees the points they'd earn on joining, at > your default tier. Campaigns with a minimum spend aren't included for them, > and a change to your rules or campaigns can take up to an hour to show. *** ## Code Add the below snippet to an element whose text content is the price of the product: ```html theme={null} data-lion-price-for-product-id ``` Add this snippet on the product page to compute the points value of the product price: ```html theme={null} data-lion-points-for-product-id ``` ### Example for Shopify Add `data-lion-price-for-product-id` to an element containing the price of the product. ```html theme={null} £12.99 ``` Then, insert `data-lion-points-for-product-id` where you want to show how many points a customer earns for buying this product. ```html theme={null}
Earn points
``` # Points for rule Source: https://developers.loyaltylion.com/sdk/simple-components/points-for-rule > [!NOTE] > > Available on the **Advanced plan** and above. Display the number of points that would be earned for a particular rule using this component. > [!NOTE] > > The `Points for rule` component is currently only applicable for the signup > rule. It doesn't work for all other rules. *** ## Explanation Whenever we find this component on the page, we'll set its innerHTML to the requested value. **If you're using Loyalty Tiers:** * if no customer is logged in, the value we set is the points for the default tier * if a customer is logged in, this value reflects their current tier membership *** ## Code ```html theme={null} ``` # Free product rewards Source: https://developers.loyaltylion.com/sdk/webviews/advanced/free-product-rewards On Shopify stores, shoppers can redeem free product rewards. After redemption, the target product is added to the cart and automatically discounted using a Shopify Function. A few things are needed to facilitate this flow through the LoyaltyLion WebView. **1. Listen for the sdkReady event and set the cart state** Listen for the [sdkReady](/sdk/webviews/advanced/webview-js-events#sdkready) event, which is fired when LoyaltyLion has finished loading in the WebView. Once you receive this event, you should pass the current Shopify cart state to the LoyaltyLion SDK, using the [setShopifyCartState](/sdk/webviews/advanced/webview-js-api#setshopifycartstate) method **2. Subscribe to the addCartLine event** When a free product reward has been successfully redeemed by the shopper, we'll fire the [addCartLine](/sdk/webviews/advanced/webview-js-events#addcartline) event with details of the item you need to add to the cart. **3. Subscribe to the removeCartLine event** Occasionally we'll need to remove a previously added item from the cart, for example if the shopper has cancelled the reward. We'll fire the [removeCartLine](/sdk/webviews/advanced/webview-js-events#removecartline) event when this happens, passing along the `id` of the cart line to remove from the cart. # Setup Source: https://developers.loyaltylion.com/sdk/webviews/advanced/setup The LoyaltyLion SDK supports bi-directional communication with your mobile app to facilitate more advanced features. For example, with Shopify mobile apps this can be used to have LoyaltyLion ask your app to add a voucher code or free product to the current cart. ## Setting up a WebView for advanced features > [tab] iOS WKWebView > > When LoyaltyLion is embedded in a `WKWebView`, we'll use the [WKScriptMessageHandler](https://developer.apple.com/documentation/webkit/wkscriptmessagehandler) > interface to send messages to your app. > > You'll need to register the listeners you want to support with your content controller, and then handle > them appropriately. The example below listens to the `sdkReady` event to detect when the SDK is ready to receive [WebView JS API](/sdk/webviews/advanced/webview-js-api) calls. The Loyalty Page may still be rendering at that point. > > ```swift theme={null} > class ViewController: UIViewController, WKScriptMessageHandler { > override func viewDidLoad() { > let contentController = WKUserContentController() > > // subscribe to LoyaltyLion events > contentController.add(self, name: "sdkReady") > > // continue creating WKWebView instance... > } > > func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { > if message.name == "sdkReady" { > print("LoyaltyLion SDK is ready") > } > } > } > ``` > [tab] Android WebView > > When LoyaltyLion is embedded in an Android WebView, you can add a `LoyaltyLionBridge` JavaScript interface which we'll use to emit events. > > The example below sets up a WebView, registers the `LoyaltyLionBridge` and registers a `sdkReady` handler to detect when the SDK is ready to receive [WebView JS API](/sdk/webviews/advanced/webview-js-api) calls. > > ```kotlin theme={null} > class MainActivity : AppCompatActivity() { > lateinit var webView: WebView > > override fun onCreate(savedInstanceState: Bundle?) { > super.onCreate(savedInstanceState) > > webView = WebView(this) > setContentView(webView) > > webView.settings.javaScriptEnabled = true > webView.addJavascriptInterface(LoyaltyLionBridge(), "LoyaltyLionBridge") > > webView.loadDataWithBaseURL(null, "...", "text/html", "utf-8", null) > } > > inner class LoyaltyLionBridge { > @JavascriptInterface > fun sdkReady() { > Log.d("WebView", "LoyaltyLion SDK ready") > } > } > } > ``` # WebView JS API reference Source: https://developers.loyaltylion.com/sdk/webviews/advanced/webview-js-api When running inside a WebView, the LoyaltyLion JS SDK exposes additional APIs the parent mobile app can use to trigger updates and pass information WebView APIs can be used by executing JavaScript inside the WebView and calling `loyaltylion.webview.methodName`, where `methodName` is one of the documented API methods below. Interacting with the JS API is typically not required for a basic WebView setup, but is often used to support [advanced features](/sdk/webviews/advanced/setup) Unless otherwise specified, you must wait for the LoyaltyLion SDK to report that it has finished loading before using WebView APIs. You can do this by listening to the [sdkReady event](/sdk/webviews/advanced/webview-js-events#sdkready). ## setShopifyCartState `loyaltylion.webview.setShopifyCartState` This can be used to inform the LoyaltyLion SDK about the current Shopify cart state, which is needed for some functionality. For example, free product rewards often require a cart to contain a paid item before they can be redeemed, so the SDK needs to know about the cart first. `setShopifyCartState` expects a single argument, which should be a JSON object representing the cart state. All fields can be retrieved from the Storefront API [Cart object](https://shopify.dev/docs/api/storefront/latest/objects/Cart). ### Properties **id** `string` *required* The ID of the cart **totalCost** `string` *required* The total amount for the customer to pay, as a decimal money amount. From `cost.totalAmount.amount` on the Storefront API [Cart object](https://shopify.dev/docs/api/storefront/latest/objects/Cart). **lines** `object[]` *required* An array of objects describing the current lines on the cart **properties** **id** `string` *required* The ID of the cart line Example: `gid://shopify/CartLine/19fdf4cb-5495-4c2f-83d0-40c6a4898f5e` **quantity** `number` *required* Quantity of the cart line **totalCost** `string` *required* The total cost of the line, as a decimal money amount. From `cost.totalAmount.amount` on the Storefront API [BaseCartLine object](https://shopify.dev/docs/api/storefront/latest/interfaces/BaseCartLine) **merchandiseId** `string` *required* The product variant ID, from `merchandise.id` on the Storefront API [BaseCartLine object](https://shopify.dev/docs/api/storefront/latest/interfaces/BaseCartLine) Example: `gid://shopify/ProductVariant/1001` **productId** `string` *required* The product ID, from `merchandise.product.id` on the Storefront API [BaseCartLine object](https://shopify.dev/docs/api/storefront/latest/interfaces/BaseCartLine) Example: `gid://shopify/Product/1001` **attributes** `object` *required* The attributes for the cart line as a key-value object Example: ```json theme={null} { "attributeOne": "value", "attributeTwo": "value" } ``` ### Example ```javascript theme={null} loyaltylion.webview.setShopifyCartState({ id: 'gid://shopify/Cart/Z2NwLWV1cm9', totalCost: '79.99', lines: [ { id: 'gid://shopify/CartLine/19fdf4cb-5495-4c2f-83d0-40c6a4898f5e', quantity: 1, totalCost: '79.99', merchandiseId: 'gid://shopify/ProductVariant/600', productId: 'gid://shopify/Product/100', attributes: {}, }, { id: 'gid://shopify/CartLine/90ce960d-237e-4a02-bc28-8e4c80c112c4', quantity: 1, totalCost: '0.00', merchandiseId: 'gid://shopify/ProductVariant/500', productId: 'gid://shopify/Product/200', attributes: { __lion_sfp_id: '40c6a4898', }, }, ], }) ``` # WebView JS events reference Source: https://developers.loyaltylion.com/sdk/webviews/advanced/webview-js-events The LoyaltyLion SDK can emit various events, which can be subscribed to when you initialize the WebView. Listening to these events is typically not required for a basic WebView setup, but is often used to support [advanced features](/sdk/webviews/advanced/setup) > [!WARNING] > > You should only subscribe to events that you intend to handle. The LoyaltyLion > SDK checks which handlers have been registered and uses that to conditionally > enable functionality. > > For example, free product rewards will only be > redeemable if the appropriate events (`addCartLine`, etc) have been registered. ## Listening to events The events themselves are the same for both iOS and Android, so the only difference is how to subscribe to them. > [tab] iOS WKWebView > > On iOS, we emit events using the [WKScriptMessageHandler](https://developer.apple.com/documentation/webkit/wkscriptmessagehandler) interface. Use your `WKUserContentController` > to subscribe to the events you're interested in. > > ```swift theme={null} > class ViewController: UIViewController, WKScriptMessageHandler { > override func viewDidLoad() { > let contentController = WKUserContentController() > > contentController.add(self, name: "sdkReady") > } > > func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { > if message.name == "sdkReady" { > print("LoyaltyLion SDK is ready") > } > } > } > ``` ## `sdkReady` This event is emitted once the LoyaltyLion SDK has finished loading. At this point, the [WebView JS API](/sdk/webviews/advanced/webview-js-api) can be used to interact with the LoyaltyLion SDK running within the WebView. ### Example > [tab] iOS WKWebKit > > ```swift theme={null} > if message.name == "sdkReady" { > print("LoyaltyLion SDK is ready") > } > ``` ## `addCartLine` This event is emitted when a shopper has redeemed a free product reward, and we need a new line to be added to the cart for the product. The product data will contain a hidden attribute that our Shopify Function will pick up and automatically apply a discount to the item. The message body will be an object containing the merchandise ID, quantity and attributes that should be added to the cart via a [cartLinesAdd](https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesAdd) mutation. ### Message body **merchandiseId** `string` *required* The ProductVariant ID to add to the cart. Example: `gid://shopify/ProductVariant/1001` **productId** `string` *required* The Product ID to add to the cart. Example: `gid://shopify/Product/100` **quantity** `number` *required* The quantity of the item to add. **attributes** `object` *required* An object containing attributes that should be included with the merchandise line. Example: ```json theme={null} { "__lion_sfp_id": "19fdf4cb" } ``` ### Example > [tab] iOS WKWebKit > > The message body will be automatically parsed, so they can > be typecast to retrieve the values. > > ```swift theme={null} > if message.name == "addCartLine" { > if let body = message.body as? [String: Any], > let merchandiseId = body["merchandiseId"] as? String, > let quantity = body["quantity"] as? Int, > let attributes = body["attributes"] as? [String: Any] { > > print("Adding cart line: \(merchandiseId), quantity: \(quantity)") > > // add to Shopify cart > } else { > print("Invalid message:", message.body) > } > } > ``` ## `removeCartLine` This event is emitted when we need to remove a line from the cart. This typically occurs when the shopper cancels a previously-redeemed free product reward. The message body will be an object containing the `lineId` that should be removed from the cart via a [cartLinesRemove](https://shopify.dev/docs/api/storefront/latest/mutations/cartLinesRemove) mutation. ### Message body **lineId** `string` *required* The CartLine ID to remove from the cart. Example: `gid://shopify/CartLine/19fdf4cb-5495-4c2f-83d0-40c6a4898f5e` **merchandiseId** `string` *required* The ProductVariant ID of the CartLine that is being removed from the cart. Example: `gid://shopify/ProductVariant/1001` **productId** `string` *required* The Product ID of the CartLine that is being removed from the cart. Example: `gid://shopify/Product/100` **quantity** `number` *required* The quantity of the CartLine that is being removed from the cart. **attributes** `object` *required* An object containing the attributes of the CartLine that is being removed from the cart. ### Example > [tab] iOS WKWebKit > > The message body will be automatically parsed, so they can > be typecast to retrieve the values. > > ```swift theme={null} > if message.name == "removeCartLine" { > if let body = message.body as? [String: Any], > let lineId = body["lineId"] as? String { > > print("Removing cart line: \(lineId)") > > // remove from Shopify cart > } else { > print("Invalid message:", message.body) > } > } > ``` # Use a dedicated Shopify page Source: https://developers.loyaltylion.com/sdk/webviews/dedicated-shopify-page By default, we render a completely standalone page when rendering as a WebView. This is the simplest way to get started, but can only be customized with the Theme Editor, and does not support additional custom CSS, fonts or JavaScript. Instead, you can create a dedicated Shopify layout and page and we'll use this when rendering as a WebView. This offers several advantages since you can customize the page directly within your Shopify Theme, such as adding custom CSS that will only apply in the mobile app, and any additional JavaScript or analytics you may need, such as auto-translation. # Configure your Shopify theme **1. Create a new minimal layout** In your Shopify Theme, create a new layout (in the `layout/` directory) called `theme.loyaltylion-webview.liquid`. This will be the layout used when rendering as a mobile WebView, so you should keep it as small and simple as possible. * **do not include a `` section in your layout**. This prevents app blocks from being included in the resulting webview, which is important to ensure a fast and uncluttered experience when rendering on a mobile device - otherwise the mobile webview may show cookie warnings, popups, or other UI elements like offers etc, which are not appropriate for a mobile webview * include only the CSS that is needed for the LoyaltyLion page, i.e. your main CSS file that includes fonts, variables, ete. These can be added to the `` section and will still work fine in the webview * only include JavaScript that is needed for the LoyaltyLion page (e.g. auto translation apps), or for analytics. Shopify analytics are included automatically with the `{{ content_for_header }}` tag Since every theme is different, we can't provide a one-size-fits-all example that is guaranteed to work for all themes, but the examples below should work for some common Shopify themes, and provide a starting point for other themes. > [accordion] Generic example > > This example isn't linked to any specific Shopify theme, but can be used as a > basic example for other or custom themes. > > ```html theme={null} > > > > {{ 'theme.css' | asset_url | stylesheet_tag }} > > {{ content_for_header }} > {{ content_for_layout }} > > > ``` > [accordion] Debut > > This example can be used for the older "Debut" theme. > > ```html theme={null} > > > > {{ 'theme.css' | asset_url | stylesheet_tag }} > > {{ content_for_header }} > {{ content_for_layout }} > > {% include 'css-variables' %} > > > > ``` > [accordion] Dawn > > This example can be used for the "Dawn" theme, and may be applicable for other > themes derived from it. > > ```html theme={null} > > > > {{ 'base.css' | asset_url | stylesheet_tag }} > > {{ content_for_header }} > {{ content_for_layout }} > > {% style %} > {{ settings.type_body_font | font_face: font_display: 'swap' }} > {{ body_font_bold | font_face: font_display: 'swap' }} > {{ body_font_italic | font_face: font_display: 'swap' }} > {{ body_font_bold_italic | font_face: font_display: 'swap' }} > {{ settings.type_header_font | font_face: font_display: 'swap' }} > > {% for scheme in settings.color_schemes -%} > {% assign scheme_classes = scheme_classes | append: ', .color-' | append: scheme.id %} > {% if forloop.index == 1 -%} > :root, > {%- endif %} > .color-{{ scheme.id }} { > --color-background: {{ scheme.settings.background.red }},{{ scheme.settings.background.green }},{{ scheme.settings.background.blue }}; > {% if scheme.settings.background_gradient != empty %} > --gradient-background: {{ scheme.settings.background_gradient }}; > {% else %} > --gradient-background: {{ scheme.settings.background }}; > {% endif %} > > {% liquid > assign background_color = scheme.settings.background > assign background_color_brightness = background_color | color_brightness > if background_color_brightness <= 26 > assign background_color_contrast = background_color | color_lighten: 50 > elsif background_color_brightness <= 65 > assign background_color_contrast = background_color | color_lighten: 5 > else > assign background_color_contrast = background_color | color_darken: 25 > endif > %} > > --color-foreground: {{ scheme.settings.text.red }},{{ scheme.settings.text.green }},{{ scheme.settings.text.blue }}; > --color-background-contrast: {{ background_color_contrast.red }},{{ background_color_contrast.green }},{{ background_color_contrast.blue }}; > --color-shadow: {{ scheme.settings.shadow.red }},{{ scheme.settings.shadow.green }},{{ scheme.settings.shadow.blue }}; > --color-button: {{ scheme.settings.button.red }},{{ scheme.settings.button.green }},{{ scheme.settings.button.blue }}; > --color-button-text: {{ scheme.settings.button_label.red }},{{ scheme.settings.button_label.green }},{{ scheme.settings.button_label.blue }}; > --color-secondary-button: {{ scheme.settings.background.red }},{{ scheme.settings.background.green }},{{ scheme.settings.background.blue }}; > --color-secondary-button-text: {{ scheme.settings.secondary_button_label.red }},{{ scheme.settings.secondary_button_label.green }},{{ scheme.settings.secondary_button_label.blue }}; > --color-link: {{ scheme.settings.secondary_button_label.red }},{{ scheme.settings.secondary_button_label.green }},{{ scheme.settings.secondary_button_label.blue }}; > --color-badge-foreground: {{ scheme.settings.text.red }},{{ scheme.settings.text.green }},{{ scheme.settings.text.blue }}; > --color-badge-background: {{ scheme.settings.background.red }},{{ scheme.settings.background.green }},{{ scheme.settings.background.blue }}; > --color-badge-border: {{ scheme.settings.text.red }},{{ scheme.settings.text.green }},{{ scheme.settings.text.blue }}; > --payment-terms-background-color: rgb({{ scheme.settings.background.rgb }}); > } > {% endfor %} > > {{ scheme_classes | prepend: 'body' }} { > color: rgba(var(--color-foreground), 0.75); > background-color: rgb(var(--color-background)); > } > > :root { > --font-body-family: {{ settings.type_body_font.family }}, {{ settings.type_body_font.fallback_families }}; > --font-body-style: {{ settings.type_body_font.style }}; > --font-body-weight: {{ settings.type_body_font.weight }}; > --font-body-weight-bold: {{ settings.type_body_font.weight | plus: 300 | at_most: 1000 }}; > > --font-heading-family: {{ settings.type_header_font.family }}, {{ settings.type_header_font.fallback_families }}; > --font-heading-style: {{ settings.type_header_font.style }}; > --font-heading-weight: {{ settings.type_header_font.weight }}; > > --font-body-scale: {{ settings.body_scale | divided_by: 100.0 }}; > --font-heading-scale: {{ settings.heading_scale | times: 1.0 | divided_by: settings.body_scale }}; > > --media-padding: {{ settings.media_padding }}px; > --media-border-opacity: {{ settings.media_border_opacity | divided_by: 100.0 }}; > --media-border-width: {{ settings.media_border_thickness }}px; > --media-radius: {{ settings.media_radius }}px; > --media-shadow-opacity: {{ settings.media_shadow_opacity | divided_by: 100.0 }}; > --media-shadow-horizontal-offset: {{ settings.media_shadow_horizontal_offset }}px; > --media-shadow-vertical-offset: {{ settings.media_shadow_vertical_offset }}px; > --media-shadow-blur-radius: {{ settings.media_shadow_blur }}px; > --media-shadow-visible: {% if settings.media_shadow_opacity > 0 %}1{% else %}0{% endif %}; > > --page-width: {{ settings.page_width | divided_by: 10 }}rem; > --page-width-margin: {% if settings.page_width == '1600' %}2{% else %}0{% endif %}rem; > > --product-card-image-padding: {{ settings.card_image_padding | divided_by: 10.0 }}rem; > --product-card-corner-radius: {{ settings.card_corner_radius | divided_by: 10.0 }}rem; > --product-card-text-alignment: {{ settings.card_text_alignment }}; > --product-card-border-width: {{ settings.card_border_thickness | divided_by: 10.0 }}rem; > --product-card-border-opacity: {{ settings.card_border_opacity | divided_by: 100.0 }}; > --product-card-shadow-opacity: {{ settings.card_shadow_opacity | divided_by: 100.0 }}; > --product-card-shadow-visible: {% if settings.card_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --product-card-shadow-horizontal-offset: {{ settings.card_shadow_horizontal_offset | divided_by: 10.0 }}rem; > --product-card-shadow-vertical-offset: {{ settings.card_shadow_vertical_offset | divided_by: 10.0 }}rem; > --product-card-shadow-blur-radius: {{ settings.card_shadow_blur | divided_by: 10.0 }}rem; > > --collection-card-image-padding: {{ settings.collection_card_image_padding | divided_by: 10.0 }}rem; > --collection-card-corner-radius: {{ settings.collection_card_corner_radius | divided_by: 10.0 }}rem; > --collection-card-text-alignment: {{ settings.collection_card_text_alignment }}; > --collection-card-border-width: {{ settings.collection_card_border_thickness | divided_by: 10.0 }}rem; > --collection-card-border-opacity: {{ settings.collection_card_border_opacity | divided_by: 100.0 }}; > --collection-card-shadow-opacity: {{ settings.collection_card_shadow_opacity | divided_by: 100.0 }}; > --collection-card-shadow-visible: {% if settings.collection_card_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --collection-card-shadow-horizontal-offset: {{ settings.collection_card_shadow_horizontal_offset | divided_by: 10.0 }}rem; > --collection-card-shadow-vertical-offset: {{ settings.collection_card_shadow_vertical_offset | divided_by: 10.0 }}rem; > --collection-card-shadow-blur-radius: {{ settings.collection_card_shadow_blur | divided_by: 10.0 }}rem; > > --blog-card-image-padding: {{ settings.blog_card_image_padding | divided_by: 10.0 }}rem; > --blog-card-corner-radius: {{ settings.blog_card_corner_radius | divided_by: 10.0 }}rem; > --blog-card-text-alignment: {{ settings.blog_card_text_alignment }}; > --blog-card-border-width: {{ settings.blog_card_border_thickness | divided_by: 10.0 }}rem; > --blog-card-border-opacity: {{ settings.blog_card_border_opacity | divided_by: 100.0 }}; > --blog-card-shadow-opacity: {{ settings.blog_card_shadow_opacity | divided_by: 100.0 }}; > --blog-card-shadow-visible: {% if settings.blog_card_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --blog-card-shadow-horizontal-offset: {{ settings.blog_card_shadow_horizontal_offset | divided_by: 10.0 }}rem; > --blog-card-shadow-vertical-offset: {{ settings.blog_card_shadow_vertical_offset | divided_by: 10.0 }}rem; > --blog-card-shadow-blur-radius: {{ settings.blog_card_shadow_blur | divided_by: 10.0 }}rem; > > --badge-corner-radius: {{ settings.badge_corner_radius | divided_by: 10.0 }}rem; > > --popup-border-width: {{ settings.popup_border_thickness }}px; > --popup-border-opacity: {{ settings.popup_border_opacity | divided_by: 100.0 }}; > --popup-corner-radius: {{ settings.popup_corner_radius }}px; > --popup-shadow-opacity: {{ settings.popup_shadow_opacity | divided_by: 100.0 }}; > --popup-shadow-horizontal-offset: {{ settings.popup_shadow_horizontal_offset }}px; > --popup-shadow-vertical-offset: {{ settings.popup_shadow_vertical_offset }}px; > --popup-shadow-blur-radius: {{ settings.popup_shadow_blur }}px; > > --drawer-border-width: {{ settings.drawer_border_thickness }}px; > --drawer-border-opacity: {{ settings.drawer_border_opacity | divided_by: 100.0 }}; > --drawer-shadow-opacity: {{ settings.drawer_shadow_opacity | divided_by: 100.0 }}; > --drawer-shadow-horizontal-offset: {{ settings.drawer_shadow_horizontal_offset }}px; > --drawer-shadow-vertical-offset: {{ settings.drawer_shadow_vertical_offset }}px; > --drawer-shadow-blur-radius: {{ settings.drawer_shadow_blur }}px; > > --spacing-sections-desktop: {{ settings.spacing_sections }}px; > --spacing-sections-mobile: {% if settings.spacing_sections < 24 %}{{ settings.spacing_sections }}{% else %}{{ settings.spacing_sections | times: 0.7 | round | at_least: 20 }}{% endif %}px; > > --grid-desktop-vertical-spacing: {{ settings.spacing_grid_vertical }}px; > --grid-desktop-horizontal-spacing: {{ settings.spacing_grid_horizontal }}px; > --grid-mobile-vertical-spacing: {{ settings.spacing_grid_vertical | divided_by: 2 }}px; > --grid-mobile-horizontal-spacing: {{ settings.spacing_grid_horizontal | divided_by: 2 }}px; > > --text-boxes-border-opacity: {{ settings.text_boxes_border_opacity | divided_by: 100.0 }}; > --text-boxes-border-width: {{ settings.text_boxes_border_thickness }}px; > --text-boxes-radius: {{ settings.text_boxes_radius }}px; > --text-boxes-shadow-opacity: {{ settings.text_boxes_shadow_opacity | divided_by: 100.0 }}; > --text-boxes-shadow-visible: {% if settings.text_boxes_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --text-boxes-shadow-horizontal-offset: {{ settings.text_boxes_shadow_horizontal_offset }}px; > --text-boxes-shadow-vertical-offset: {{ settings.text_boxes_shadow_vertical_offset }}px; > --text-boxes-shadow-blur-radius: {{ settings.text_boxes_shadow_blur }}px; > > --buttons-radius: {{ settings.buttons_radius }}px; > --buttons-radius-outset: {% if settings.buttons_radius > 0 %}{{ settings.buttons_radius | plus: settings.buttons_border_thickness }}{% else %}0{% endif %}px; > --buttons-border-width: {% if settings.buttons_border_opacity > 0 %}{{ settings.buttons_border_thickness }}{% else %}0{% endif %}px; > --buttons-border-opacity: {{ settings.buttons_border_opacity | divided_by: 100.0 }}; > --buttons-shadow-opacity: {{ settings.buttons_shadow_opacity | divided_by: 100.0 }}; > --buttons-shadow-visible: {% if settings.buttons_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --buttons-shadow-horizontal-offset: {{ settings.buttons_shadow_horizontal_offset }}px; > --buttons-shadow-vertical-offset: {{ settings.buttons_shadow_vertical_offset }}px; > --buttons-shadow-blur-radius: {{ settings.buttons_shadow_blur }}px; > --buttons-border-offset: {% if settings.buttons_radius > 0 or settings.buttons_shadow_opacity > 0 %}0.3{% else %}0{% endif %}px; > > --inputs-radius: {{ settings.inputs_radius }}px; > --inputs-border-width: {{ settings.inputs_border_thickness }}px; > --inputs-border-opacity: {{ settings.inputs_border_opacity | divided_by: 100.0 }}; > --inputs-shadow-opacity: {{ settings.inputs_shadow_opacity | divided_by: 100.0 }}; > --inputs-shadow-horizontal-offset: {{ settings.inputs_shadow_horizontal_offset }}px; > --inputs-margin-offset: {% if settings.inputs_shadow_vertical_offset != 0 and settings.inputs_shadow_opacity > 0 %}{{ settings.inputs_shadow_vertical_offset | abs }}{% else %}0{% endif %}px; > --inputs-shadow-vertical-offset: {{ settings.inputs_shadow_vertical_offset }}px; > --inputs-shadow-blur-radius: {{ settings.inputs_shadow_blur }}px; > --inputs-radius-outset: {% if settings.inputs_radius > 0 %}{{ settings.inputs_radius | plus: settings.inputs_border_thickness }}{% else %}0{% endif %}px; > > --variant-pills-radius: {{ settings.variant_pills_radius }}px; > --variant-pills-border-width: {{ settings.variant_pills_border_thickness }}px; > --variant-pills-border-opacity: {{ settings.variant_pills_border_opacity | divided_by: 100.0 }}; > --variant-pills-shadow-opacity: {{ settings.variant_pills_shadow_opacity | divided_by: 100.0 }}; > --variant-pills-shadow-horizontal-offset: {{ settings.variant_pills_shadow_horizontal_offset }}px; > --variant-pills-shadow-vertical-offset: {{ settings.variant_pills_shadow_vertical_offset }}px; > --variant-pills-shadow-blur-radius: {{ settings.variant_pills_shadow_blur }}px; > } > > *, > *::before, > *::after { > box-sizing: inherit; > } > > html { > box-sizing: border-box; > font-size: calc(var(--font-body-scale) * 62.5%); > height: 100%; > } > > body { > margin: 0; > font-size: 1.5rem; > letter-spacing: 0.06rem; > line-height: calc(1 + 0.8 / var(--font-body-scale)); > font-family: var(--font-body-family); > font-style: var(--font-body-style); > font-weight: var(--font-body-weight); > } > > @media screen and (min-width: 750px) { > body { > font-size: 1.6rem; > } > } > {% endstyle %} > > > ``` > [accordion] Rise > > This example can be used for the "Rise" theme. > > ```html theme={null} > > > > {{ 'base.css' | asset_url | stylesheet_tag }} > > {{ content_for_header }} > {{ content_for_layout }} > > {% style %} > {{ settings.type_body_font | font_face: font_display: 'swap' }} > {{ body_font_bold | font_face: font_display: 'swap' }} > {{ body_font_italic | font_face: font_display: 'swap' }} > {{ body_font_bold_italic | font_face: font_display: 'swap' }} > {{ settings.type_header_font | font_face: font_display: 'swap' }} > > {% for scheme in settings.color_schemes -%} > {% assign scheme_classes = scheme_classes | append: ', .color-' | append: scheme.id %} > {% if forloop.index == 1 -%} > :root, > {%- endif %} > .color-{{ scheme.id }} { > --color-background: {{ scheme.settings.background.red }},{{ scheme.settings.background.green }},{{ scheme.settings.background.blue }}; > {% if scheme.settings.background_gradient != empty %} > --gradient-background: {{ scheme.settings.background_gradient }}; > {% else %} > --gradient-background: {{ scheme.settings.background }}; > {% endif %} > > {% liquid > assign background_color = scheme.settings.background > assign background_color_brightness = background_color | color_brightness > if background_color_brightness <= 26 > assign background_color_contrast = background_color | color_lighten: 50 > elsif background_color_brightness <= 65 > assign background_color_contrast = background_color | color_lighten: 5 > else > assign background_color_contrast = background_color | color_darken: 25 > endif > %} > > --color-foreground: {{ scheme.settings.text.red }},{{ scheme.settings.text.green }},{{ scheme.settings.text.blue }}; > --color-background-contrast: {{ background_color_contrast.red }},{{ background_color_contrast.green }},{{ background_color_contrast.blue }}; > --color-shadow: {{ scheme.settings.shadow.red }},{{ scheme.settings.shadow.green }},{{ scheme.settings.shadow.blue }}; > --color-button: {{ scheme.settings.button.red }},{{ scheme.settings.button.green }},{{ scheme.settings.button.blue }}; > --color-button-text: {{ scheme.settings.button_label.red }},{{ scheme.settings.button_label.green }},{{ scheme.settings.button_label.blue }}; > --color-secondary-button: {{ scheme.settings.background.red }},{{ scheme.settings.background.green }},{{ scheme.settings.background.blue }}; > --color-secondary-button-text: {{ scheme.settings.secondary_button_label.red }},{{ scheme.settings.secondary_button_label.green }},{{ scheme.settings.secondary_button_label.blue }}; > --color-link: {{ scheme.settings.secondary_button_label.red }},{{ scheme.settings.secondary_button_label.green }},{{ scheme.settings.secondary_button_label.blue }}; > --color-badge-foreground: {{ scheme.settings.text.red }},{{ scheme.settings.text.green }},{{ scheme.settings.text.blue }}; > --color-badge-background: {{ scheme.settings.background.red }},{{ scheme.settings.background.green }},{{ scheme.settings.background.blue }}; > --color-badge-border: {{ scheme.settings.text.red }},{{ scheme.settings.text.green }},{{ scheme.settings.text.blue }}; > --payment-terms-background-color: rgb({{ scheme.settings.background.rgb }}); > } > {% endfor %} > > {{ scheme_classes | prepend: 'body' }} { > color: rgba(var(--color-foreground), 0.75); > background-color: rgb(var(--color-background)); > } > > :root { > --font-body-family: {{ settings.type_body_font.family }}, {{ settings.type_body_font.fallback_families }}; > --font-body-style: {{ settings.type_body_font.style }}; > --font-body-weight: {{ settings.type_body_font.weight }}; > --font-body-weight-bold: {{ settings.type_body_font.weight | plus: 300 | at_most: 1000 }}; > > --font-heading-family: {{ settings.type_header_font.family }}, {{ settings.type_header_font.fallback_families }}; > --font-heading-style: {{ settings.type_header_font.style }}; > --font-heading-weight: {{ settings.type_header_font.weight }}; > > --font-body-scale: {{ settings.body_scale | divided_by: 100.0 }}; > --font-heading-scale: {{ settings.heading_scale | times: 1.0 | divided_by: settings.body_scale }}; > > --media-padding: {{ settings.media_padding }}px; > --media-border-opacity: {{ settings.media_border_opacity | divided_by: 100.0 }}; > --media-border-width: {{ settings.media_border_thickness }}px; > --media-radius: {{ settings.media_radius }}px; > --media-shadow-opacity: {{ settings.media_shadow_opacity | divided_by: 100.0 }}; > --media-shadow-horizontal-offset: {{ settings.media_shadow_horizontal_offset }}px; > --media-shadow-vertical-offset: {{ settings.media_shadow_vertical_offset }}px; > --media-shadow-blur-radius: {{ settings.media_shadow_blur }}px; > --media-shadow-visible: {% if settings.media_shadow_opacity > 0 %}1{% else %}0{% endif %}; > > --page-width: {{ settings.page_width | divided_by: 10 }}rem; > --page-width-margin: {% if settings.page_width == '1600' %}2{% else %}0{% endif %}rem; > > --product-card-image-padding: {{ settings.card_image_padding | divided_by: 10.0 }}rem; > --product-card-corner-radius: {{ settings.card_corner_radius | divided_by: 10.0 }}rem; > --product-card-text-alignment: {{ settings.card_text_alignment }}; > --product-card-border-width: {{ settings.card_border_thickness | divided_by: 10.0 }}rem; > --product-card-border-opacity: {{ settings.card_border_opacity | divided_by: 100.0 }}; > --product-card-shadow-opacity: {{ settings.card_shadow_opacity | divided_by: 100.0 }}; > --product-card-shadow-visible: {% if settings.card_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --product-card-shadow-horizontal-offset: {{ settings.card_shadow_horizontal_offset | divided_by: 10.0 }}rem; > --product-card-shadow-vertical-offset: {{ settings.card_shadow_vertical_offset | divided_by: 10.0 }}rem; > --product-card-shadow-blur-radius: {{ settings.card_shadow_blur | divided_by: 10.0 }}rem; > > --collection-card-image-padding: {{ settings.collection_card_image_padding | divided_by: 10.0 }}rem; > --collection-card-corner-radius: {{ settings.collection_card_corner_radius | divided_by: 10.0 }}rem; > --collection-card-text-alignment: {{ settings.collection_card_text_alignment }}; > --collection-card-border-width: {{ settings.collection_card_border_thickness | divided_by: 10.0 }}rem; > --collection-card-border-opacity: {{ settings.collection_card_border_opacity | divided_by: 100.0 }}; > --collection-card-shadow-opacity: {{ settings.collection_card_shadow_opacity | divided_by: 100.0 }}; > --collection-card-shadow-visible: {% if settings.collection_card_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --collection-card-shadow-horizontal-offset: {{ settings.collection_card_shadow_horizontal_offset | divided_by: 10.0 }}rem; > --collection-card-shadow-vertical-offset: {{ settings.collection_card_shadow_vertical_offset | divided_by: 10.0 }}rem; > --collection-card-shadow-blur-radius: {{ settings.collection_card_shadow_blur | divided_by: 10.0 }}rem; > > --blog-card-image-padding: {{ settings.blog_card_image_padding | divided_by: 10.0 }}rem; > --blog-card-corner-radius: {{ settings.blog_card_corner_radius | divided_by: 10.0 }}rem; > --blog-card-text-alignment: {{ settings.blog_card_text_alignment }}; > --blog-card-border-width: {{ settings.blog_card_border_thickness | divided_by: 10.0 }}rem; > --blog-card-border-opacity: {{ settings.blog_card_border_opacity | divided_by: 100.0 }}; > --blog-card-shadow-opacity: {{ settings.blog_card_shadow_opacity | divided_by: 100.0 }}; > --blog-card-shadow-visible: {% if settings.blog_card_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --blog-card-shadow-horizontal-offset: {{ settings.blog_card_shadow_horizontal_offset | divided_by: 10.0 }}rem; > --blog-card-shadow-vertical-offset: {{ settings.blog_card_shadow_vertical_offset | divided_by: 10.0 }}rem; > --blog-card-shadow-blur-radius: {{ settings.blog_card_shadow_blur | divided_by: 10.0 }}rem; > > --badge-corner-radius: {{ settings.badge_corner_radius | divided_by: 10.0 }}rem; > > --popup-border-width: {{ settings.popup_border_thickness }}px; > --popup-border-opacity: {{ settings.popup_border_opacity | divided_by: 100.0 }}; > --popup-corner-radius: {{ settings.popup_corner_radius }}px; > --popup-shadow-opacity: {{ settings.popup_shadow_opacity | divided_by: 100.0 }}; > --popup-shadow-horizontal-offset: {{ settings.popup_shadow_horizontal_offset }}px; > --popup-shadow-vertical-offset: {{ settings.popup_shadow_vertical_offset }}px; > --popup-shadow-blur-radius: {{ settings.popup_shadow_blur }}px; > > --drawer-border-width: {{ settings.drawer_border_thickness }}px; > --drawer-border-opacity: {{ settings.drawer_border_opacity | divided_by: 100.0 }}; > --drawer-shadow-opacity: {{ settings.drawer_shadow_opacity | divided_by: 100.0 }}; > --drawer-shadow-horizontal-offset: {{ settings.drawer_shadow_horizontal_offset }}px; > --drawer-shadow-vertical-offset: {{ settings.drawer_shadow_vertical_offset }}px; > --drawer-shadow-blur-radius: {{ settings.drawer_shadow_blur }}px; > > --spacing-sections-desktop: {{ settings.spacing_sections }}px; > --spacing-sections-mobile: {% if settings.spacing_sections < 24 %}{{ settings.spacing_sections }}{% else %}{{ settings.spacing_sections | times: 0.7 | round | at_least: 20 }}{% endif %}px; > > --grid-desktop-vertical-spacing: {{ settings.spacing_grid_vertical }}px; > --grid-desktop-horizontal-spacing: {{ settings.spacing_grid_horizontal }}px; > --grid-mobile-vertical-spacing: {{ settings.spacing_grid_vertical | divided_by: 2 }}px; > --grid-mobile-horizontal-spacing: {{ settings.spacing_grid_horizontal | divided_by: 2 }}px; > > --text-boxes-border-opacity: {{ settings.text_boxes_border_opacity | divided_by: 100.0 }}; > --text-boxes-border-width: {{ settings.text_boxes_border_thickness }}px; > --text-boxes-radius: {{ settings.text_boxes_radius }}px; > --text-boxes-shadow-opacity: {{ settings.text_boxes_shadow_opacity | divided_by: 100.0 }}; > --text-boxes-shadow-visible: {% if settings.text_boxes_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --text-boxes-shadow-horizontal-offset: {{ settings.text_boxes_shadow_horizontal_offset }}px; > --text-boxes-shadow-vertical-offset: {{ settings.text_boxes_shadow_vertical_offset }}px; > --text-boxes-shadow-blur-radius: {{ settings.text_boxes_shadow_blur }}px; > > --buttons-radius: {{ settings.buttons_radius }}px; > --buttons-radius-outset: {% if settings.buttons_radius > 0 %}{{ settings.buttons_radius | plus: settings.buttons_border_thickness }}{% else %}0{% endif %}px; > --buttons-border-width: {% if settings.buttons_border_opacity > 0 %}{{ settings.buttons_border_thickness }}{% else %}0{% endif %}px; > --buttons-border-opacity: {{ settings.buttons_border_opacity | divided_by: 100.0 }}; > --buttons-shadow-opacity: {{ settings.buttons_shadow_opacity | divided_by: 100.0 }}; > --buttons-shadow-visible: {% if settings.buttons_shadow_opacity > 0 %}1{% else %}0{% endif %}; > --buttons-shadow-horizontal-offset: {{ settings.buttons_shadow_horizontal_offset }}px; > --buttons-shadow-vertical-offset: {{ settings.buttons_shadow_vertical_offset }}px; > --buttons-shadow-blur-radius: {{ settings.buttons_shadow_blur }}px; > --buttons-border-offset: {% if settings.buttons_radius > 0 or settings.buttons_shadow_opacity > 0 %}0.3{% else %}0{% endif %}px; > > --inputs-radius: {{ settings.inputs_radius }}px; > --inputs-border-width: {{ settings.inputs_border_thickness }}px; > --inputs-border-opacity: {{ settings.inputs_border_opacity | divided_by: 100.0 }}; > --inputs-shadow-opacity: {{ settings.inputs_shadow_opacity | divided_by: 100.0 }}; > --inputs-shadow-horizontal-offset: {{ settings.inputs_shadow_horizontal_offset }}px; > --inputs-margin-offset: {% if settings.inputs_shadow_vertical_offset != 0 and settings.inputs_shadow_opacity > 0 %}{{ settings.inputs_shadow_vertical_offset | abs }}{% else %}0{% endif %}px; > --inputs-shadow-vertical-offset: {{ settings.inputs_shadow_vertical_offset }}px; > --inputs-shadow-blur-radius: {{ settings.inputs_shadow_blur }}px; > --inputs-radius-outset: {% if settings.inputs_radius > 0 %}{{ settings.inputs_radius | plus: settings.inputs_border_thickness }}{% else %}0{% endif %}px; > > --variant-pills-radius: {{ settings.variant_pills_radius }}px; > --variant-pills-border-width: {{ settings.variant_pills_border_thickness }}px; > --variant-pills-border-opacity: {{ settings.variant_pills_border_opacity | divided_by: 100.0 }}; > --variant-pills-shadow-opacity: {{ settings.variant_pills_shadow_opacity | divided_by: 100.0 }}; > --variant-pills-shadow-horizontal-offset: {{ settings.variant_pills_shadow_horizontal_offset }}px; > --variant-pills-shadow-vertical-offset: {{ settings.variant_pills_shadow_vertical_offset }}px; > --variant-pills-shadow-blur-radius: {{ settings.variant_pills_shadow_blur }}px; > } > > *, > *::before, > *::after { > box-sizing: inherit; > } > > html { > box-sizing: border-box; > font-size: calc(var(--font-body-scale) * 62.5%); > height: 100%; > } > > body { > display: grid; > grid-template-rows: auto auto 1fr auto; > grid-template-columns: 100%; > min-height: 100%; > margin: 0; > font-size: 1.5rem; > letter-spacing: 0.06rem; > line-height: calc(1 + 0.8 / var(--font-body-scale)); > font-family: var(--font-body-family); > font-style: var(--font-body-style); > font-weight: var(--font-body-weight); > } > > @media screen and (min-width: 750px) { > body { > font-size: 1.6rem; > } > } > {% endstyle %} > > > ``` **2. Create a new CSS file for custom styling** Create a new CSS file (in the `assets/` directory) called `loyaltylion-webview.css`, with the following content. You can leave this file blank for now; any CSS in this file will apply exclusively to the Loyalty Page when it's rendered as in your mobile app as a WebView. **3. Create a new section** In your Shopify Theme, create a new section (in the `sections/` directory) called `loyaltylion-webview.liquid`, with the following content: ```html theme={null} {{ 'loyaltylion-webview.css' | asset_url | stylesheet_tag }} {{ page.content }} {% schema %} { "name": "t:sections.loyaltylion-webview.name", "tag": "section", "class": "section", "settings": [] } {% endschema %} ``` **4. Create a new template** In your Shopify Theme, create a new template (in the `templates/` directory) called `page.loyaltylion-webview.json`, with the following content: ```json theme={null} { "layout": "theme.loyaltylion-webview", "sections": { "main": { "type": "loyaltylion-webview", "settings": {} } }, "order": [ "main" ] } ``` This simple template, when applied to a page, will render the page using the new layout and section we created in the previous steps. ## Set up a new Shopify page ### Create a new page Once your Shopify Theme has been configured, we need to create a new page and apply the new page template to it. This will be the actual page that will be rendered inside the WebView. ![Webview page](https://mintcdn.com/loyaltylion/mzpO03HW8a1K958n/images/sdk/shopify-create-webview-page.png?fit=max\&auto=format\&n=mzpO03HW8a1K958n\&q=85\&s=66aa9ade4fdf3d08b64dde1df35a79bd) * We recommend naming the page "Rewards (webview)" to distinguish it from any other loyalty pages * Configure the page to use the `loyaltylion-webview` template For the page content, switch to HTML mode and paste in the following: ```html theme={null}
``` ### Preview and customize the page Assuming LoyaltyLion is already installed and launched on your store, you can open this new page to preview how the Loyalty Page will look, and add any customizations you need to make using custom CSS added to the `loyaltylion-webview.css` Because the page will be rendered in a full-screen webview, we recommend that the page renders using 100% width, i.e. is not rendered inside a grid container and limited to a specific width. ### Share the page URL with us Once you're happy with how the page looks, share the page URL with your LoyaltyLion account manager or [our support team](mailto:support@loyaltylion.com) and we'll configure it as your WebView page. # Render in a WebView Source: https://developers.loyaltylion.com/sdk/webviews/render-in-webview You can render the [Loyalty Page](/sdk/embeddable-components/loyalty-page) component as a standalone page, suitable for use in a WebView (such as in a mobile app). This is simpler than embedding your storefront page and is optimized for mobile devices. ## How the page is rendered The Loyalty Page will be rendered using the same Theme Editor customisations as it does on your storefront, i.e. the order & visibility of sections, brand colors, etc. Any custom CSS delivered as part of your storefront theme will not be applied. Not all rules and rewards will be available: we'll only render those that are suitable for use inside a WebView. ## Create a WebView session You can use the [WebView Session API](/api-reference/v2/resources/sites/create-webview-session) to create a short-lived WebView session for a site. This session includes a URL that can be used as the source for a WebView to render a complete Loyalty Page. > [!WARNING] > > This is a *server-side* API and must be called from a secure server, using an > API key or OAuth token. You cannot call this API directly from a client-side > app. If a customer is logged in, you should include their ID and email when creating a session. The resulting WebView session URL will render for that customer, allowing them to view their points and redeem rewards. If you don't include a customer, the guest Loyalty Page will be rendered. The URL included in the WebView session will expire after a few minutes, so it should not be saved or reused. You should create a new session each time you need to render the WebView. ## Render the WebView in your app Once you've acquired a WebView URL, you can render it in an iOS or Android WebView, and register various message handlers to support more advanced functionality such as adding discount codes or free products to the cart, depending on the ecommerce platform. # Workflow hooks Source: https://developers.loyaltylion.com/sdk/workflow-hooks LoyaltyLion SDK provides the ability for you to hook into various workflows to further customize the user experience. A `hook` is a promise-returning callback function that you provide and that the LoyaltyLion SDK executes when certain hook-enabled events occur. Hooks enable you to 'hook into' certain frontend workflows, giving you an opportunity to make calls to other services, render your own UI, and influence the behavior of the LoyaltyLion SDK. For example, you may provide a `hook` for the `customers.rewards.claimed` hook event that calls a storefront API to automatically add a discount to the cart, or make a call to your own app to trigger fulfillment of a custom reward. Your `hook` should return a promise which resolves to an object which contains an `action` property. The `action` is a string that informs what the LoyaltyLion UI should do next. Each kind of `hook` has its own set of supported actions, depending on the underlying use case and workflow. ## Hooks registration Hooks are registered using the `loyaltylion.registerHook` method. This method accepts two arguments: * `hookName` - string, name of the hooked event to register * `callback` - the function to be called when the hooked event occurs > [!WARNING] > > You may only register **one** hook for each hook kind. Attempting to register > the same hook more than once throws an exception. Hooks should be registered once the LoyaltyLion SDK is `ready`, see below for an example. #### Example usage ```javascript theme={null} loyaltylion.on('ready', () => { loyaltylion.registerHook( 'customers.rewards.claimed', async ({ claimedReward }) => { // do something with the claimed reward here if (claimedReward.redeemable.code) { await myCustomCartPlatform.setDiscount(claimedReward.redeemable.code) myCustomModal.open('Your discount has been applied!') } return { action: 'hide_claim_modal' } }, ) }) ``` ## Hook requirements Your `hook` must return a response with a valid `action` within 5 seconds. If it returns an invalid payload or doesn't resolve in time, the LoyaltyLion SDK uses the default action and proceed as if no hook was registered. ## Supported hooks We currently support the following hooks: * [`customers.rewards.claimed`](#customer-reward-claimed) *** ## Customer reward claimed This hook is called after a customer has successfully used their points to claim a reward. It enables you to implement things like automatically applying a reward to a cart if your platform supports this capability. On a store without a Shopify cart, it is also called when a customer adds a free product they were granted, such as one from a challenge or a drop. #### Callback payload This hook is called with an object with a `claimedReward` property matching the schema of our [rewards API](/api-reference/v2/resources/customers/rewards/redeem-reward). ```javascript theme={null} { claimedReward: {...} // see claimed reward docs for detailed schema } ``` #### Supported return actions This action should be indicated by the return of your callback function, e.g. ```javascript theme={null} return { action: 'hide_claim_modal' } ``` This hook supports two actions: | Action string | UI result | | - | - | | `hide_claim_modal` | The LoyaltyLion SDK's claimed reward modal is closed | | `show_claim_modal` | The LoyaltyLion SDK shows its standard post claimed reward modal content | The `show_claim_modal` action is used as the default in case of invalid return value or timeout. # program_events/customer.approaching_points_expiration Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-approaching-points-expiration This webhook is triggered when customer's points are close to expiring. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. > [!NOTE] > > This webhook is triggered only when your point expiration feature is enabled ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **expire_points_at** `string` *required* `ISO 8601` timestamp of the customer's approaching point expiration **points_to_expire** `number | null` *required* The number of customer points that are approaching expiration **earned_on** `string | null` *required* `ISO 8601` timestamp of when the expiring points were acquired ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.approaching_points_expiration", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "id": "332d90cd-1ba1-4a7b-abd1-79e643b4b89f", "created_at": "2018-01-01T03:00:05.000Z", "kind": "customer.approaching_points_expiration", "unique_until": null, "properties": { "expire_points_at": "2024-01-01T03:00:05.000Z", "points_to_expire": 136, "earned_on": "2023-01-01T03:00:05.000Z", "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": "a4e", "referred_by": { "id": 3958, "merchant_id": "192838592" }, "loyalty_tier_membership": { "started_at": "2017-03-03 00:00:00Z", "expires_at": null, "manual": false, "loyalty_tier": { "id": 16, "name": "Silver", "position": 2, "default": false, "hidden": false, "lower_bound": "200.01", "upper_bound": "400.00" } }, "tier_eligibility": { "kind": "points", "valid_until": null, "tier_points": { "now": 250, "at_expiration": null }, "points_needed_for_renewal": null, "points_needed_for_upgrade": 150, "upgrade_tier": { "id": 17, "name": "Gold", "threshold": 400 }, "forecasted_tier": null }, "insights_segment": "Loyal", "referral_url": "https://prz.io/KzByQ2Fa", "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" } } } } ``` # program_events/customer.approaching_reward_expiration Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-approaching-reward-expiration This webhook is triggered when customer's reward is close to expiring. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. > [!NOTE] > > Available only to **Shopify** merchants > [!NOTE] > > This webhook is triggered only when your reward expiration feature is enabled ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **title** `string` *required* Title of the reward that is to expire **reward_type** `enum\` *required* The type of the expiring reward. One of: `voucher` or `gift_card` **source** `object` *required* The source informs how the reward was acquired. One of: `customer_redemption` or `rule_completion` or `tier_benefit` **expires_at** `string` *required* `ISO 8601` timestamp of the reward's approaching expiration **discount_type** `enum\` *required* The type of discount provided. One of: `flat` or `percentage` **discount_amount** `number | null` *required* The discount provided by the claimed reward as a decimal value, e.g. \$5 will be `5`. Only included if the reward type is `voucher` **voucher_code** `string | null` *required* The voucher (coupon) code linked to the claimed reward. Only included if the reward type is `voucher` ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.approaching_reward_expiration", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "id": "332d90cd-1ba1-4a7b-abd1-79e643b4b89f", "created_at": "2018-01-01T03:00:05.000Z", "kind": "customer.approaching_reward_expiration", "unique_until": null, "properties": { "title": "$5 voucher", "source": { "kind": "customer_redemption" }, "expires_at": "2014-01-01T03:00:05.000Z", "reward_type": "voucher", "voucher_code": "LL-PQ8V63", "discount_type": "flat", "discount_amount": 20, "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": "a4e", "referred_by": { "id": 3958, "merchant_id": "192838592" }, "loyalty_tier_membership": { "started_at": "2017-03-03 00:00:00Z", "expires_at": null, "manual": false, "loyalty_tier": { "id": 16, "name": "Silver", "position": 2, "default": false, "hidden": false, "lower_bound": "200.01", "upper_bound": "400.00" } }, "tier_eligibility": { "kind": "points", "valid_until": null, "tier_points": { "now": 250, "at_expiration": null }, "points_needed_for_renewal": null, "points_needed_for_upgrade": 150, "upgrade_tier": { "id": 17, "name": "Gold", "threshold": 400 }, "forecasted_tier": null }, "insights_segment": "Loyal", "referral_url": "https://prz.io/KzByQ2Fa", "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" } } } } ``` # program_events/customer.moved_to_at_risk_segment Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-moved-to-at-risk-segment This webhook triggers when a customer moves to the 'At Risk' insight segment. To subscribe to this topic your access token needs to contain the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **new_insight_segment** `string` *required* The name of the insight segment that the customer has moved into **previous_insight_segment** `string | null` *required* The name of the insight segment that the customer has moved from, or `null` if they were not previously in a segment **frequency** `number | null` *required* The number of orders the customer has placed **total_spend** `number | null` *required* The total lifetime spend of the customer in currency subunits, e.g. \$150 will be `15000` **last_order_date** `string | null` *required* `ISO 8601` timestamp of the customer's last order **average_basket_size** `number | null` *required* Average value of the customer's basket ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.moved_to_at_risk_segment", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": {}, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "At Risk", "referral_url": "https://prz.io/KzByQ2Fa", "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "frequency": 1, "total_spend": 4500, "last_order_date": "2020-11-11T19:18:39.928Z", "average_basket_size": 4500, "new_insight_segment": "At Risk", "previous_insight_segment": "Win Back" } } ``` # program_events/customer.moved_to_defected_segment Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-moved-to-defected-segment This webhook triggers when a customer moves to the Win Back insight segment. Note that while the webhook contains the word `defected` the segment is always referred to as 'Win Back'. To subscribe to this topic your access token needs to contain the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **new_insight_segment** `string` *required* The name of the insight segment that the customer has moved into **previous_insight_segment** `string | null` *required* The name of the insight segment that the customer has moved from, or `null` if they were not previously in a segment **frequency** `number | null` *required* The number of orders the customer has placed **total_spend** `number | null` *required* The total lifetime spend of the customer in currency subunits, e.g. \$150 will be `15000` **last_order_date** `string | null` *required* `ISO 8601` timestamp of the customer's last order **average_basket_size** `number | null` *required* Average value of the customer's basket ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.moved_to_defected_segment", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": {}, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Win Back", "referral_url": "https://prz.io/KzByQ2Fa", "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "frequency": 1, "total_spend": 4500, "last_order_date": "2020-11-11T19:18:39.928Z", "average_basket_size": 4500, "new_insight_segment": "Win Back", "previous_insight_segment": "At Risk" } } ``` # program_events/customer.moved_to_loyal_segment Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-moved-to-loyal-segment This webhook triggers when a customer moves to the 'Loyal' insight segment. To subscribe to this topic your access token needs to contain the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **new_insight_segment** `string` *required* The name of the insight segment that the customer has moved into **previous_insight_segment** `string | null` *required* The name of the insight segment that the customer has moved from, or `null` if they were not previously in a segment **frequency** `number | null` *required* The number of orders the customer has placed **total_spend** `number | null` *required* The total lifetime spend of the customer in currency subunits, e.g. \$150 will be `15000` **last_order_date** `string | null` *required* `ISO 8601` timestamp of the customer's last order **average_basket_size** `number | null` *required* Average value of the customer's basket ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.moved_to_loyal_segment", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": {}, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": "https://prz.io/KzByQ2Fa", "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "frequency": 2, "total_spend": 4500, "last_order_date": "2020-11-11T19:18:39.928Z", "average_basket_size": 4500, "new_insight_segment": "Loyal", "previous_insight_segment": "Win Back" } } ``` # program_events/customer.receipt_approved Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-receipt-approved This webhook is triggered when a customer's uploaded receipt is approved. The receipt may have been approved automatically or after manual review. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **receipt** `object` *required* **id** `number` *required* The LoyaltyLion ID of the receipt **status** `string` *required* The status of the receipt. Will be `approved` for this event **retailer_name** `string | null` *required* The name of the retailer on the receipt **total_paid** `number | null` *required* The total amount paid, in the receipt's currency **tax_paid** `number | null` *required* The tax amount paid, in the receipt's currency **currency** `string | null` *required* The ISO 4217 currency code of the receipt **fraud_score** `number | null` *required* The fraud score of the receipt, from 0 to 100 **duplicate** `boolean | null` *required* Whether the receipt was detected as a duplicate **retailer_receipt_date** `string | null` *required* The date on the receipt, as an ISO 8601 timestamp **created_at** `string` *required* When the receipt was uploaded, as an ISO 8601 timestamp **rule** `object` *required* **id** `number` *required* The LoyaltyLion ID of the retail purchase rule **name** `string` *required* The name of the rule **activity** `object` Activity object with the same shape as the [Activities API](/api-reference/v2/resources/activities/list-activities#response-activities) response. This is the activity created as a result of the receipt being approved. May not be present if the receipt was approved without creating an activity ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.receipt_approved", "created_at": "2025-03-15T10:30:00.000Z", "payload": { "id": "a1b2c3d4-5e6f-7890-abcd-ef1234567890", "created_at": "2025-03-15T10:30:00.000Z", "kind": "customer.receipt_approved", "unique_until": null, "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 0, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2025-03-15T10:30:00.000Z" }, "receipt": { "id": 42, "status": "approved", "retailer_name": "Walmart", "total_paid": 85.5, "tax_paid": 7.5, "currency": "USD", "fraud_score": 15, "duplicate": false, "retailer_receipt_date": "2025-03-14T00:00:00.000Z", "created_at": "2025-03-14T18:22:00.000Z" }, "rule": { "id": 1234, "name": "$retail_purchase" }, "activity": { "id": "7653", "merchant_id": null, "value": "100", "state": "approved", "created_at": "2025-03-15T10:30:00.000Z", "rule": { "id": "1234", "name": "$retail_purchase", "title": "Upload a receipt" } } } } } ``` # program_events/customer.receipt_declined Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customer-receipt-declined This webhook is triggered when a customer's uploaded receipt is declined. The receipt may have been declined automatically or after manual review. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **receipt** `object` *required* **id** `number` *required* The LoyaltyLion ID of the receipt **status** `string` *required* The status of the receipt. Will be `declined` for this event **retailer_name** `string | null` *required* The name of the retailer on the receipt **total_paid** `number | null` *required* The total amount paid, in the receipt's currency **tax_paid** `number | null` *required* The tax amount paid, in the receipt's currency **currency** `string | null` *required* The ISO 4217 currency code of the receipt **fraud_score** `number | null` *required* The fraud score of the receipt, from 0 to 100 **duplicate** `boolean | null` *required* Whether the receipt was detected as a duplicate **retailer_receipt_date** `string | null` *required* The date on the receipt, as an ISO 8601 timestamp **created_at** `string` *required* When the receipt was uploaded, as an ISO 8601 timestamp **rule** `object` *required* **id** `number` *required* The LoyaltyLion ID of the retail purchase rule **name** `string` *required* The name of the rule **declined_reason** `string | null` *required* The reason the receipt was declined, if available **upload_url** `string` *required* A URL the customer can use to re-upload a new receipt ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.receipt_declined", "created_at": "2025-03-15T10:30:00.000Z", "payload": { "id": "a1b2c3d4-5e6f-7890-abcd-ef1234567890", "created_at": "2025-03-15T10:30:00.000Z", "kind": "customer.receipt_declined", "unique_until": null, "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 0, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": null, "referred_by": null, "loyalty_tier_membership": null, "tier_eligibility": null, "insights_segment": "Loyal", "referral_url": null, "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2025-03-15T10:30:00.000Z" }, "receipt": { "id": 43, "status": "declined", "retailer_name": "Walmart", "total_paid": 85.5, "tax_paid": 7.5, "currency": "USD", "fraud_score": 92, "duplicate": false, "retailer_receipt_date": "2025-03-14T00:00:00.000Z", "created_at": "2025-03-14T18:22:00.000Z" }, "rule": { "id": 1234, "name": "$retail_purchase" }, "declined_reason": "Fraud score exceeded threshold", "upload_url": "https://upload.loyaltylion.com/123/a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4" } } } ``` # program_events/customer.approaching_tier_upgrade Source: https://developers.loyaltylion.com/api-reference/v2/webhooks/events/program-events/customers-approaching-tier-upgrade This webhook is fired when a customer is close to moving up a tier. The constraint (i.e. how close a customer should be to the next tier before this webhook is sent) can be configured in your LoyaltyLion admin. To subscribe to this webhook, your access token needs to contain the `read_customers` scope. > [!NOTE] > > This webhook has a 7 day cool-down period per individual customer ## Payload **customer** `object` *required* Customer object with the same shape as the [Customers API](/api-reference/v2/resources/customers/list-customers#response-customers) response **current_tier** `object` *required* The loyalty tier the customer is currently in **properties** **id** `number` *required* Unique LoyaltyLion ID of the tier **name** `string` *required* The name of the tier **number** `number` *required* The sequential, ordered number of the tier. The default (first) tier will be `1` **default** `boolean` *required* Indicates if this is the default (first) tier in the program **hidden** `boolean` *required* Indicates if this is a hidden tier **lower_bound** `string` *required* The lower bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` **upper_bound** `string | null` *required* The upper bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` This will be `null` if there is no upper bound for the tier. **next_tier** `object` *required* The next tier the customer is approaching **properties** **id** `number` *required* Unique LoyaltyLion ID of the tier **name** `string` *required* The name of the tier **number** `number` *required* The sequential, ordered number of the tier. The default (first) tier will be `1` **default** `boolean` *required* Indicates if this is the default (first) tier in the program **hidden** `boolean` *required* Indicates if this is a hidden tier **lower_bound** `string` *required* The lower bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` **upper_bound** `string | null` *required* The upper bound of the tier. For spend-based tiers, this will be a decimal value, e.g. a lower bound of \$100 will be `100.00` For point-based tiers, this value will be divided by 100. To get the correct value for the bound, multiply it by 100. For example, if the lower bound of the tier is 5000, the value returned will be `50.00` This will be `null` if there is no upper bound for the tier. **points_required** `number` If tiers are points-based, the number of points required to reach the next tier. Only the field matching your program's tier mode is present **spend_required** `number` If tiers are spend-based, the spend required to reach the next tier. Only the field matching your program's tier mode is present **orders_required** `number` If tiers are order-count based, the number of qualifying orders required to reach the next tier. Only the field matching your program's tier mode is present ## Example ```json Example theme={null} { "id": "bff1bddb-6cd8-4c2c-9619-18744657053c", "topic": "program_events/customer.approaching_tier_upgrade", "created_at": "2018-01-01T03:00:05.000Z", "payload": { "properties": { "customer": { "id": 6932, "merchant_id": "2134606599", "email": "jessica@example.com", "points_approved": 200, "points_pending": 300, "points_spent": 500, "rewards_claimed": 5, "rewards_used": 0, "properties": { "name": "Jessica White" }, "metadata": {}, "birthday": "1990-01-29", "blocked": false, "guest": false, "enrolled": true, "enrolled_at": "2015-12-10T03:00:00.000Z", "referral_id": "a4e", "referred_by": { "id": 3958, "merchant_id": "192838592" }, "loyalty_tier_membership": { "started_at": "2017-03-03 00:00:00Z", "expires_at": null, "manual": false, "loyalty_tier": { "id": 15, "name": "Bronze", "position": 1, "default": true, "hidden": false, "lower_bound": "0.00", "upper_bound": "200.00" } }, "tier_eligibility": { "kind": "points", "valid_until": null, "tier_points": { "now": 180, "at_expiration": null }, "points_needed_for_renewal": null, "points_needed_for_upgrade": 20, "upgrade_tier": { "id": 16, "name": "Silver", "threshold": 200 }, "forecasted_tier": null }, "insights_segment": "Loyal", "referral_url": "https://prz.io/KzByQ2Fa", "created_at": "2016-12-10T03:00:00.000Z", "updated_at": "2018-01-01T03:00:00.000Z" }, "next_tier": { "id": 16, "name": "Silver", "number": 2, "default": false, "hidden": false, "lower_bound": "200.01", "upper_bound": "400.00" }, "current_tier": { "id": 15, "name": "Bronze", "number": 1, "default": true, "hidden": false, "lower_bound": "0.00", "upper_bound": "200.00" }, "points_required": 20 } } } ``` # Example prompts Source: https://developers.loyaltylion.com/docs/mcp/example-prompts Once you've [connected the MCP server](/docs/mcp/overview), you can ask your assistant questions in plain language. Below are examples grouped by capability to show what's possible. ## Understanding your program setup Ask about your program's configuration — sites, locales, points-expiry policy, earning rules, redeemable rewards, tier structure, and referral incentive. * "How is my loyalty program set up?" * "What rules do customers earn points from, and how many points does each give?" * "List all the rewards customers can redeem and how many points they cost." * "What tiers do I have, and what are the thresholds for each?" * "Do my points expire? What's the expiry policy?" * "What referral incentive is configured for my program?" * "Which sites and locales are part of my program?" ## Analytics and performance Get a time series for a single metric over a date range, bucketed by day, week, or month. Many metrics can be filtered to a single site, earning rule, or reward. The available metrics are: | Metric | What it measures | Filter by | | - | - | - | | New members | Customers who enrolled during the period | — | | Activities completed | Point-earning customer activities recorded | site, rule | | Points earned | Points earned (approved + pending) | site, rule | | Points earned (approved) | Points earned from approved activities | site, rule | | Points earned (pending) | Points earned from activities not yet approved | site, rule | | Points spent | Points spent on approved reward claims | site | | Points expired | Points that expired | site, rule | | Points deducted | Points removed via negative approved activities | site, rule | | Orders | Orders placed during the period | site | | Revenue | Total order revenue, in your currency | site | | Average order value | Revenue divided by orders, in your currency (buckets with no orders are omitted) | site | | Loyalty-attributed revenue | Revenue attributable to the loyalty program (reward/referral orders and repeat redeemers) | site | | Rewards claimed | Reward claims created (distinct from the points they cost) | site, reward | | Rewards used | Claimed rewards that were redeemed | site, reward | | Customer lifetime value | Blended customer lifetime value, averaged across customers (monthly only) | site | > [!NOTE] > > Revenue, average order value, loyalty-attributed revenue, and customer > lifetime value are returned in your store's currency. If your program has > active sites in more than one currency, scope these metrics to a single site > with a site filter — otherwise the request is refused rather than mixing > currencies. Customer lifetime value is only available at month granularity. Example prompts: * "How many new members did I gain each month this year?" * "Show me points earned per week for the last quarter." * "Compare points earned vs points spent over the last 90 days." * "How many points expired last month?" * "What were my daily activity completions in December?" * "Which earning rule drove the most points last month?" * "Break down points earned by site for the last month." * "What was my revenue and average order value each month this year?" * "How much revenue was attributed to the loyalty program last quarter?" * "How many orders did I get per week over the last 90 days?" * "How many rewards were claimed vs used last month?" * "Which reward was claimed the most over the last 90 days?" * "Show me customer lifetime value month by month this year." ## Customers Look up your loyalty customers by email, ID (`merchant_id`, their ID in your ecommerce platform), or created/updated time range. Each customer includes their points balances, enrollment state, current tier, tags, and timestamps. Requires the `read_customers` scope on the credential you connected with. * "Look up the customer with email [customer@example.com](mailto:customer@example.com)." * "What's the points balance and tier for the customer with ID 1234567890?" * "Which customers enrolled in the last 7 days?" * "Show me customers updated since the start of the month." ## Orders List your orders by time range, order number, ID (`merchant_id`, the order's ID in your ecommerce platform), or customer. Each order includes its amounts, statuses, timestamps, points earned, and rewards used. Requires the `read_orders` scope on the credential you connected with. * "Show me the orders placed by [customer@example.com](mailto:customer@example.com)." * "What points did order #1001 earn?" * "List orders from the last 7 days and the rewards used against them." * "Find the order with ID 1234567890 and tell me its status." # Overview Source: https://developers.loyaltylion.com/docs/mcp/overview The LoyaltyLion MCP server lets AI assistants — such as Claude, ChatGPT, Cursor, or any [Model Context Protocol](https://modelcontextprotocol.io) client — answer questions about your loyalty program using live data from your account. Connect it once and you can ask, in plain language, how your program is configured and how it's performing. > [!NOTE] > > Merchant MCP is available on the **Classic plan and above**. ## What it can do The MCP server exposes a small set of read-only tools: | Capability | What the assistant can do | | - | - | | **Describe program setup** | Read your program's configuration — name, live status, sites, locales, points-expiry policy, earning rules, rewards, tiers, and referral incentive. | | **Analytics metrics** | Pull time series for a single analytics metric — membership, points, orders, revenue, rewards, and customer lifetime value — over a date range, bucketed by day, week, or month, optionally filtered by site, rule, or reward. | | **Fetch customers** | Look up loyalty customers by email, ID (`merchant_id`), or created/updated time range, with their points balances, enrollment state, tier, and tags. | | **Fetch orders** | List orders by time range, order number, ID (`merchant_id`), or customer, with each order's amounts, statuses, timestamps, points earned, and rewards used. | See [Example prompts](/docs/mcp/example-prompts) for things you can ask once it's connected. ## Endpoint The MCP server is a streamable-HTTP endpoint served from the same host as the LoyaltyLion API: ``` POST https://api.loyaltylion.com/mcp ``` Authenticate with a Program API key (or OAuth token) passed as a `Bearer` token in the `Authorization` header. Site token & secret authentication is not accepted. ## Install in Claude If you use Claude — web, desktop, mobile, or Claude Code — install the LoyaltyLion connector from the Claude directory: > [card] [LoyaltyLion connector for Claude](https://claude.ai/directory/connectors/loyaltylion) > > Open the connector and click **Connect**, then sign in to LoyaltyLion to > authorize access. You don't need an API key — the connector authorizes through your LoyaltyLion account. Claude Code picks it up too: any connector you add in Claude is [automatically available in Claude Code](https://code.claude.com/docs/en/mcp#use-mcp-servers-from-claudeai) when it's signed in with the same `claude.ai` account, so there's nothing to configure there either. Once it's connected, Claude discovers the available tools automatically. Head to [Example prompts](/docs/mcp/example-prompts) to start asking questions. ## Install in ChatGPT In ChatGPT, add LoyaltyLion as a custom MCP plugin in developer mode. Like the Claude connector, it authorizes through your LoyaltyLion account, so you don't need an API key. > [!NOTE] > > Developer mode is available on ChatGPT Plus, Pro, Business, Enterprise, and > Education plans, on the web. In a Business, Enterprise, or Education > workspace, an admin may need to allow developer mode before you can turn it > on. **1. Turn on developer mode** In ChatGPT, open `Settings > Security and login` and turn on `Developer mode`. On some accounts the toggle sits at the bottom of the `Plugins` settings page instead. **2. Create the plugin** Go to [chatgpt.com/plugins](https://chatgpt.com/plugins) and click the `+` button. Give it a name, such as `LoyaltyLion`, and a short description, such as `Loyalty program setup, analytics, customers, and orders`. **3. Point it at the MCP server** Enter `https://api.loyaltylion.com/mcp` as the server URL and choose `OAuth` for authentication. Leave any client ID and secret fields blank — ChatGPT registers itself with LoyaltyLion automatically. **4. Sign in and authorize** Create the plugin, then sign in to LoyaltyLion when prompted. If your account has more than one program, choose the program to authorize, then approve access. ChatGPT then lists the tools it found on the server. To use it, start a new conversation and add the LoyaltyLion plugin from the tools menu in the composer, or mention it with `@`. Every LoyaltyLion tool is read-only, so ChatGPT won't ask you to confirm actions the way it does for tools that change data. > [!TIP] > > If ChatGPT answers from its own knowledge instead of your data, name the > plugin in your prompt — for example, "Using LoyaltyLion, how many new members > did I gain last month?" Head to [Example prompts](/docs/mcp/example-prompts) to start asking questions. ## Install in other MCP clients Other clients connect to the endpoint directly with an API key. Create the key first, then configure your client. This is also the route for a Claude Code session that authenticates some other way — `ANTHROPIC_API_KEY`, Bedrock, or Vertex — since connector sync requires a `claude.ai` login. ### 1. Create an API key Sign in to your LoyaltyLion account, go to `Manage > API keys`, click `Create API key`, and follow the steps. The token is shown only once after creation — store it somewhere secure. For more detail on API keys, see [Authentication › API keys](/api-reference/authentication/api-keys). ### 2. Choose scopes The MCP server only ever reads data, and the tools available to a key depend on the scopes you grant it. Grant the read scopes that match the data you want the assistant to access: | Capability | Scope required | | - | - | | Describe program setup | None — any valid key works | | Analytics metrics | None — any valid key works | | Fetch customers | `read_customers` | | Fetch orders | `read_orders` | Program setup and analytics don't require a specific scope, so a key with no scopes can use them. To let the assistant look up customers or orders, grant `read_customers` and `read_orders`. For the full list of scopes, see the [API key scopes](/api-reference/authentication/api-keys#api-key-scopes) reference. ### 3. Configure your client > [!WARNING] > > Your API key is a long-lived credential. Keep it out of any config file that > gets committed — read it from the environment, or from your client's secret > input, as the examples below do. Each example expects the key in a `LOYALTYLION_API_KEY` environment variable, except VS Code, which prompts for it. > [tab] Claude Code > > Run the following from your terminal: > > ```bash theme={null} > claude mcp add --transport http --scope user loyaltylion https://api.loyaltylion.com/mcp \ > --header 'Authorization: Bearer ${LOYALTYLION_API_KEY}' > ``` > > The single quotes matter: they stop your shell expanding the variable, so > the reference is stored in your config and resolved from the environment > each time Claude Code starts. With double quotes you'd save the key itself > into `~/.claude.json` in plain text. > > `--scope user` makes the server available in every project. Drop it to > install into the current project only. Check it connected with `/mcp` inside > Claude Code. > [tab] Cursor > > Add the server to `~/.cursor/mcp.json`, which applies to every project and > lives outside any repo: > > ```json theme={null} > { > "mcpServers": { > "loyaltylion": { > "url": "https://api.loyaltylion.com/mcp", > "headers": { > "Authorization": "Bearer ${env:LOYALTYLION_API_KEY}" > } > } > } > } > ``` > > A project-level `.cursor/mcp.json` works the same way, but it sits inside > your repo — only use it with the environment reference above, never a > hardcoded key. > [tab] VS Code > > Add the server to `.vscode/mcp.json` in your workspace. VS Code treats this > file as shareable, so declare the key as a password input rather than > inlining it — you'll be prompted for it on first use and it's stored in > secret storage: > > ```json theme={null} > { > "inputs": [ > { > "id": "loyaltylion-api-key", > "type": "promptString", > "description": "LoyaltyLion API key", > "password": true > } > ], > "servers": { > "loyaltylion": { > "type": "http", > "url": "https://api.loyaltylion.com/mcp", > "headers": { > "Authorization": "Bearer ${input:loyaltylion-api-key}" > } > } > } > } > ``` > [tab] Other clients > > Most clients accept an HTTP server entry with an `Authorization` header: > > ```json theme={null} > { > "mcpServers": { > "loyaltylion": { > "type": "http", > "url": "https://api.loyaltylion.com/mcp", > "headers": { > "Authorization": "Bearer YOUR_API_KEY" > } > } > } > } > ``` > > The exact format varies — consult your client's documentation for where MCP > servers are configured, how to supply request headers, and how to reference > a secret rather than pasting the key in. Once connected, your client will discover the available tools automatically. Head to [Example prompts](/docs/mcp/example-prompts) to start asking questions. ## Connect multiple loyalty programs Every MCP connection is scoped to a single loyalty program: an API key belongs to one program, and an OAuth authorization covers the one program you choose on the consent screen. If you run more than one program, add one connection per program and give each a name that identifies it — your assistant surfaces the tools of each connection under its name, so that's how you (and it) tell them apart. ### Add extra programs in Claude The connector from the directory can only be connected once, so it covers your first program. For each additional program, add a **custom connector** pointing at the same endpoint with a query string on the end: ``` https://api.loyaltylion.com/mcp?program=uk-store ``` The query string exists only to make the URL unique — Claude identifies connectors by URL, so a second connector needs a URL that differs from the first. The MCP server ignores it entirely and resolves the program from the credentials the connector authorizes with, so the value is yours to choose; something recognizable like your store name keeps things clear. **1. Open the custom connector dialog** In Claude, go to `Settings > Connectors`, then click `Add custom connector`. **2. Name it after the program** Use a name that makes the program obvious, such as `LoyaltyLion (UK store)`. Claude shows this name alongside the connector's tools, and it's what you'll refer to when you want a question answered from that program. **3. Enter the URL with a distinct query string** Use `https://api.loyaltylion.com/mcp?program=uk-store`, replacing `uk-store` with your own label. Each connector needs a different value here. **4. Connect and pick the program** Click `Connect` and sign in to LoyaltyLion. If your LoyaltyLion account has more than one program, you'll be asked which program to authorize — choose the one this connector is for. Repeat for each additional program. Once they're all connected, mention the program in your prompt — "compare points issued last month for the UK store and the US store" — and Claude will call the matching connector for each. > [!NOTE] > > Programs that live in separate LoyaltyLion accounts need a separate > LoyaltyLion login each, so you can only authorize them from Claude one account > at a time. If that's your setup, use API keys in a client that supports them > instead. ### Add extra programs in ChatGPT Repeat [Install in ChatGPT](#install-in-chatgpt) once per program, naming each plugin after its program, such as `LoyaltyLion (UK store)`, and choosing the matching program when you authorize. If ChatGPT won't accept a URL you've already used, add a query string as described for Claude above, such as `https://api.loyaltylion.com/mcp?program=uk-store`. Then add the plugins you need to the conversation and mention the program in your prompt, just as with Claude. The same limitation applies as in Claude: programs in separate LoyaltyLion accounts each need their own login. ### Add extra programs in other MCP clients Clients configured from a file already namespace each server by the name you give it, so no query string is needed — add one entry per program, each with its own name and its own API key. Create the key from within each program: switch program in LoyaltyLion, then go to `Manage > API keys`. > [tab] Claude Code > > ```bash theme={null} > claude mcp add --transport http --scope user loyaltylion-uk https://api.loyaltylion.com/mcp \ > --header 'Authorization: Bearer ${LOYALTYLION_UK_API_KEY}' > > claude mcp add --transport http --scope user loyaltylion-us https://api.loyaltylion.com/mcp \ > --header 'Authorization: Bearer ${LOYALTYLION_US_API_KEY}' > ``` > [tab] Cursor > > ```json theme={null} > { > "mcpServers": { > "loyaltylion-uk": { > "url": "https://api.loyaltylion.com/mcp", > "headers": { > "Authorization": "Bearer ${env:LOYALTYLION_UK_API_KEY}" > } > }, > "loyaltylion-us": { > "url": "https://api.loyaltylion.com/mcp", > "headers": { > "Authorization": "Bearer ${env:LOYALTYLION_US_API_KEY}" > } > } > } > } > ``` > [tab] VS Code > > One password input per program, so each key is prompted for separately and > kept in secret storage: > > ```json theme={null} > { > "inputs": [ > { > "id": "loyaltylion-uk-api-key", > "type": "promptString", > "description": "LoyaltyLion API key (UK store)", > "password": true > }, > { > "id": "loyaltylion-us-api-key", > "type": "promptString", > "description": "LoyaltyLion API key (US store)", > "password": true > } > ], > "servers": { > "loyaltylion-uk": { > "type": "http", > "url": "https://api.loyaltylion.com/mcp", > "headers": { > "Authorization": "Bearer ${input:loyaltylion-uk-api-key}" > } > }, > "loyaltylion-us": { > "type": "http", > "url": "https://api.loyaltylion.com/mcp", > "headers": { > "Authorization": "Bearer ${input:loyaltylion-us-api-key}" > } > } > } > } > ``` Everything else — where each file lives, and how each client references a secret — is unchanged from [Install in other MCP clients](#install-in-other-mcp-clients) above. The only difference here is that there's one entry, and one key, per program. # Clickthrough Source: https://developers.loyaltylion.com/headless-api/2025-06/complete-rules/clickthrough headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rules/clickthrough/complete Use this endpoint to complete a specific `clickthrough` rule for an enrolled customer. This should be called once the customer has visited the link specified in the clickthrough rule's `destination_url` property. On web, we recommend calling this endpoint and then opening the `destination_url` in a new tab. On mobile, you could use a browser navigation intent, or in-app browser, depending on your app. If the customer is able to complete the rule, a success response will be returned. This response will include a list of `actions` which will indicate any points or rewards that were awarded based on the rule's configuration. If the customer is not able to complete the rule, a `422` response will be returned instead. For example, if the customer has already completed the rule an allowed number of times, or the rule isn't enabled for the customer. # Facebook Like Source: https://developers.loyaltylion.com/headless-api/2025-06/complete-rules/facebook-like headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rules/facebook_like/complete Use this endpoint to complete a specific `facebook_like` rule for an enrolled customer. This should be called once a customer has liked, or (more commonly), shown an intention to like, the Facebook page specified in the rule's `facebook_like_url` property. Unless you have a full integration with a custom Facebook app and can ensure the user has liked the page, our recommended approach is to open the relevant Facebook page in a new window or in-app browser, and then call this endpoint either immediately, or after a short delay. If the customer is able to complete the rule, a success response will be returned. This response will include a list of `actions` which will indicate any points or rewards that were awarded based on the rule's configuration. If the customer is not able to complete the rule, a `422` response will be returned instead. For example, if the customer has already completed the rule an allowed number of times, or the rule isn't enabled for the customer. # Instagram Follow Source: https://developers.loyaltylion.com/headless-api/2025-06/complete-rules/instagram-follow headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rules/instagram_follow/complete Use this endpoint to complete a specific `instagram_follow` rule for an enrolled customer. This should be called once a customer has followed, or (more commonly), shown an intention to follow, the Instagram profile specified in the rule's `instagram_handle` property. Unless you have a full integration with a custom Instagram app and can ensure the user has followed the profile, our recommended approach is to open the relevant TikTok profile in a new window or in-app browser, and then call this endpoint either immediately, or after a short delay. If the customer is able to complete the rule, a success response will be returned. This response will include a list of `actions` which will indicate any points or rewards that were awarded based on the rule's configuration. If the customer is not able to complete the rule, a `422` response will be returned instead. For example, if the customer has already completed the rule an allowed number of times, or the rule isn't enabled for the customer. # TikTok Follow Source: https://developers.loyaltylion.com/headless-api/2025-06/complete-rules/tiktok-follow headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rules/tiktok_follow/complete Use this endpoint to complete a specific `tiktok_follow` rule for an enrolled customer. This should be called once a customer has followed, or (more commonly), shown an intention to follow, the TikTok profile specified in the rule's `tiktok_handle` property. Unless you have a full integration with a custom TikTok app and can ensure the user has followed the profile, our recommended approach is to open the relevant TikTok profile in a new window or in-app browser, and then call this endpoint either immediately, or after a short delay. If the customer is able to complete the rule, a success response will be returned. This response will include a list of `actions` which will indicate any points or rewards that were awarded based on the rule's configuration. If the customer is not able to complete the rule, a `422` response will be returned instead. For example, if the customer has already completed the rule an allowed number of times, or the rule isn't enabled for the customer. # Twitter/X Follow Source: https://developers.loyaltylion.com/headless-api/2025-06/complete-rules/twitter-follow headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rules/twitter_follow/complete Use this endpoint to complete a specific `twitter_follow` rule for an enrolled customer. This should be called once a customer has followed, or (more commonly), shown an intention to follow, the Twitter/X profile specified in the rule's `twitter_handle` property. Unless you have a full integration with a custom Twitter/X app and can ensure the user has followed the profile, our recommended approach is to open the relevant Twitter/X profile in a new window or in-app browser, and then call this endpoint either immediately, or after a short delay. If the customer is able to complete the rule, a success response will be returned. This response will include a list of `actions` which will indicate any points or rewards that were awarded based on the rule's configuration. If the customer is not able to complete the rule, a `422` response will be returned instead. For example, if the customer has already completed the rule an allowed number of times, or the rule isn't enabled for the customer. # Get Configuration Source: https://developers.loyaltylion.com/headless-api/2025-06/configuration/get-configuration headless-api/2025-06/openapi.json GET /headless/2025-06/{site_id}/configuration Use this endpoint to retrieve the full configuration for a site, based on the requested sales channel. This configuration includes tier details, rules, rewards and various other settings that can be used to construct a custom shopper-facing frontend. > [!NOTE] > > This endpoint has a rate limit of 100 requests per second > > If you anticipate making a high volume of calls to this endpoint, e.g. if you > are calling it on each page render, consider caching the returned configuration > for a short period (max 30 seconds) and reusing it ## Tiers `tier_configuration.boundary_mode` is `points`, `spend` or `orders`, and sets the unit of each tier's `lower_bound` and `upper_bound`: a points total, a currency amount, or a number of qualifying orders. Every tier except a conditional tier has a `kind` matching the boundary mode. Conditional tiers have no bounds. For `orders` programs, bounds are whole numbers of qualifying orders and are inclusive. A tier with a lower bound of `3` and an upper bound of `5` holds customers with 3, 4 or 5 qualifying orders. The highest tier has an `upper_bound` of `null`. A qualifying order is paid or partially paid, not cancelled, and not fully refunded. A partially refunded order still counts as one order. Only orders placed after the program launched, and within the tier evaluation window, are counted. If the program sets a minimum qualifying order value, an order only counts when its value, net of refunds and gift cards, meets that minimum. The minimum is compared against the order total, or against the product subtotal if the program is set up that way. # Enroll Customer Source: https://developers.loyaltylion.com/headless-api/2025-06/customers/enroll-customer headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/customers/{merchant_id}/enroll Explicitly enroll a customer into the loyalty program. Use this when the shopper has asked to join, for example by clicking a "Join the program" button in your storefront or mobile app. This endpoint bypasses the program's enrollment strategy entirely, which makes it the answer for programs configured for opt-in enrollment, where initializing a session deliberately doesn't enroll anyone. It's also safe to call on an auto-enroll program — calling it for an already-enrolled customer is a no-op. The customer must already exist in LoyaltyLion. If no customer matches the given `merchant_id`, a `404` response will be returned. On a headless storefront running an opt-in program, the normal sequence is [Initialize Session](./initialize-session) — which creates a customer who doesn't exist yet and leaves them as a guest — then this endpoint once they click join. The `enrolled` property is `true` only when this request performed the enrollment. If the customer was already a member it will be `false` and nothing has changed, so treat it as "did I just enroll them", not "are they enrolled" — use `customer.state` for the latter. The `customer` property is the customer in their post-enrollment state. It's safe to retry this endpoint, and concurrent calls (e.g. a double-clicked button, or two open tabs) will only enroll the customer once. If the customer is blocked from the program, they can't be enrolled, and a `422` response will be returned with a `customer_blocked` code. As with enrollment from a session, enrolling a customer may trigger program rules, most notably a "join program" rule, if one is configured. # Get Customer Source: https://developers.loyaltylion.com/headless-api/2025-06/customers/get-customer headless-api/2025-06/openapi.json GET /headless/2025-06/{site_id}/customers/{merchant_id} Retrieve a customer by `merchant_id` (the ID of the customer in your store or platform). If no matching customer exists, a `404` response will be returned. For convenience, the full program configuration, as returned by the [Get Configuration](/headless-api/2025-06/configuration/get-configuration) endpoint, is also included in the response. Compared to the [Initialize Session](./initialize-session) endpoint, this endpoint is readonly and will never create or update a customer, or trigger any rules. This endpoint is useful when you know the customer will already exist, and just want to retrieve their information quickly. For example, if the customer session is initialized elsewhere (either by you, or the main LoyaltyLion SDK). # Initialize Session Source: https://developers.loyaltylion.com/headless-api/2025-06/customers/initialize-session headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/customers/{merchant_id}/sessions Initialize a headless session for the customer with the given `merchant_id` (the ID of the customer in your store or platform). For convenience, the full program configuration, as returned by the [Get Configuration](/headless-api/2025-06/configuration/get-configuration) endpoint, is also included in the response. If you're building your own headless web UI, you should generally call this once on each page load, or, for a mobile app, once per "session", e.g. when the customer opens or resumes the app. Compared to the read-only [Get Customer](./get-customer) endpoint, this endpoint can create and enroll customers, and will trigger any relevant rules. * if no matching customer exists in LoyaltyLion for the given `merchant_id`, a new customer will be created, potentially enrolled into the program, and returned * if a matching customer is found in LoyaltyLion, they may be enrolled and returned Customers will be enrolled based on the program's configuration. For example, if the program is configured to auto-enroll customers, they'll become enrolled automatically when their session is initialized. If the program requires customers to opt in, initializing a session will not enroll them. Use the [Enroll Customer](./enroll-customer) endpoint to enroll a customer once they've asked to join, e.g. by clicking a "Join the program" button. For both new and existing customers, program rules may be triggered for the customer. For example: * "join program" rule if the customer was just enrolled from this session * "pageview" rule if the `channel` is `web` and they're viewing a relevant page * "download mobile app" rule if the `channel` is `mobile` # Set Birthday Source: https://developers.loyaltylion.com/headless-api/2025-06/customers/set-birthday headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/customers/{merchant_id}/birthday Set a customer's birthday. After a customer's birthday is set, no immediate action is taken, but any applicable rules will be triggered in future. If the customer's birthday is already set, this endpoint will not change it. Instead, the the `updated` field in the response will be `false`, and the birthday will remain at its previous value. # Subscribe to Email Marketing Source: https://developers.loyaltylion.com/headless-api/2025-06/customers/subscribe-email-marketing headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/customers/{merchant_id}/email_marketing/subscribe > [!NOTE] > > This endpoint is currently only supported for Shopify stores Subscribe a customer to email marketing. This will set the customer's email marketing consent in your Shopify store, so it's important that you only call this endpoint once the customer has provided explicit consent. The customer's registered email will be used for the email marketing subscription; it's not possible to subscribe any other email address. If the customer is already subscribed to email marketing, the `updated` property will be `false`. Otherwise, they will be subscribed and the `updated` property will be `true`. In case it's not possible to subscribe the customer, a `422` response will be returned with a `code` property indicating the reason. If there are relevant rules applicable to the customer, such as a `newsletter_signup` rule, they will be triggered (unless they have already been completed before), and any related actions will be included in the `actions` property in the response, such as points or rewards that were awarded. # Claim Referee Incentive Source: https://developers.loyaltylion.com/headless-api/2025-06/referrals/claim-referee-incentive headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/referrals/referee_incentive Exchange an inbound referral id for the referee incentive — a discount voucher code you can display to the referred shopper. Use this when a shopper arrives at your storefront or app with an `ll_ref_id` query parameter, which is how our referral links identify who referred them. The `referral_id` is the value of that `ll_ref_id` parameter. The `ip_address` must be the referred shopper's own address — the one that reached your server, never your server's — as it powers referral fraud detection. Pass `referee_email` whenever you know the shopper's email. It binds the voucher to them, and it's what allows self-referrals and referrals of existing program members to be rejected (`invalid_referee`). If the referrer isn't an enrolled member, the email is required, and you'll receive a `referee_email_required` error until you supply it — collect the shopper's email and retry. It's safe to retry: claiming again with the same referral and referee returns the same code rather than issuing a new one. To present the offer alongside the code ("Get 10% off your first order, up to \$30"), use the `referee_incentive` object from [Get Configuration](../configuration/get-configuration), which carries localized display text and the structured discount details. When the shopper later places their first order using the voucher, the referral completes automatically — the shopper is linked to their referrer and your referral rule triggers. See the [referrals guide](/headless-api/guides/referrals) for the end-to-end flow. # Register Guest Referrer Source: https://developers.loyaltylion.com/headless-api/2025-06/referrals/register-guest-referrer headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/referrals/guest_registrations Give a shopper who hasn't joined your program a set of referral links to share. Use this to offer referrals to a visitor before they enrol, for example from a "refer a friend" form that only asks for their name and email. The response carries `referral_urls`, the same set of channel links an enrolled customer has. The shopper is not enrolled by this request: they get a customer record so their referrals have somewhere to be attributed, and if they later enrol with the same email, their referrals carry over. The request is only available when guest referrals are turned on in your referral settings, and your program has an active referral rule. Otherwise it is rejected with `guest_referrals_not_enabled`. The `ip_address` must be the shopper's own address, the one that reached your server, never your server's. Each shopper is rate limited on it, so sending your own address gives every shopper you have one shared allowance. A `429` means that shopper, or your site as a whole, has registered too many guests in a short window: wait and retry. It's safe to retry: registering an address that already holds links returns the same links rather than a second set. If the address belongs to an enrolled member, they keep their membership and the response says nothing about it. When a guest's friend claims the incentive, the claim needs the friend's email address, because there is no membership to attribute the referral to. See `referee_email_required` on [Claim Referee Incentive](/headless-api/2025-06/referrals/claim-referee-incentive). # Track Share Source: https://developers.loyaltylion.com/headless-api/2025-06/referrals/track-share headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/referrals/shares Record that a customer shared their referral link, and on which channel. This is what populates the share counts in your referral analytics — without it, your dashboard shows referral visits and purchases but no shares, so call it whenever a shopper completes a share in your storefront or app (for example, after the native share sheet confirms, or when they copy their link). The `channel` must be one of the channels that appear in the customer's `referral_urls`, and should match the link they actually shared — `device_share` for a native share sheet, `direct` for a copied link, and so on. Shares are categorized by channel in your referral analytics. The customer must be enrolled in the program and not blocked. A [guest referrer](/headless-api/2025-06/referrals/register-guest-referrer) has links to share, but their shares can't be recorded. A successful request returns `204` with no body. # Active Subscription Discount Voucher Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-redemption/active-subscription-discount-voucher headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/active_subscription_discount_voucher/redeem > [!NOTE] > > The > [ReCharge](https://help.loyaltylion.com/en/articles/3128642-recharge-integration-manual) > integration must have been configured in LoyaltyLion before using this reward. Use this endpoint to redeem a `active_subscription_discount_voucher` reward, which will apply a fixed or percentage discount to one or more *active* subscriptions. If the redemption is successful, the new claimed reward and a unique voucher (coupon) code will be included in the response. Unlike regular [discount vouchers](./cart-discount-voucher), an active subscription discount voucher can only be applied to an active subscription. This generally means the customer must navigate to their subscription portal and then apply the voucher code to an active subscription. For example, if your subscriptions provider is ReCharge, you should link the customer to their ReCharge subscription portal and instruct them to copy and apply the code to one of their active subscriptions. # Active Subscription Product Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-redemption/active-subscription-product headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/active_subscription_product/redeem > [!NOTE] > > The > [ReCharge](https://help.loyaltylion.com/en/articles/3128642-recharge-integration-manual) > integration must have been configured in LoyaltyLion before using this reward. Use this endpoint to redeem an active subscription product reward, which will automatically add a free product to a customer's upcoming subscription order. If the customer does not currently have any active subscriptions, the redemption will fail with an `error.code` of `no_active_subscriptions` ### Choosing a variant The reward may have been configured with multiple eligible product variants. If this is the case, you'll need to let the customer choose which variant they want to redeem, and then pass that ID as `variant_id` when performing the redemption. ### Choosing a subscription address By default, the product will be included with the customer's next upcoming subscription order. Alternatively, you can ask the customer to select which address they want the free product to be sent to. You can use the ReCharge API to [fetch a list](https://developer.rechargepayments.com/2021-11/addresses/list_addresses) of the customer's active addresses and ask them to choose which one the free product should be sent to. # Cart Discount Voucher Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-redemption/cart-discount-voucher headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/cart_discount_voucher/redeem Use this endpoint to redeem a `cart_discount_voucher` reward, which will apply a fixed or percentage discount to the whole cart. If the redemption is successful, the new claimed reward and a unique voucher (coupon) code will be included in the response. You can show the voucher code to the customer and instruct them to apply it to their cart later. Or, if supported by your ecommerce platform, you can apply the voucher code to the cart directly, which provides a superior user experience. Note that cart discount vouchers can have a minimum spend, found in `claimed_reward.redeemable.minimum_spend`. If present, this should be communicated to the customer to avoid confusion. # Collection Discount Voucher Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-redemption/collection-discount-voucher headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/collection_discount_voucher/redeem Use this endpoint to redeem a `collection_discount_voucher` reward, which will apply a fixed or percentage discount to line items that belong to the designated collection. If the redemption is successful, the new claimed reward and a unique voucher (coupon) code will be included in the response. You can show the voucher code to the customer and instruct them to apply it to their cart later. Details of the collection to which this voucher applies can be found in `claimed_reward.redeemable.collection`, and this should be shown to the customer. Note that collection discount vouchers can have a minimum spend, found in `claimed_reward.redeemable.minimum_spend`. If present, this should be communicated to the customer to avoid confusion. # Free Product Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-redemption/free-product headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/product_cart/redeem > [!NOTE] > > Free products can only be redeemed on Shopify, and must use Shopify Functions. > If you are still using Shopify Scripts for free products, [get in > touch](mailto:support@loyaltylion.com) and we'll switch you over to Shopify > Functions Use this endpoint to redeem a free product reward, which can then be added to the customer's cart and checked out along with their other items. Redeeming free products requires the use of the Storefront API to add the free product to the customer's cart, at which point a LoyaltyLion Shopify Function will apply the discount. If you're using Shopify Hydrogen, see our [implementation guide](/headless-api/guides/hydrogen/free-product-rewards) for free product rewards. ### Choosing a variant The reward may have been configured with multiple eligible product variants. If this is the case, you'll need to let the customer choose which variant they want to redeem, and then pass that ID as `variant_id` when performing the redemption. # Free Shipping Voucher Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-redemption/free-shipping-voucher headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/free_shipping_voucher/redeem Use this endpoint to redeem a `free_shipping_voucher` reward, which will apply free shipping to the cart. If the redemption is successful, the new claimed reward and a unique voucher (coupon) code will be included in the response. You can show the voucher code to the customer and instruct them to apply it to their cart later. Or, if supported by your ecommerce platform, you can apply the voucher code to the cart directly, which provides a superior user experience. Note that free shipping vouchers may have a max shipping amount, which will be in in `claimed_reward.redeemable.max_shipping`. If present, this should be communicated to the customer to avoid confusion. # Gift Card Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-redemption/gift-card headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/gift_card/redeem Use this endpoint to redeem a `gift_card` reward. If the redemption is successful, the new claimed reward and a unique gift card code will be included in the response. The new gift card code can be seen *once only* in the in the `gift_card_code` response field. It's important that you instruct the customer to copy and save the code. # Product Discount Voucher Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-redemption/product-discount-voucher headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/product_discount_voucher/redeem Use this endpoint to redeem a `product_discount_voucher` reward, which will apply a percentage discount to a specific product and, optionally, a specific product variant. If the redemption is successful, the new claimed reward and a unique voucher (coupon) code will be included in the response. You can show the voucher code to the customer and instruct them to apply it to their cart later. Details of the product to which this voucher applies can be found in `claimed_reward.redeemable.product`, and this should be shown to the customer. # Free Product Source: https://developers.loyaltylion.com/headless-api/2025-06/reward-refund/free-product headless-api/2025-06/openapi.json POST /headless/2025-06/{site_id}/rewards/product_cart/refund > [!NOTE] > > Free products can only be refunded on Shopify, and must use Shopify Functions. > If you are still using Shopify Scripts for free products, [get in > touch](mailto:support@loyaltylion.com) and we'll switch you over to Shopify > Functions Use this endpoint to manually refund a free product reward. This will refund the points used back to the customer, and invalidate the associated free product line discount. This can be used when you detect a shopper has removed a free product reward from their cart. Note that if you refund a free product reward that is *still in the cart*, it won't be removed automatically, and will not be discounted at checkout. To prevent confusion for shoppers, you should always ensure that refunded free product rewards are also removed from the cart. ### Interaction with the [Initialize Customer Session API](/headless-api/2025-06/customers/initialize-session) If you are initializing a customer session regularly (e.g. on each page load, or after any change to the cart), *and* you are passing your current serialized cart, you typically do not need to manually refund free product rewards. The Initialize Customer Session API will use your serialized cart to check if any active free product rewards are present in the cart. If any are missing, they will be automatically refunded. # Changelog Source: https://developers.loyaltylion.com/headless-api/changelog **20 October 2026** ## Loyalty pass link An enrolled customer, returned by [Initialize Session](/headless-api/2025-06/customers/initialize-session) and [Get Customer](/headless-api/2025-06/customers/get-customer), now has a `loyalty_pass_url`. It is a personal link that installs the customer's loyalty pass in Apple Wallet or Google Wallet without asking them for their email or to log in, so a headless storefront can offer "Add to Wallet" without a separate Admin API call. The link identifies one customer, so only show it to that customer. It is `null` when the customer has no email address or the program's loyalty pass isn't live. **13 October 2026** ## Guest referral links The [Register Guest Referrer](/headless-api/2025-06/referrals/register-guest-referrer) endpoint gives a shopper who hasn't joined your program a set of referral links to share, so a headless storefront or mobile app can offer referrals before enrolment. It is available to programs with guest referrals turned on in their referral settings. See [Referral links for guests](/headless-api/guides/referrals#referral-links-for-guests) in the Referrals guide. **5 October 2026** ## Plan requirement Headless API requests from a program whose plan doesn't include the Headless API now return a `403` with the code `plan_required`, whichever credential they use. See [Errors](/headless-api/errors). The Headless API is included in the Classic plan and above, and can be enabled as an add-on on a lower plan. The Admin API (`/v2/*`) is not affected. **4 September 2026** ## Order-count tiers A program can now set its tier thresholds as a number of qualifying orders, alongside the existing points and spend modes. Nothing changes for points or spend programs. The additions below only appear when a program uses order-count tiers: * `tier_configuration.boundary_mode` in the [Get Configuration](/headless-api/2025-06/configuration/get-configuration) response can be `orders`. Each non-conditional tier then has `kind: "orders"`, an integer `lower_bound`, and an integer or `null` `upper_bound`, both inclusive counts of qualifying orders * `tier_membership.progress` on the customer, returned by [Initialize Session](/headless-api/2025-06/customers/initialize-session) and [Get Customer](/headless-api/2025-06/customers/get-customer), has a `kind: "orders"` variant with `tier_orders`, `orders_needed_for_upgrade` and `orders_needed_for_renewal`, mirroring the points and spend variants A qualifying order is paid or partially paid, not cancelled, and not fully refunded. A partially refunded order still counts as one order. If the program sets a minimum qualifying order value, an order only counts when its value, net of refunds and gift cards, meets that minimum. See [Tiers](/headless-api/2025-06/configuration/get-configuration#tiers). **28 August 2026** ## Customer session tokens Most Headless API endpoints accept a [customer session token](/headless-api/session-tokens) in place of an API key, so they can be called directly from a shopper's browser or mobile app. A session token is a signed credential you generate yourself, scoped to one customer on one site and to the `read` / `write` scopes you grant it. There is no API call to get one: you sign it with a key we publish to your store, which means a Shopify theme can render one in Liquid with no backend at all. This means you can now make calls to the Headless API directly from the client, instead of proxying them through your backend first. **25 August 2026** ## Referrals The Headless API now supports the full referral loop, so shoppers on a headless storefront or mobile app can share referral links, and their friends can claim the referral incentive and complete the referral: * The [Claim Referee Incentive](/headless-api/2025-06/referrals/claim-referee-incentive) endpoint exchanges the `ll_ref_id` from an inbound referral link for a discount voucher code to show the referred shopper * The [Track Share](/headless-api/2025-06/referrals/track-share) endpoint records shares so they appear in your referral analytics See the new [Referrals guide](/headless-api/guides/referrals) for the end-to-end flow, including order attribution and mobile deep links. **8 June 2026** ## Enroll customers into the program The [Enroll Customer](/headless-api/2025-06/customers/enroll-customer) endpoint can be used to explicitly enroll a customer into your program, so a shopper can join from your own storefront or mobile app, for example from a "Join the program" button. This is particularly useful if your program is configured for opt-in enrollment, where initializing a session deliberately doesn't enroll anyone. **29 July 2025** ## Set customer birthdays and subscribe to email marketing * The [Set Birthday](/headless-api/2025-06/customers/set-birthday) endpoint can be used to set a customer's birthday, so you can capture it as part of your storefront or mobile app and send it to LoyaltyLion where it can be used to gift a customer points or a reward for their birthday * The [Subscribe to Email Marketing](/headless-api/2025-06/customers/subscribe-email-marketing) endpoint can be used to subscribe a customer to email marketing. This is limited to Shopify stores for now, and will update the customer's email marketing consent with Shopify. If applicable rules are configured, they will be automatically triggered, such as awarding a customer with points or a reward for subscribing ## Complete rules for customers Complete interactive rules for customers using a set of new endpoints: [Clickthrough](/headless-api/2025-06/complete-rules/clickthrough), [Facebook Like](/headless-api/2025-06/complete-rules/facebook-like), [Instagram Follow](/headless-api/2025-06/complete-rules/instagram-follow), [TikTok Follow](/headless-api/2025-06/complete-rules/tiktok-follow), [Twitter/X Follow](/headless-api/2025-06/complete-rules/twitter-follow), [Custom](/headless-api/2025-06/complete-rules/custom) These endpoints should be called once the customer has completed the relevant action, such as visiting a URL, liking a Facebook page or following a TikTok user, and will immediately complete the rule for the customer and award them points or a reward, assuming they're eligible. **17 July 2025** ## Customer history Endpoints that return a Customer object, such as the [Get Customer](/headless-api/2025-06/customers/get-customer) API and reward redemption endpoints, now return the customer's recent point, tier and reward history under the `customer.history` property. **8 July 2025** ## Free product rewards The Headless API now supports the redemption of free product rewards when used with a Shopify storefront. See the [Free Product redemption](/headless-api/2025-06/reward-redemption/free-product) endpoint, and our [implementation guide](/headless-api/guides/hydrogen/free-product-rewards) for Shopify Hydrogen. If you're using a different frontend framework, you can still redeem free products (it's not Hydrogen specific). Review the Hydrogen guide for an overview and adapt to your framework, or get in touch with us if you need help. # Errors Source: https://developers.loyaltylion.com/headless-api/errors Headless API endpoints return can various errors. As a general rule, only `422` errors represent a problem that could be relayed to the shopper. All other error responses represent either a bug in your integration, an authentication issue, or a rate limit being reached. # Validation errors - `400` If your request fails structural validation, a `400` response will be returned, with details about the problematic fields. For example, the `channel` query parameter requires one of `web`, `pos` or `mobile`. If you provide a different value, you'll receive an error like this: ```json Example theme={null} { "error": { "message": "Invalid request", "details": { "channel": "Invalid option: expected one of \"web\"|\"pos\"|\"mobile\"" } } } ``` These kind of error responses represent a bug in your integration; the error itself is not useful to a shopper, or suitable to show to them. # Authentication errors - `401`, `403` These errors will be returned if your request could not be authenticated. In general, a `401` response indicates an invalid credential, while a `403` response indicates the credential does not have permission to perform the requested action. ```json Example theme={null} { "error": { "message": "Authentication is required" } } ``` Some of these carry a machine-readable `code`. The following apply only to requests authenticated with a [customer session token](/headless-api/session-tokens): * `token_expired`, a `401`. The session token is past its expiry. Issue a fresh one and retry the request once. * `insufficient_scope`, a `403`. The session token is valid, but was issued without a [scope](/headless-api/session-tokens#scopes) the endpoint requires. Retrying won't help; the fix is in the code that issues the token. ```json Example theme={null} { "error": { "code": "token_expired", "message": "Session token has expired. Fetch a fresh session token from your backend and retry the request" } } ``` Every other session token `401` carries no `code`, but most include a tag such as `[INVALID_SIGNATURE]` in the message, naming the check that failed. The tags, and the remaining code-less `403` rejections, are listed on the [customer session tokens](/headless-api/session-tokens#errors) page. `plan_required` is a `403` that applies whichever credential a request uses: an API key, an OAuth access token or a customer session token. It means your plan doesn't include the Headless API. The Classic plan and above include it, and on a lower plan it can be enabled as an add-on. Retrying won't help, and neither will a code change: contact your LoyaltyLion account manager or [our support team](mailto:support@loyaltylion.com) to enable it. ```json Example theme={null} { "error": { "code": "plan_required", "message": "The Headless API is not included in your plan. Contact your account manager to enable it." } } ``` # Not found errors - `404` If you request a resource that does not exist, a `404` response will be returned. For example, if you [redeem a reward](/headless-api/2025-06/reward-redemption/cart-discount-voucher) and pass a `reward_id` or a `customer_merchant_id` that does not exist in LoyaltyLion, a `404` response will be returned. ```json Example theme={null} { "error": { "code": "not_found", "message": "Reward with ID `1000` not found" } } ``` # Unprocessable errors - `422` If your request was correct, but it cannot be processed, a `422` response will be returned. This kind of error will always have a `code`, and each API endpoint's documentation page which error codes to expect, and what they mean. For example, if you [redeem a reward](/headless-api/2025-06/reward-redemption/cart-discount-voucher) but it is out of stock, a `reward_out_of_stock` code will be returned. You should review the expected error codes, determine which will apply to your integration, and turn them into an appropriate shopper-facing error message. ```json Example theme={null} { "error": { "code": "reward_out_of_stock" } } ``` # Rate limit errors - `429` If your API key has exceeded its rate limit, a `429` response will be returned. Requests authenticated with a [customer session token](/headless-api/session-tokens) are limited per customer instead, so one shopper cannot exhaust the budget for the rest of your site. # Free product rewards Source: https://developers.loyaltylion.com/headless-api/guides/hydrogen/free-product-rewards > [!NOTE] > > The Headless API is included in the **Classic plan** and above. On a lower > plan, contact your LoyaltyLion account manager or [our support > team](mailto:support@loyaltylion.com) to have it enabled as an add-on. You can use the Headless API with Shopify Hydrogen to implement product rewards which are added directly to the cart for free. Unlike other kinds of reward, free products require updates to your cart, which is done using the Storefront API, so they require a few more steps to implement. Our [reference implementation](https://github.com/loyaltylion/hydrogen-reference-store/pull/1) includes a full implementation of free product rewards, including them in the Cart sidebar. Even if you use our reference implementation, we recommend reading the rest of this guide to understand the steps involved. ## Prerequisites ### Ensure you're using Shopify Functions for free products Some older LoyaltyLion accounts may be using Shopify Scripts to implement free products. You must migrate to Shopify Functions in order to use free product rewards with the Headless API. If you're still using Shopify Scripts (or you're not sure), [get in touch](mailto:support@loyaltylion.com) and we can help you migrate over to Shopify Functions. ### Add a Buyer Identity to the Cart Free product rewards only work if the cart has a buyer identity, to associate the current logged in customer with the current cart. If you're using Hydrogen, you can do this using the provided helpers. In our reference implementation, we do this in the `root` loader inside `loadCriticalData`. ```typescript theme={null} export async function loader(args: LoaderFunctionArgs) { const { context } = args if (await context.customerAccount.isLoggedIn()) { const buyer = await context.customerAccount.getBuyer() await context.cart.updateBuyerIdentity({ customerAccessToken: buyer.customerAccessToken, }) } } ``` ## Implementation ### Initialize a customer session with your current cart Use the [Initialize Session](/headless-api/2025-06/customers/initialize-session) API to initialize a customer session and pass along your current cart. We use your cart to generate the response, for example any product rewards which have requirements like a minimum cart total will indicate they are not available to redeem in the response based on the provided cart. In our reference implementation, we do this using a deferred API call in the `root` loader. This pending data is then passed down to the `Cart` component and awaited in a `` wrapper. ```tsx theme={null} return ( Loading rewards...

}> {loyaltylion => { if (!loyaltylion) { return null } }}
) ``` ### Check if the customer is enrolled Confirm that the customer is enrolled by checking that `customer.state == "enrolled"`. Customers in any other state are not eligible to redeem rewards. ### Render free product rewards available to the customer Search for any applicable rewards in the `customer.available_rewards` array. Free product rewards will have `kind == "product_cart"`. Next, iterate each reward and render it along with an action button to redeem the reward. You'll need to check each reward's `context.can_redeem.state` to determine if the customer can redeem the reward, and, if they can't, the reason why, which is useful to display to the customer. ```tsx theme={null} const fetcher = useFetcher() const isLoading = fetcher.state !== 'idle' const canRedeem = reward.context.can_redeem.state === 'redeemable' const redeemButtonText = (() => { switch (reward.context.can_redeem.state) { case 'redeemable': return `Redeem for ${reward.variant.cost_text}` case 'claim_limit_reached': return 'Limit reached' case 'insufficient_points': return `${reward.context.can_redeem.additional_points_required} more points needed` case 'cart_requirements_not_met': return 'Cart requirements not met' case 'max_redemptions_for_cart_reached': return 'Already redeemed' default: return 'Unavailable' } })() return (
{reward.properties.product.image_url ? ( ) : (
)}

{reward.variant.title}

) ``` ### Handle the redemption of a free product reward When the customer clicks the redeem button, you'll need to submit an action. Inside your server-side action handler, * use the [Redeem Free Product](/headless-api/2025-06/reward-redemption/free-product) endpoint to redeem the reward * if successful, the response will contain an `active_cart_redemption.cart_line` object, which includes the necessary information you need to add to the cart using the Storefront API In our reference implementation, we do this in the [loyaltylion.redeem-free-product.\$id.tsx](https://github.com/loyaltylion/hydrogen-reference-store/blob/integrate-loyaltylion/app/routes/loyaltylion.redeem-free-product.%24id.tsx) route. Once the action is successful, Hydrogen/Remix should automatically re-run the relevant loaders, which will update both the cart and LoyaltyLion data, triggering an automatic UI update. ```tsx theme={null} export async function action({ params, request, context }: ActionFunctionArgs) { if (!(await context.customerAccount.isLoggedIn())) { return null } const { data } = await context.customerAccount.query(` query { customer { id } } `) if (!data.customer || !params.id) { return null } const rewardId = parseInt(params.id) const variantId = (await request.formData()).get('variant_id') as string const cartId = context.cart.getCartId() if (!cartId) { throw new Error('Cannot redeem free product reward without a cart') } const res = await createLoyaltyLionClient(context).rewards.redeemProductCart({ cart_id: cartId, customer_merchant_id: data.customer.id, reward_id: rewardId, variant_id: variantId, }) if (!res.data) { console.error('Failed to redeem product reward', { data: res.data, error: res.error, }) throw new Error('Request failed') } const cartLine = res.data.active_cart_redemption.cart_line await context.cart.addLines([ { merchandiseId: cartLine.merchandise_id, quantity: cartLine.quantity, attributes: cartLine.attributes, }, ]) } ``` ### Handle requested cart actions When you call [Initialize Session](/headless-api/2025-06/customers/initialize-session) and provide your current cart, will check the cart for any expired or invalid product redemptions and automatically cancel them and refund the points. If this happens, we'll return a list of [`requested_cart_actions`](/headless-api/2025-06/customers/initialize-session#response-requested-cart-actions) in the response. These actions indicate the changes, if any, that need to made to the cart. Currently this is limited to *removing* lines from the cart, because we've cancelled their associated redemption. This might be because the redemption expired, or because its requirements are no longer met by the cart (e.g. the cart total is too low). In our reference implementation, we [stash these requested line IDs](https://github.com/loyaltylion/hydrogen-reference-store/blob/integrate-loyaltylion/app/lib/loyaltylion/fetchLoyaltylionData.ts#L102) to remove on the `LoyaltyLionData` object, pass them down to the `Cart` component, and then [use a hook](https://github.com/loyaltylion/hydrogen-reference-store/blob/integrate-loyaltylion/app/lib/loyaltylion/useLoyaltylionCartUpdates.ts) which will remove the lines from the cart by submitting an action. # Integrate with Hydrogen Source: https://developers.loyaltylion.com/headless-api/guides/hydrogen/integrate > [!NOTE] > > The Headless API is included in the **Classic plan** and above. On a lower > plan, contact your LoyaltyLion account manager or [our support > team](mailto:support@loyaltylion.com) to have it enabled as an add-on. The LoyaltyLion Headless API is easy to use with Shopify Hydrogen, and lets you build customised loyalty experiences that support server-side rendering. We maintain a [reference implementation](https://github.com/loyaltylion/hydrogen-reference-store/pull/1) for Hydrogen which you can use as a starting point for your own implementation. ## Calling the Headless API > [!WARNING] > > **Only ever use API keys server-side.** Depending on its permissions, anyone > holding it can read all your customers' data and redeem rewards on their > behalf. Never send an API key to a browser, bundle it into a mobile app, or > embed it in a POS client. If it has been exposed, disable and rotate it > immediately. In Hydrogen, that means only ever using your API key from a loader or an action, which run in the Oxygen worker. Never send it to a component that renders in the browser. Store your API key as an Oxygen environment variable and read it inside your loader or action. Don't give it a `PUBLIC_` prefix — in Hydrogen that prefix marks a variable as safe to inline into the client bundle, which is exactly what must not happen to your API key. If the browser needs LoyaltyLion data, return it from a loader, or add a route of your own that the client can call. To have the browser call the Headless API directly instead, sign a [customer session token](/headless-api/session-tokens) in a loader and return that to the client; it is safe there in a way your API key never is. ### Use the `@loyaltylion/headless-api-client` library We provide a lightweight (\~4KB gzipped) TypeScript library, [@loyaltylion/headless-api-client](https://www.npmjs.com/package/@loyaltylion/headless-api-client), for interacting with the LoyaltyLion Headless API, which is the fastest way to integrate with your Hydrogen storefront. Using this library, you can quickly create a fully typed Headless API client and use it to call all Headless API endpoints. This is the option used in our [reference implementation](https://github.com/loyaltylion/hydrogen-reference-store/pull/1). The client automatically handles authentication and other subtle details such as encoding Shopify GIDs, and is fully typed out of the box. ```ts theme={null} import { createHeadlessApiClient } from '@loyaltylion/headless-api-client' const client = createHeadlessApiClient({ siteId: parseInt(process.env.LOYALTYLION_SITE_ID), apiKey: process.env.LOYALTYLION_API_KEY, channel: 'web', }) // retrieve the full site configuration const configuration = await client.getConfiguration() ``` ### Use our TypeScript typings If you'd prefer to manage your own HTTP requests, you can still use our [@loyaltylion/headless-api-client](https://www.npmjs.com/package/@loyaltylion/headless-api-client) library, as it exports a complete set of TypeScript types for use with the Headless API. ```ts theme={null} import type { CustomersInitializeSessionRequestBody, CustomersInitializeSessionResponseBody, } from '@loyaltylion/headless-api-client' const res = await fetch( `https://api.loyaltylion.com/headless/2025-06/${siteId}/customers/${encodeURIComponent(merchantId)}/sessions`, { method: 'POST', headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json', 'X-LoyaltyLion-Channel': 'web', }, body: JSON.stringify({ customer: { email: 'alice@example.com' }, } satisfies CustomersInitializeSessionRequestBody), }, ) if (!res.ok) throw new Error('API request failed') const data: CustomersInitializeSessionResponseBody = await res.json() ``` ## Loading LoyaltyLion configuration and customer data The most straightforward way to load LoyaltyLion data and pass it down to your components for rendering is to load it as *deferred* data in your root loader (`root.tsx`). Sending LoyaltyLion data down as a deferred load ensures that the rest of your page will never be blocked by LoyaltyLion. Using `Suspense` and `Await` you can wait until the data has loaded before rendering the relevant components. The exact data you need to load depends on whether a customer is logged in or not. In our reference implementation, [we have a `fetchLoyaltylionData` function](https://github.com/loyaltylion/hydrogen-reference-store/blob/integrate-loyaltylion/app/lib/loyaltylion/fetchLoyaltylionData.ts) which checks if a customer is logged in, and then calls the appropriate endpoint to load the relevant data. ### When no one is logged in When no one is logged in, the only relevant data you need to load is the Site Configuration, via the [Get Configuration](/headless-api/2025-06/configuration/get-configuration) endpoint. This includes the full set of configuration for your site and associated program in LoyaltyLion, such as the program name, tiers, rules, and rewards. You could use this to render general information about the program anywhere on the store, or on a dedicated `/rewards` page. If you're using tiers, the rules and rewards in the configuration will contain multiple `variants`, which reflect the rule and reward's configuration for each tier, e.g. if it's enabled or provides more points for a particular tier. It's up to you how you want to render these variants. In the official LoyaltyLion JS SDK, we always render the *first* enabled variant, but you could, for example, render all variants, e.g. to show prospective customers the difference between each tier. Customer objects will have `available_rules` and `available_rewards`, which are reflect the rules and rewards that are available to the customer, based on their tier. Each rule and reward will have a single `variant` (based on the tier), and a `context` object, which can be used to determine if the customer can actually interact with the rule or reward. ### When a customer is logged in > [!TIP] > > Calls to `Get Customer` and `Initialize Session` will always return the full > site configuration in the response, in addition to the customer, so you never > need to call `Get Configuration` separately if you're using either of these > endpoints. If a customer is logged in, you'll instead want to instead load data specific to the logged in customer. This can be done using the [Get Customer](/headless-api/2025-06/customers/get-customer) and [Initialize Session](/headless-api/2025-06/customers/initialize-session) endpoints. Note that the returned `customer` object may not be a member of the program. You need to check `customer.state` to determine if they are enrolled, a guest (non-member), or blocked from the program. A guest can be converted into a member with the [Enroll Customer](/headless-api/2025-06/customers/enroll-customer) endpoint, e.g. behind a "Join the program" button that you show when `customer.state` is `guest`. Don't offer it to a blocked customer — enrolling one returns a `422`. For Hydrogen, we recommend using the [Initialize Session](/headless-api/2025-06/customers/initialize-session) endpoint and calling it in the root loader. This will trigger a new call any time the page is reloaded from scratch, or when any mutation occurs (e.g. the cart changes). If you need to retrieve the customer in other loaders, we recommend using the [Get Customer](/headless-api/2025-06/customers/get-customer) endpoint instead. This endpoint is faster because it never create or update the customer in LoyaltyLion, which is fine if you're calling `Initialize Session` in the root loader (i.e. it's guaranteed to have been called at least once when a customer logged in). # Referrals Source: https://developers.loyaltylion.com/headless-api/guides/referrals > [!NOTE] > > The Headless API is included in the **Classic plan** and above. On a lower > plan, contact your LoyaltyLion account manager or [our support > team](mailto:support@loyaltylion.com) to have it enabled as an add-on. > [!WARNING] > > **Only ever use API keys server-side.** Depending on its permissions, anyone > holding it can read all your customers' data and redeem rewards on their > behalf. Never send an API key to a browser, bundle it into a mobile app, or > embed it in a POS client. If it has been exposed, disable and rotate it > immediately. The Headless API supports the full referral loop: your shoppers share their personal referral links, their friends claim the referral incentive and buy with it, and the referrer is rewarded automatically. This guide walks through the loop end to end for a headless storefront or mobile app. If you haven't read it yet, the [Referrals feature overview](/docs/features/referrals) explains how referrals work in general — this guide covers the headless-specific parts. ## How the loop fits together 1. An enrolled customer has a set of personal referral links, one per share channel 2. They share one. You [record the share](#track-shares) so it appears in referral analytics 3. Their friend opens the link, which redirects to your store with an `ll_ref_id` parameter 4. You exchange that `ll_ref_id` for a discount code using the [Claim Referee Incentive](/headless-api/2025-06/referrals/claim-referee-incentive) endpoint, and show the code to the friend 5. The friend places their first order using the code. Once that order reaches LoyaltyLion — through your platform integration, or the [Orders API](/api-reference/v2/resources/orders/create-order) on custom platforms — the two customers are linked and the referrer is rewarded, with no further referral-specific calls ## Get a customer's referral links An enrolled customer's links are on the `customer` object returned by [Get Customer](/headless-api/2025-06/customers/get-customer) and [Initialize Session](/headless-api/2025-06/customers/initialize-session), under `referral_urls`. There's one URL per channel — `direct`, `facebook`, `twitter`, `email`, `whatsapp`, `instagram` and `device_share` — and they all point to the same place; the channel only affects how the referral is categorized in analytics. Use `device_share` for a native share sheet in a mobile app, and `direct` anywhere you're unsure. `referral_urls` is `null` when referrals aren't enabled for your program. ### Referral links for guests If guest referrals are turned on in your referral settings, a shopper who hasn't joined the program can share links too. Collect their email and first name and call [Register Guest Referrer](/headless-api/2025-06/referrals/register-guest-referrer), which returns the same `referral_urls` set. The shopper isn't enrolled by this, and registering the same email again returns the same links. A guest's shares can't be recorded: [Track Share](/headless-api/2025-06/referrals/track-share) accepts enrolled customers only, so they don't appear in your share counts. Pass the shopper's own IP address, not your server's. Each shopper is rate limited on it, so forwarding your own address throttles all of them together. When a guest's friend claims the incentive, the claim is rejected with `referee_email_required` until you supply the friend's email, as described [below](#claim-the-referee-incentive). ## Handle the inbound referral link Referral links are permanent redirects. When a shopper opens one, we record the visit and redirect them to your storefront with the referral id appended: ``` https://store.example.com/?ll_ref_id=jRq0X ``` Capture the `ll_ref_id` value from the URL and hold onto it (for example in the session) — it's the input to the claim endpoint below. > [!NOTE] > > **Mobile apps and deep links:** if your app uses deep links, the OS may open > your app instead of the browser when the shopper taps a referral link. This is > fine — the redirect that carries `ll_ref_id` happens before the OS hands over > to your app, so the visit is already tracked. Your app just needs to read > `ll_ref_id` from the URL it was opened with. ## Claim the referee incentive On a storefront running the LoyaltyLion SDK, arriving with an `ll_ref_id` triggers a welcome modal offering the friend a discount code. Headless, you build that experience yourself with the [Claim Referee Incentive](/headless-api/2025-06/referrals/claim-referee-incentive) endpoint: send the `referral_id`, get back a voucher code to display. A few things to know: * **Send the shopper's IP address, not your server's.** The `ip_address` field is required and is used for referral fraud detection. Forward the address your server received the shopper's request from * **`user_agent` is also required.** Forward the shopper's user agent string; where there genuinely isn't one — such as a native mobile app — send `null` explicitly * **Send `referee_email` whenever you know it.** It binds the voucher to that shopper and lets us reject self-referrals and referrals of existing members. Without an email, those checks can't run * **Handle `referee_email_required`.** When the referrer isn't an enrolled member (a guest who signed up just to share a link), the claim is rejected with this error code until you supply the friend's email — collect it and retry * **Retries are safe.** Claiming again with the same inputs returns the same code * To describe the offer ("Get 10% off your first order"), use `referee_incentive` from the [configuration](/headless-api/2025-06/configuration/get-configuration) — it includes localized `incentive_text`, and details like the discount, any minimum spend, and any maximum discount. When the offer is limited to a collection, `collection_restriction_text` carries the merchant's description of that restriction — it isn't part of `incentive_text`, so display it alongside ## Track shares When an enrolled customer shares their link, record it with [Track Share](/headless-api/2025-06/referrals/track-share) — pass the customer and the channel they shared on. This is what populates the share counts in your referral analytics; without it, your dashboard will show referral visits and purchases but no shares. ## Attribution: how the referral completes You don't need to do anything special at checkout. When the friend's order is processed — including orders submitted through the [Orders API](/api-reference/v2/resources/orders/create-order) — LoyaltyLion matches the referral voucher code on the order, links the friend to their referrer, and triggers your referral rule. If the friend didn't use the voucher, you can still attribute the referral explicitly by passing the `ll_ref_id` value as `referral_id` on the [Create Order](/api-reference/v2/resources/orders/create-order) request, or on a `$signup` activity via [Create Activity](/api-reference/v2/resources/activities/create-activity). > [!WARNING] > > Referrals only complete on the friend's **first** order. If you import a > customer's historical orders, do so before relying on referral attribution — a > referred customer who already has other orders on record won't trigger the > referral reward. ## Custom platform stores: import voucher codes first On platforms with a discount API — Shopify, BigCommerce, Adobe Commerce — referral voucher codes are created on demand. On custom platform stores, LoyaltyLion issues codes from a pool you import in advance — so referrals won't work until codes have been uploaded, and the claim endpoint returns a `no_vouchers_available` error if the pool runs dry. Keep it topped up. # Introduction Source: https://developers.loyaltylion.com/headless-api/introduction > [!NOTE] > > The Headless API is included in the **Classic plan** and above. On a lower > plan, contact your LoyaltyLion account manager or [our support > team](mailto:support@loyaltylion.com) to have it enabled as an add-on. The LoyaltyLion Headless API can be used to build headless integrations. For example, it can be used to: * build a custom UI for a headless ecommerce storefront, e.g. Shopify Hydrogen * incorporate your loyalty program into a mobile app, using native UI components, or a custom POS system You can use Headless API endpoints to: * retrieve program configuration, including rules, rewards, and tiers * find, create, and enroll customers * redeem rewards and trigger rules for customers ## Authentication The Headless API has two authentication flows. A storefront that proxies every call through its own backend needs only the first; one that calls the API from the client uses the second, usually alongside the first. ### Server-side flow Every Headless API endpoint can be called from a server you control, using an [API key](/api-reference/authentication/api-keys) or an [OAuth access token](/api-reference/authentication/oauth). The legacy token & secret authentication method is not supported. > [!WARNING] > > **Only ever use API keys server-side.** Depending on its permissions, anyone > holding it can read all your customers' data and redeem rewards on their > behalf. Never send an API key to a browser, bundle it into a mobile app, or > embed it in a POS client. If it has been exposed, disable and rotate it > immediately. ### Client-side flow Requests made directly from a browser, mobile app or other client-owned device authenticate with a [customer session token](/headless-api/session-tokens): a credential scoped to a single site and customer, which most shopper-facing endpoints accept in place of an API key. You sign it yourself with your site's SDK token, on your backend or in Liquid on a Shopify theme, with no LoyaltyLion API call involved. ## Required request parameters Headless API endpoints require a `site_id` property in the path, and a `channel` property passed as a query parameter or header. ### Site ID All Headless API endpoints require a `site_id` in the path, e.g. `GET /headless/2025-06/{site_id}/configuration`. This is the ID of your site in LoyaltyLion. You can find it by [signing into LoyaltyLion](https://app.loyaltylion.com/login) - it's the number after the `/sites/` part of the URL, e.g. `/sites/123`. If you have a multi-site program, you can use any of the site IDs within the program to interact with the Headless API. The exception is a [customer session token](/headless-api/session-tokens), which only works with the site ID it was signed for. ### Channel Program configuration can vary based on the current channel, which will be one of `pos` (point of sale), `web` (online storefront), and `mobile` (mobile app). For example, rewards can be configured to only work on POS, in which case those rewards won't be included in the responses for any API calls where `channel=web`. The value of this parameter should match the platform in which you're using the Headless API. For example, if you're using the API inside a native mobile app, you should set the channel to `mobile`. To pass this parameter as a HTTP header, use `X-LoyaltyLion-Channel`. ## Optional request parameters Headless API endpoints also support a `language` query parameter or header, which, in combination with a multi-language site, specifies which language text should be returned in. ### Language By default, all text in Headless API responses will be returned in the associated site's default language. If you are using multi-language, you can specify the desired language when making the request. This can passed as the `language` query parameter, or as the `X-LoyaltyLion-Language` header. The value of the parameter/header must match the language code of a configured language, such as `en-gb` or `ja`. Unrecognized language codes will be ignored, and the default language will be used instead. # Customer session tokens Source: https://developers.loyaltylion.com/headless-api/session-tokens > [!NOTE] > > The Headless API is included in the **Classic plan** and above. On a lower > plan, contact your LoyaltyLion account manager or [our support > team](mailto:support@loyaltylion.com) to have it enabled as an add-on. A customer session token authenticates Headless API calls made from a shopper's own device: storefront JavaScript, a mobile app, a headless frontend. It is a credential for a single customer on a single site. You generate and sign it yourself, with no LoyaltyLion API call involved, and it authorizes only that customer's own self-serve actions, which is what makes it safe to hand to a client: even from devtools, it only lets the shopper act as themselves. That means you can call the Headless API directly from the client, instead of proxying calls through your backend first. ## Generating a token Session tokens are signed with your site's **SDK token**, which comes as a pair: a **Key ID** and a **secret**. Find both in LoyaltyLion under **Settings → General**, in the "SDK secret token" section, where the secret is labelled "Token" (not the site "Token and secret" section above it, which is a different credential and can't sign session tokens). On Shopify, the pair is also published to your shop as metafields, in the namespace Shopify reserves for the LoyaltyLion app: `app--149877--loyaltylion.secret_id` (Key ID) and `app--149877--loyaltylion.secret_key` (secret). Only LoyaltyLion can write there, which is why the namespace carries our app's ID rather than a name you would have chosen. > [!WARNING] > > Treat the secret like a password: anyone holding it can mint a session token > for any of your customers. It stays on your server or in your theme; only the > finished session token goes to the client. A session token is a base64-encoded JSON payload, a dot, and the hex HMAC-SHA256 signature of that encoded payload: ``` base64url(payload) + "." + hex(hmac_sha256(base64url(payload), secret)) ``` The comments in each recipe explain how to fill in every field: ```js JavaScript theme={null} import crypto from 'node:crypto' function createSessionToken({ keyId, secret, siteId, customerId, email, scopes, lifetimeSeconds, }) { const issuedAt = Math.floor(Date.now() / 1000) const payload = { // format version, always 2 v: 2, // your Key ID, e.g. '4821' key_id: keyId, // your LoyaltyLion site ID, e.g. 12345 site_id: siteId, // their ID in your store (= merchant_id), always a string customer_id: String(customerId), // their email address email, // when the token was issued: a unix timestamp, in seconds iat: issuedAt, // when it expires: a unix timestamp, in seconds exp: issuedAt + lifetimeSeconds, // ['read'], ['write'] or both (write does not include read) scopes, } const encoded = Buffer.from(JSON.stringify(payload)).toString('base64url') // sign with your SDK token secret const signature = crypto .createHmac('sha256', secret) .update(encoded) .digest('hex') return `${encoded}.${signature}` } // e.g. a 15-minute read+write token: const token = createSessionToken({ keyId: process.env.LOYALTYLION_SDK_TOKEN_KEY_ID, secret: process.env.LOYALTYLION_SDK_TOKEN_SECRET, siteId: 12345, customerId: '6072819304', email: 'shopper@example.com', scopes: ['read', 'write'], lifetimeSeconds: 900, }) ``` ```ruby Ruby theme={null} require 'base64' require 'json' require 'openssl' def create_session_token(key_id:, secret:, site_id:, customer_id:, email:, scopes:, lifetime_seconds:) issued_at = Time.now.to_i payload = JSON.generate({ # format version, always 2 v: 2, # your Key ID, e.g. '4821' key_id: key_id, # your LoyaltyLion site ID, e.g. 12345 site_id: site_id, # their ID in your store (= merchant_id), always a string customer_id: customer_id.to_s, # their email address email: email, # when the token was issued: a unix timestamp, in seconds iat: issued_at, # when it expires: a unix timestamp, in seconds exp: issued_at + lifetime_seconds, # ['read'], ['write'] or both (write does not include read) scopes: scopes, }) encoded = Base64.urlsafe_encode64(payload, padding: false) # sign with your SDK token secret signature = OpenSSL::HMAC.hexdigest('SHA256', secret, encoded) "#{encoded}.#{signature}" end # e.g. a 15-minute read+write token: token = create_session_token( key_id: ENV['LOYALTYLION_SDK_TOKEN_KEY_ID'], secret: ENV['LOYALTYLION_SDK_TOKEN_SECRET'], site_id: 12345, customer_id: '6072819304', email: 'shopper@example.com', scopes: ['read', 'write'], lifetime_seconds: 900, ) ``` ```php PHP theme={null} function create_session_token($key_id, $secret, $site_id, $customer_id, $email, $scopes, $lifetime_seconds) { $issued_at = time(); $payload = json_encode([ // format version, always 2 'v' => 2, // your Key ID, e.g. '4821' 'key_id' => $key_id, // your LoyaltyLion site ID, e.g. 12345 'site_id' => $site_id, // their ID in your store (= merchant_id), always a string 'customer_id' => (string) $customer_id, // their email address 'email' => $email, // when the token was issued: a unix timestamp, in seconds 'iat' => $issued_at, // when it expires: a unix timestamp, in seconds 'exp' => $issued_at + $lifetime_seconds, // ['read'], ['write'] or both (write does not include read) 'scopes' => $scopes, ]); $encoded = rtrim(strtr(base64_encode($payload), '+/', '-_'), '='); // sign with your SDK token secret $signature = hash_hmac('sha256', $encoded, $secret); return $encoded . '.' . $signature; } // e.g. a 15-minute read+write token: $token = create_session_token(getenv('LOYALTYLION_SDK_TOKEN_KEY_ID'), getenv('LOYALTYLION_SDK_TOKEN_SECRET'), 12345, '6072819304', 'shopper@example.com', ['read', 'write'], 900); ``` The JSON formatting is yours: we verify the exact encoded string you sign, so key order and whitespace don't matter, either base64 alphabet works (padded or unpadded), and the hex signature can be upper or lower case. ### On Shopify with Liquid, no backend needed On a regular Shopify storefront, Liquid's rendering step is the server-side step: it reads the SDK token from the shop metafields and emits only the finished session token. Add this to your theme layout or loyalty template, replacing `123456` with your LoyaltyLion site ID: ```liquid theme={null} {% if customer != nil and customer.has_account %} {%- assign ll_site_id = 123456 -%} {%- capture ll_key_id -%}{{ shop.metafields["app--149877--loyaltylion"].secret_id }}{%- endcapture -%} {%- capture ll_secret -%}{{ shop.metafields["app--149877--loyaltylion"].secret_key }}{%- endcapture -%} {%- assign ll_iat = 'now' | date: '%s' -%} {%- assign ll_exp = ll_iat | plus: 1209600 -%} {%- capture ll_payload -%}{"v":2,"key_id":"{{ ll_key_id }}","site_id":{{ ll_site_id }},"customer_id":"{{ customer.id }}","email":{{ customer.email | json }},"iat":{{ ll_iat }},"exp":{{ ll_exp }},"scopes":["read","write"]}{%- endcapture -%} {%- assign ll_encoded = ll_payload | base64_url_safe_encode -%} {%- assign ll_signature = ll_encoded | hmac_sha256: ll_secret -%} {% endif %} ``` Three details that matter here: * **Keep the whitespace control (`{%-` / `-%}`) exactly as shown**: a newline captured into the secret corrupts it. * **`customer.id` is quoted** because `customer_id` must be a string, and **`| json` on the email** escapes anything that would break the JSON. * **`1209600` is the 14-day Shopify cap** (see [Lifetime](#lifetime)); a shorter lifetime risks logging shoppers out on cached pages. Then use `window.loyaltylionSessionToken` from your storefront JavaScript. > [!NOTE] > > If your store runs the [LoyaltyLion JS SDK](/sdk/overview), your storefront > JavaScript can use the same token for its own Headless API calls. ### In a mobile app > [!WARNING] > > Never embed the SDK token secret in an app build. Anything in the binary can > be extracted, and anyone holding the secret can mint a session token for any > of your customers. Have your backend authenticate the shopper and return a freshly minted session token on every launch and every login, and again on [`token_expired`](#errors). Don't bake a token into a build or store one across sessions: it names one customer and stops working within days. ## The payload ```json theme={null} { "v": 2, "key_id": "4821", "site_id": 12345, "customer_id": "6072819304", "email": "shopper@example.com", "iat": 1756200000, "exp": 1757409600, "scopes": ["read", "write"] } ``` | Field | Type | Description | | - | - | - | | `v` | number | Format version, always `2`. | | `key_id` | string | Your Key ID. A bare number is also accepted and treated as its decimal string. | | `site_id` | number | Your LoyaltyLion site ID. Must match the request path. | | `customer_id` | string | The customer's ID in your store, the same `merchant_id` you use elsewhere. Always a string. | | `email` | string | The customer's email address. Must be valid; Initialize Session creates the customer with it. | | `iat` | number | When the token was issued, in seconds since the Unix epoch. | | `exp` | number | When the token stops working, in seconds since the Unix epoch. See [Lifetime](#lifetime). | | `scopes` | array of strings | At least one of `read`, `write`. See [Scopes](#scopes). | Every field is required and unknown fields are rejected, so a typo fails the token the first time you test, not months later. ## Scopes There are two scopes, and they are independent: `write` does not include `read`, so a token that both reads loyalty state and performs actions must list both. | Scope | Authorizes | | - | - | | `read` | Reading the customer's own loyalty state and your site configuration. | | `write` | The supported self-serve actions: enrolling, setting a birthday, subscribing to email marketing, redeeming and refunding rewards, and completing interactive rules. | Grant only the scopes the client needs: a points-balance widget should be issued `["read"]`, so a copied token can't redeem. ### Which endpoints accept a session token | Endpoint | Scope | | - | - | | **Get Configuration**: `GET /{site_id}/configuration` | `read` | | **Get Customer**: `GET /{site_id}/customers/{merchant_id}` | `read` | | **Initialize Session**: `POST /{site_id}/customers/{merchant_id}/sessions` | `write` | | **Enroll Customer**: `POST /{site_id}/customers/{merchant_id}/enroll` | `write` | | **Set Birthday**: `POST /{site_id}/customers/{merchant_id}/birthday` | `write` | | **Subscribe to Email Marketing**: `POST /{site_id}/customers/{merchant_id}/email_marketing/subscribe` | `write` | | **Redeem a reward**: `POST /{site_id}/rewards/{type}/redeem`, for all nine reward types | `write` | | **Refund a product-to-cart reward**: `POST /{site_id}/rewards/product_cart/refund` | `write` | | **Complete a rule**: `POST /{site_id}/rules/{type}/complete`, for `clickthrough`, `facebook_like`, `instagram_follow`, `tiktok_follow` and `twitter_follow` | `write` | Initialize Session is the one endpoint that creates the customer when LoyaltyLion doesn't hold them yet, so a storefront can run entirely on session tokens. The customer is created from the token's **signed claims**, never the request body. The body's `customer.email` must still match the signed email (case-insensitively) or the request fails with `email_mismatch`. Everything else needs an API key and stays server-side: completing a custom rule, the referrals endpoints, and every Admin API (`/v2/*`) endpoint. A session token sent to any of those is rejected with a `401` that says `Session tokens are not supported on this route`. On **Redeem a custom reward**, the `fulfill_immediately` and `usage` options are merchant-side controls and are rejected with a `403` under a session token. ## Moving a browser call off the Admin API A session token can't replace an Admin API (`/v2/*`) call; those stay API-key-only. If your storefront calls one directly today, there are two routes off it. **The Headless API already has it.** One Get Customer call covers most of what a storefront reads per shopper, so several `/v2/*` calls usually collapse into it: | Currently calling | Read instead from `GET /{site_id}/customers/{merchant_id}` | | - | - | | `GET /v2/customers`, paged to find one shopper | the response itself | | `GET /v2/customers/{merchant_id}/transactions` | `history` (but see below) | | `GET /v2/customers/{merchant_id}/available_rewards` | `available_rewards` | | points balances | `points_approved`, `points_pending`, `points_spent` | | tier | `tier_membership` | There is no per-customer read on the Admin API, so a storefront showing one shopper their points is paging the whole customer list to find them. Headless Get Customer replaces that outright: the session token already names the customer in its signed claims, so there is no list to search and no way to ask for anyone else. `history` is not the transactions list under another name. A single history action can cover several transactions: points added and later voided are one entry whose state changes, not two rows. If your page renders a transaction ledger, check it against `history` before switching. Writes have equivalents too: claiming a reward is `POST /{site_id}/rewards/{type}/redeem` under `write` scope. **Nothing equivalent exists.** Then the call belongs on your server with an API key, and your storefront asks your server rather than us. `POST /v2/activities` is the usual case, and deliberately so: an activity a shopper's own browser can submit is an activity a shopper can fabricate. ## Lifetime `exp` is required; there is no default lifetime. We clamp rather than reject: a token stops working at its own `exp` or `iat` plus the cap, whichever comes first. | Site platform | Cap | | - | - | | Shopify | 14 days | | Everything else | 1 day | The cap follows the site the token is for, not where it is minted: a backend-minted token for a Shopify site still gets the 14-day cap. * `exp` must be later than `iat`. * `iat` more than 5 minutes in the future invalidates the token. If one server's tokens are rejected while others work, check its clock. Issue the shortest lifetime that fits: minutes from a backend minting per session; the full 14 days from a Shopify theme, because Shopify serves cached pages (including any token rendered into them) for far longer than a day. ## Using a token Send the token as a bearer token on any endpoint that accepts one: ``` GET https://api.loyaltylion.com/headless/2025-06/12345/customers/6072819304?channel=web Authorization: Bearer ``` From a browser, pass `channel` (and `language`, if you use it) as query parameters, as here: the CORS preflight doesn't allow the equivalent `X-LoyaltyLion-*` headers on a cross-origin request. The token has to agree with the request: the `site_id` in the path must be the one it was signed with, and any customer the request names (`merchant_id` in the path, or `customer_merchant_id` in the body) must be its customer. Requests are rate limited per customer, so one shopper can't exhaust your site's budget, and CORS preflights are answered with `Access-Control-Allow-Origin: *`, so a browser can call the API directly. ## Errors Rejections are almost always a `401`. A `403` means something narrower: the token is fine, but doesn't authorize this particular request; see [the `403`s](#403s). Two rejections specific to session tokens carry a machine-readable `code` your client should branch on: ```json token_expired (401) theme={null} { "error": { "code": "token_expired", "message": "Session token has expired. Fetch a fresh session token from your backend and retry the request" } } ``` ```json insufficient_scope (403) theme={null} { "error": { "code": "insufficient_scope", "message": "Requires scope [write] but session token only has scopes [read]" } } ``` Handle `token_expired` by getting a fresh token and retrying once. Don't retry on `insufficient_scope`: the fix is in the code that issues the token. Other token-validation failures are a `401` with no code: ```json theme={null} { "error": { "message": "Session token is invalid. Please check the format is correct: https://developers.loyaltylion.com/headless-api/session-tokens [INVALID_SIGNATURE]" } } ``` The tag in brackets says which check failed: | Tag | Meaning | | - | - | | `MALFORMED` | The payload half isn't decodable JSON. A bearer without the `.` shape at all isn't treated as a session token and fails as a generic invalid credential instead. | | `INVALID_CLAIMS` | The payload is missing a field, has an unknown one, or `exp` is not after `iat`. | | `SITE_MISMATCH` | The token's `site_id` isn't the site in the request path. | | `UNKNOWN_KEY` | The `key_id` names no active SDK token for this site, usually a rotated or mistyped Key ID. | | `RESERVED_KEY_NAMESPACE` | The `key_id` starts with `lion_`, which is reserved for keys we hold. | | `INVALID_SIGNATURE` | The signature doesn't match the payload under that key. | | `ISSUED_IN_FUTURE` | `iat` is further ahead than clock skew explains. Check the issuing server's clock. | The signature is checked before the timestamps, so a token that is both mis-signed and expired reports `INVALID_SIGNATURE`, not `token_expired`. Some `401`s carry no tag. The two worth knowing: a site in the request path that doesn't exist (deliberately indistinguishable from an invalid token, so site IDs can't be enumerated), and a verified token naming a customer LoyaltyLion doesn't hold. Only Initialize Session creates customers, so everywhere else the signed `customer_id` must be a customer we already hold. A token sent to a route that doesn't accept one is also an untagged `401`; see [which endpoints accept a session token](#which-endpoints-accept-a-session-token). ### 403s A `403` always means the token verified. The causes are: * `insufficient_scope`, above. * The request names a different customer than the token was signed for. * Redeem a custom reward was called with `fulfill_immediately` or `usage`. * The site has been uninstalled, or its LoyaltyLion subscription is inactive. * `plan_required`: your plan doesn't include the Headless API. It isn't specific to session tokens; see [Errors](/headless-api/errors).