> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt ## Resource: Introduction ## Article: Introduction ## Article Link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/earning-rules/introduction.md ## Article Content: # About the Earning Rules API The Earning Rules API allows you to manage earning rules for your loyalty program. Earning rules define how customers earn points through various activities, such as making purchases or registering for events. With the Earning Rules API, you can: + [Create loyalty earning rules](https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/earning-rules/create-loyalty-earning-rule.md) to set up new rules for earning points. + [List earning rules](https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/earning-rules/list-earning-rules.md) to retrieve all earning rules in your loyalty program. + [Bulk create loyalty earning rules](https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/earning-rules/bulk-create-loyalty-earning-rules.md) to set up multiple earning rules at once. + [Update loyalty earning rules](https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/earning-rules/update-loyalty-earning-rule.md) to modify existing earning rules. + [Delete loyalty earning rules](https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/earning-rules/delete-loyalty-earning-rule.md) to remove earning rules that are no longer needed. + [Delete automation earning rules](https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/earning-rules/delete-automation-earning-rule.md) to remove automated earning rules. To learn more about earning rules, see [Managing Your Loyalty Program](https://support.wix.com/en/article/wix-loyalty-program-managing-your-loyalty-program#updating-how-customers-earn-loyalty-points). ## Before you begin It's important to note the following before starting to code: + The API supports both automated and non-automated earning rules. + A site must have the [Wix Loyalty Program](https://www.wix.com/app-market/loyalty) installed to use this API. ## Types of earning rules The Wix Loyalty program supports two types of earning rules: + Automated earning rules + Non-automated earning rules Both types allow customers to earn points for various actions, but differ in their creation, management, and customization options. ### Automated earning rules Automated earning rules are enabled by Wix Automations. There are two subtypes: + Pre-installed earning rules + Custom earning rules #### Pre-installed rules Pre-installed rules appear automatically when certain business solutions are installed. These rules can be disabled but not deleted. | Earning Rule Name | Activity Type | Supported Types | |-----------|---------------|-----------------| | Order a plan (Wix Pricing Plans) | `wix_pricing_plans-plan_purchased` | Fixed amount, Conversion rate | | Place a restaurant order (Legacy Wix Restaurants) | `wix_restaurants_orders-order_submitted` | Conversion rate only | | Place a restaurant order (New Wix Restaurants) | `restaurants-order-is-pending` | Conversion rate only | #### Custom rules Custom rules are created by Wix users and don't come pre-installed. All automated earning rules not listed above fall into this category. ### Non-Automated earning rules Non-automated earning rules can be created based on installed Wix business solutions. These rules are identified by their `sourceAppId`, which differs from automated earning rule `sourceAppId`. Supported non-automated earning rules: | Earning Rule Name | Activity Type | Supported Types | |-----------|---------------|-----------------| | Purchase a product (Wix Stores) | `stores/OrderPaid` | Fixed amount, Conversion rate | | Book a session (Wix Bookings) | `bookings/BookingConfirmed` | Fixed amount only | | Buy a ticket (Wix Events) | `events/OrderConfirmed` | Fixed amount, Conversion rate | | RSVP to an event (Wix Events) | `events/Rsvp` | Not specified | For example, if you have Wix Events installed, you can create an earning rule that is triggered when a customer buys a ticket or RSVPs to an event. ## Points calculation Earning rules can award points in two ways: + **Fixed Amount**: A set number of points is awarded for a specific action. For example, a customer might receive 10 points for purchasing a ticket through Wix Events. + **Conversion Rate**: Points are awarded based on a ratio of money spent to points earned. For example, a customer might receive 10 points for every $1 spent. The formula is: `(amount spent) / (moneyAmount * points)`. ## Use cases - [Build tiered earning systems with progressive rates](https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/earning-rules/sample-use-cases-and-flows.md) ## Terminology + __Earning rule__: A condition that, when met, awards loyalty points to a customer. All earning rules allow customers to earn points for performing certain actions, without a minimum spending requirement. + __Non-automated earning rule__: An earning rule set up for specific business solutions, identified by its `sourceAppId`. + __Automated earning rule__: An earning rule enabled by Wix Automations, which can be pre-installed or custom: - __Pre-installed__: An automated earning rule that comes by default with certain services, which can be disabled but not deleted. - __Custom__: An automated earning rule created by the Wix user, not pre-installed by default. + __Fixed amount__: An earning rule type where a set number of points is awarded for a specific action. For example, a customer might receive 10 points for purchasing a ticket through Wix Events. + __Conversion rate__: An earning rule type where points are awarded based on a ratio of money spent to points earned. The formula is: `[amount spent] / moneyAmount * points`. + __Trigger app ID__: The ID of the app that initiates the point assignment. For example: Stores, Bookings, Events. + __Trigger activity type__: The specific action that triggers point assignment. For example: `"auth/register"`, `"events/OrderConfirmed"`. + __Source app ID__: The ID of the app managing the rule, which can be either the Loyalty app ID or an Automations app ID. + __Tier__: A tier is a loyalty level that customers are assigned to based on the amount of points they earn. Customers in different tiers may earn points at different rates for the same activity. For example, a higher tier member might earn more points per purchase than a lower tier member. + __Status__: The current status of an earning rule, `"ACTIVE"` or `"PAUSED"`. @sdk_package_setup