---
title: "List Earning Rules"
method: GET
path: "/v1/loyalties/{campaignId}/earning-rules"
tags: ["Loyalties"]
---

# List Earning Rules

`GET /v1/loyalties/{campaignId}/earning-rules`

Returns a list of all earning rules within a given campaign.

## Query parameters

- `limit` integer
- `page` integer
- `order` 'created_at' | '-created_at' | 'updated_at' | '-updated_at'

## Response `200`

Returns a list of earning rules.

- LoyaltiesEarningRulesListResponseBody — Response body schema for listing earning rules using **GET** `v1/loyalties/{campaignId}/earning-rules` endpoint.
  - `object` 'list' — The type of the object represented by JSON. This object stores information about earning rules in a dictionary.
  - `data_ref` string — Identifies the name of the attribute that contains the array of earning rule objects.
  - `data` EarningRule[] — Contains array of earning rule objects.
    - `id` string, required — Assigned by the Voucherify API, identifies the earning rule object.
    - `created_at` string, date-time, required — Timestamp representing the date and time when the earning rule was created. The value is shown in the ISO 8601 format.
    - `loyalty` union, required
      - EarningRuleFixed
        - `type` 'FIXED', required — The number of points to be added to the loyalty card.
        - `points` integer, required — Defines how the points will be added to the loyalty card. FIXED adds a fixed number of points.
        - `points_formula` string — Formula used to dynamically calculate the rewarded points.
      - union
        - union
          - EarningRuleProportionalOrderAmount
            - `type` 'PROPORTIONAL', required — Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio.
            - `calculation_type` 'ORDER_AMOUNT', required — `ORDER_AMOUNT`: Pre-discount order amount (X points for every Y spent excluding discounts)
            - `order` object, required
              - …
          - EarningRuleProportionalOrderTotalAmount
            - `type` 'PROPORTIONAL', required — Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio.
            - `calculation_type` 'ORDER_TOTAL_AMOUNT', required — `ORDER_TOTAL_AMOUNT`: Total order amount (X points for every Y spent including discount)
            - `order` object, required
              - …
          - EarningRuleProportionalOrderMetadata
            - `type` 'PROPORTIONAL', required — Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio.
            - `calculation_type` 'ORDER_METADATA', required — `ORDER_METADATA`: Order Metadata (X points for every Y in metadata attribute, defined in the property key under the order.metadata object)
            - `order` object, required — Defines the formula for calculating points proportionally.
              - …
        - union
          - EarningRuleProportionalOrderItemsQuantity
            - `type` 'PROPORTIONAL', required — Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio.
            - `calculation_type` 'ORDER_ITEMS_QUANTITY', required — `ORDER_ITEMS_QUANTITY`: Quantity of items defined in the `order_items.quantity.applicable_to` array or `order_items.quantity.object` & `.id` (X points for every Y items excluding free items).
            - `order_items` object, required
              - …
          - EarningRuleProportionalOrderItemsAmount
            - `type` 'PROPORTIONAL', required — Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio.
            - `calculation_type` 'ORDER_ITEMS_AMOUNT', required — ORDER_ITEMS_AMOUNT; Pre-discount amount spent on items defined in the `order_items.quantity.applicable_to` array or `order_items.quantity.object` & `.id` (X points for every Y spent on items excluding discounts)
            - `order_items` object, required
              - …
          - EarningRuleProportionalOrderItemsSubtotalAmount
            - `type` 'PROPORTIONAL', required — Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio.
            - `calculation_type` 'ORDER_ITEMS_SUBTOTAL_AMOUNT', required — ORDER_ITEMS_SUBTOTAL_AMOUNT; Amount spent on items defined in the order_items.subtotal_amount.object & .id (X points for every Y spent on items including discounts)
            - `order_items` object, required
              - …
        - EarningRuleProportionalCustomerMetadata
          - `type` 'PROPORTIONAL', required — Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio.
          - `calculation_type` 'CUSTOMER_METADATA', required — CUSTOMER_METADATA: Customer Metadata (X points for every Y in metadata attribute, defined in the property key under the customer.metadata object)
          - `customer` object, required
            - `metadata` object, required — Defines the ratio based on the property defined in the calculation_type parameter. For every given increment of value (1, 10, etc) defined in the every parameter for the property defined in calculation_type, give the customer the number of points defined in the points parameter. In other words, for every order metadata property value, give points.
              - …
        - EarningRuleProportionalCustomEvent
          - `type` 'PROPORTIONAL', required — Defines how the points will be added to the loyalty card.PROPORTIONAL adds points based on a pre-defined ratio.
          - `calculation_type` 'CUSTOM_EVENT_METADATA', required — CUSTOM_EVENT_METADATA: Custom event metadata (X points for every Y in metadata attribute).
          - `custom_event` object, required
            - `metadata` object, required — Defines the ratio based on the property defined in the calculation_type parameter. For every given increment of value (1, 10, etc) defined in the every parameter for the property defined in calculation_type, give the customer the number of points defined in the points parameter. In other words, for every order metadata property value, give points.
              - …
    - `event` string
    - `custom_event` object — Contains details about the custom event.
      - `schema_id` string, required — Unique identifier of the custom event schema
    - `segment` object — Contains the ID of a customer segment. Required for the `customer.segment.entered` option in the event.
      - `id` string, required — Contains a unique identifier of a customer segment. Assigned by the Voucherify API.
    - `loyalty_tier` object — Defines the tier associated with the earning rule definition.
      - `id` string — Unique loyalty tier ID associated with the earning rule. - `__ANY__`: any loyalty tier within the campaign
    - `pending_points` object — Defines the configuration for pending points. Pending points can be used only with the `order.paid` event.
      - `period_type` 'DAY' — Defines the type of the period during which the points are in the pending state. Currently, only `DAY` value is accepted.
      - `period_value` integer — Defines for how long the points are in the pending state. The minimum value is 1, maximum is 90.
    - `source` object, required — Contains the custom earning rule name and parent campaign.
      - `banner` string — Name of the earning rule. This is displayed as a header for the earning rule in the Dashboard.
      - `object_id` string, required — A unique campaign identifier assigned by the Voucherify API.
      - `object_type` 'campaign', required — Defines the object associated with the earning rule. Defaults to `campaign`.
    - `object` 'earning_rule', required — The type of the object represented by JSON. Default is earning_rule.
    - `automation_id` string, required — For internal use by Voucherify.
    - `start_date` string — Start date defines when the earning rule starts to be active. Activation timestamp is presented in the ISO 8601 format. The earning rule is inactive before this date. If you do not define the start date for an earning rule, it will inherit the campaign start date by default.
    - `expiration_date` string — Expiration date defines when the earning rule expires. Expiration timestamp is presented in the ISO 8601 format. The earning rule is inactive after this date. If you do not define the expiration date for an earning rule, it will inherit the campaign expiration date by default.
    - `validity_timeframe` ValidityTimeframe — Set recurrent time periods when the earning rule is valid. For example, valid for 1 hour every other day.`start_date` **required** when including the `validity_timeframe`.
      - `duration` string — Defines the amount of time an earning rule will be active in ISO 8601 format. For example, an earning rule with a `duration` of `PT1H` will be valid for a duration of one hour.
      - `interval` string — Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, an earning rule with an `interval` of `P2D` will be valid every other day.
    - `validity_day_of_week` integer[] — Integer array corresponding to the particular days of the week in which the voucher is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday
    - `validity_hours` ValidityHours — Determines the hours of validity, e.g. to create a happy hours scenario.
      - `daily` object[] — Defines the recurring period(s) when the resource is active. The periods should not overlap.
        - `start_time` string, time — Defines the starting hour of validity in the HH:mm format. The resource is *inactive before* this time.
        - `days_of_week` integer[] — Integer array corresponding to the particular days of the week in which the resource is valid. - `0` Sunday - `1` Monday - `2` Tuesday - `3` Wednesday - `4` Thursday - `5` Friday - `6` Saturday
        - `expiration_time` string, time — Defines the ending hour of validity in the HH:mm format. The resource is *inactive after* this time.
    - `metadata` object, required — The metadata object stores all custom attributes assigned to the earning rule. A set of key/value pairs that you can attach to an earning rule object. It can be useful for storing additional information about the earning rule in a structured format.
    - `expiration_rules` EarningRuleExpirationRules — Defines the loyalty point expiration rule. This expiration rule applies only to this earning rule and supersedes `expiration_rules` defined in the `voucher.loyalty_card` object.
      - `period_type` 'FIXED_DAY_OF_YEAR' | 'MONTH', required — Type of period. Can be set for `MONTH` or `FIXED_DAY_OF_YEAR`. `MONTH` requires the `period_value` field. `FIXED_DAY_OF_YEAR` requires the `fixed_month` and `fixed_day` fields.
      - `period_value` integer — Value of the period. Required for the `period_type: MONTH`.
      - `rounding_type` 'END_OF_MONTH' | 'END_OF_QUARTER' | 'END_OF_HALF_YEAR' | 'END_OF_YEAR' | 'PARTICULAR_MONTH' — Type of rounding of the expiration period. Optional for the `period_type: MONTH`.
      - `rounding_value` integer — Value of rounding of the expiration period. Required for the `rounding_type`.
      - `fixed_month` integer — Determines the month when the points expire; `1` is January, `2` is February, and so on. Required for the `period_type: FIXED_DAY_OF_YEAR`.
      - `fixed_day` integer — Determines the day of the month when the points expire. Required for the `period_type: FIXED_DAY_OF_YEAR`.
    - `validation_rule_id` string, nullable, required — A unique validation rule identifier assigned by the Voucherify API. The validation rule is verified before points are added to the balance.
    - `updated_at` string, date-time, nullable, required — Timestamp representing the date and time when the earning rule was last updated in ISO 8601 format.
    - `active` boolean, required — A flag to toggle the earning rule on or off. You can disable an earning rule even though it's within the active period defined by the start_date and expiration_date of the campaign or the earning rule's own start_date and expiration_date. - `true` indicates an active earning rule - `false` indicates an inactive earning rule
  - `total` integer — Total number of earning rule objects.

---

[API](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions.md) · [All operations](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/voucherifyio/voucherify-api-async-actions/versions/4982266e0494/schema)
