> ## Documentation Index
> Fetch the complete documentation index at: https://docs.voucherify.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Earning Rule

> Retrieves an earning rule assigned to a campaign.



## OpenAPI

````yaml /openapi/loyalties.json get /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}
openapi: 3.0.1
info:
  title: Voucherify API - Loyalties
  version: v2018-08-01
  description: >-
    Voucherify promotion engine REST API. Please see
    https://docs.voucherify.io/docs for more details.
  contact:
    name: Voucherify Team
    url: https://www.voucherify.io/contact-support
    email: support@voucherify.io
  termsOfService: https://www.voucherify.io/legal/subscription-agreement
  license:
    name: MIT
    url: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE
servers:
  - url: https://{cluster}.voucherify.io
    description: Base URL
    variables:
      cluster:
        default: api
        enum:
          - api
          - us1.api
          - as1.api
          - download
          - us1.download
          - as1.download
security: []
paths:
  /v1/loyalties/{campaignId}/earning-rules/{earningRuleId}:
    parameters:
      - schema:
          $ref: '#/components/schemas/ParameterCampaignId'
        name: campaignId
        in: path
        required: true
        description: >-
          The campaign ID or name of the loyalty campaign. You can either pass
          the campaign ID, which was assigned by Voucherify, or the `name` of
          the campaign as the path parameter value, e.g., `Loyalty%20Campaign`. 
      - schema:
          $ref: '#/components/schemas/ParameterEarningRuleId'
        name: earningRuleId
        in: path
        required: true
        description: A unique earning rule ID.
    get:
      tags:
        - Loyalties
      summary: Get Earning Rule
      description: Retrieves an earning rule assigned to a campaign.
      operationId: get-earning-rule
      parameters: []
      responses:
        '200':
          description: Returns an earning rule object with the earning rule details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LoyaltiesEarningRulesGetResponseBody'
              examples:
                Custom Event:
                  value:
                    id: ern_abvbD0d7Wv4hgr3fTElLb38G
                    created_at: '2022-02-07T08:19:41.810Z'
                    updated_at: null
                    validation_rule_id: null
                    loyalty:
                      points: 2
                      type: FIXED
                    custom_event:
                      schema_id: ms_7JRYC8jXbezBV8AvGYGA0b5R
                    event: saw_on_facebook
                    source:
                      banner: Saw on Facebook Timeframe
                      object_id: camp_Pfja7X91b1GoyH5wnpzCwlP3
                      object_type: campaign
                    active: true
                    start_date: '2022-02-07T08:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    object: earning_rule
                    automation_id: auto_WTxNMXGJMS5ZdU9oZip3AzuA
                Order Paid:
                  value:
                    id: ern_taClaOIiaGNdmdby8xS0lCcy
                    created_at: '2022-02-04T13:27:50.665Z'
                    updated_at: '2022-02-07T08:19:44.198Z'
                    validation_rule_id: null
                    loyalty:
                      points: 1000
                      type: FIXED
                    event: order.paid
                    source:
                      banner: Order paid 1000 points
                      object_id: camp_Pfja7X91b1GoyH5wnpzCwlP3
                      object_type: campaign
                    active: true
                    start_date: '2022-02-02T13:00:00.000Z'
                    expiration_date: '2022-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 4
                    object: earning_rule
                    automation_id: auto_RjBuwpeFQZ7TyQ5LP2LFVZYG
                Segment Entered:
                  value:
                    id: ern_3HlFKLMNIfBme9lcHwnMwXON
                    created_at: '2022-02-04T13:02:52.937Z'
                    updated_at: '2022-02-07T08:19:43.291Z'
                    validation_rule_id: null
                    loyalty:
                      points: 1000
                      type: FIXED
                    segment:
                      id: seg_WJv55MbzQwnr56ttJ2xUrSgt
                    event: customer.segment.entered
                    source:
                      banner: Entered segment 100 points.
                      object_id: camp_Pfja7X91b1GoyH5wnpzCwlP3
                      object_type: campaign
                    active: true
                    start_date: '2022-02-02T13:00:00.000Z'
                    expiration_date: '2022-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    object: earning_rule
                    automation_id: auto_39wqQSScJJbvpzAF611jnrh9
                Loyalty Tier Joined:
                  value:
                    id: ern_gVo6CHBduFPoh1hctASfXHLT
                    created_at: '2022-11-24T17:01:42.809Z'
                    updated_at: null
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: CUSTOMER_METADATA
                      customer:
                        metadata:
                          every: 4
                          points: 4
                          property: customer_life_time_value
                    event: customer.loyalty.tier.joined
                    loyalty_tier:
                      id: ltr_pudTGWasuIqxdiDM0go31OV1
                    source:
                      banner: Tier joined
                      object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                      object_type: campaign
                    active: true
                    object: earning_rule
                    automation_id: auto_wdlEo17wmoqYHGfilbayEUj7
                    metadata:
                      Type: Tier joined - customer metadata - proportional
                Loyalty Tier Left:
                  value:
                    id: ern_66OdCyLADv5IGFoQe18vGUwa
                    created_at: '2022-11-24T17:03:59.414Z'
                    updated_at: null
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: CUSTOMER_METADATA
                      customer:
                        metadata:
                          every: 2
                          points: 2
                          property: customer_life_time_value
                    event: customer.loyalty.tier.left
                    loyalty_tier:
                      id: ltr_7rVIPlPzdSFwpnbCcUXgwzH2
                    source:
                      banner: Tier left
                      object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                      object_type: campaign
                    active: true
                    object: earning_rule
                    automation_id: auto_czm5el1Uz1jeGaO97AYoDNAq
                    metadata:
                      Type: Tier left
                Loyalty Tier Upgraded:
                  value:
                    id: ern_YR3fDfCjAmz9a5D68nk0i4dm
                    created_at: '2022-11-25T07:29:38.961Z'
                    updated_at: null
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: CUSTOMER_METADATA
                      customer:
                        metadata:
                          every: 3
                          points: 4
                          property: customer_life_time_value
                    event: customer.loyalty.tier.upgraded
                    loyalty_tier:
                      id: ltr_30KHciA0UG8B71Fo51GZqwgN
                    source:
                      banner: Tier upgraded
                      object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                      object_type: campaign
                    active: true
                    object: earning_rule
                    automation_id: auto_M1OdRH8spk6Fs7yTuPLN2LAv
                    metadata:
                      Type: Upgraded
                Loyalty Tier Downgraded:
                  value:
                    id: ern_A2RArBE30Tkt56utVLrRv7rZ
                    created_at: '2022-11-25T07:31:05.866Z'
                    updated_at: '2022-11-25T07:31:43.029Z'
                    validation_rule_id: val_kfmWpfXMI9P1
                    loyalty:
                      points: 1
                      type: FIXED
                    event: customer.loyalty.tier.downgraded
                    loyalty_tier:
                      id: __ANY__
                    source:
                      banner: Tier Downgraded
                      object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                      object_type: campaign
                    active: true
                    object: earning_rule
                    automation_id: auto_TMVZtCNMBgZm0KcPJ7otiHZW
                    metadata:
                      Type: Tier
                Loyalty Tier Prolonged:
                  value:
                    id: ern_AdlWO2yt6b6llWsibIdiRXVE
                    created_at: '2022-11-25T07:31:42.767Z'
                    updated_at: null
                    validation_rule_id: null
                    loyalty:
                      points: 5
                      type: FIXED
                    event: customer.loyalty.tier.prolonged
                    loyalty_tier:
                      id: __ANY__
                    source:
                      banner: Prolonged
                      object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                      object_type: campaign
                    active: true
                    object: earning_rule
                    automation_id: auto_4jH1yq9WJS0oJ8suagCrltyb
                    metadata: {}
      security:
        - X-App-Id: []
          X-App-Token: []
        - X-Voucherify-OAuth:
            - api
            - loyalties
components:
  schemas:
    ParameterCampaignId:
      type: string
      example: camp_rRsfatlwN7unSeUIJDCYedal
    ParameterEarningRuleId:
      type: string
      example: ern_CFuv1O0IDl8Jgph0ojhMu8bH
    LoyaltiesEarningRulesGetResponseBody:
      type: object
      title: Loyalties Earning Rules Get Response Body
      description: >-
        Response body schema for **GET**
        `v1/loyalties/{campaignId}/earning-rules/{earningRuleId}`.
      allOf:
        - $ref: '#/components/schemas/EarningRule'
    EarningRule:
      title: Earning Rule
      allOf:
        - $ref: '#/components/schemas/EarningRuleBase'
        - type: object
          properties:
            validation_rule_id:
              type: string
              nullable: true
              description: >-
                A unique validation rule identifier assigned by the Voucherify
                API. The validation rule is verified before points are added to
                the balance.
            updated_at:
              type: string
              nullable: true
              format: date-time
              description: >-
                Timestamp representing the date and time when the earning rule
                was last updated in ISO 8601 format.
            active:
              type: boolean
              description: >-
                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
          required:
            - validation_rule_id
            - updated_at
            - active
    EarningRuleBase:
      title: EarningRuleBase
      type: object
      properties:
        id:
          type: string
          description: Assigned by the Voucherify API, identifies the earning rule object.
        created_at:
          type: string
          format: date-time
          description: >-
            Timestamp representing the date and time when the earning rule was
            created. The value is shown in the ISO 8601 format.
        loyalty:
          oneOf:
            - $ref: '#/components/schemas/EarningRuleFixed'
            - $ref: '#/components/schemas/EarningRuleProportional'
        event:
          description: >-
            Defines the event which triggers the earning rule to add points to a
            loyalty card.
          allOf:
            - $ref: '#/components/schemas/EarningRuleEvent'
        custom_event:
          description: Contains details about the custom event.
          type: object
          properties:
            schema_id:
              description: Unique identifier of the custom event schema
              type: string
          required:
            - schema_id
        segment:
          type: object
          description: >-
            Contains the ID of a customer segment. Required for the
            `customer.segment.entered` option in the event.
          properties:
            id:
              type: string
              description: >-
                Contains a unique identifier of a customer segment. Assigned by
                the Voucherify API.
          required:
            - id
        loyalty_tier:
          type: object
          description: Defines the tier associated with the earning rule definition.
          properties:
            id:
              type: string
              description: |-
                Unique loyalty tier ID associated with the earning rule.    

                - `__ANY__`: any loyalty tier within the campaign
              example: ltr_pudTGWasuIqxdiDM0go31OV1
        pending_points:
          type: object
          description: >-
            Defines the configuration for pending points. Pending points can be
            used only with the `order.paid` event.
          properties:
            period_type:
              type: string
              description: >-
                Defines the type of the period during which the points are in
                the pending state. Currently, only `DAY` value is accepted.
              enum:
                - DAY
            period_value:
              type: integer
              description: >-
                Defines for how long the points are in the pending state. The
                minimum value is 1, maximum is 90.
              minimum: 1
              maximum: 90
        source:
          type: object
          required:
            - object_id
            - object_type
          description: Contains the custom earning rule name and parent campaign.
          properties:
            banner:
              type: string
              description: >-
                Name of the earning rule. This is displayed as a header for the
                earning rule in the Dashboard.
            object_id:
              type: string
              description: A unique campaign identifier assigned by the Voucherify API.
            object_type:
              type: string
              description: >-
                Defines the object associated with the earning rule. Defaults to
                `campaign`.
              default: campaign
              enum:
                - campaign
        object:
          type: string
          default: earning_rule
          enum:
            - earning_rule
          description: The type of the object represented by JSON. Default is earning_rule.
        automation_id:
          type: string
          description: For internal use by Voucherify.
        start_date:
          type: string
          description: >-
            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:
          type: string
          description: >-
            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:
          $ref: '#/components/schemas/ValidityTimeframe'
        validity_day_of_week:
          $ref: '#/components/schemas/ValidityDayOfWeek'
        validity_hours:
          $ref: '#/components/schemas/ValidityHours'
        metadata:
          type: object
          description: >-
            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:
          $ref: '#/components/schemas/EarningRuleExpirationRules'
      required:
        - id
        - created_at
        - loyalty
        - source
        - object
        - automation_id
        - metadata
    EarningRuleFixed:
      title: Define fixed amount of points
      type: object
      properties:
        type:
          type: string
          default: FIXED
          enum:
            - FIXED
          description: The number of points to be added to the loyalty card.
        points:
          type: integer
          description: >-
            Defines how the points will be added to the loyalty card. FIXED adds
            a fixed number of points.
        points_formula:
          type: string
          description: Formula used to dynamically calculate the rewarded points.
      required:
        - type
        - points
    EarningRuleProportional:
      title: Calculate points proportionally
      oneOf:
        - $ref: '#/components/schemas/EarningRuleProportionalOrder'
        - $ref: '#/components/schemas/EarningRuleProportionalOrderItems'
        - $ref: '#/components/schemas/EarningRuleProportionalCustomerMetadata'
        - $ref: '#/components/schemas/EarningRuleProportionalCustomEvent'
    EarningRuleEvent:
      title: Earning Rule Event
      example: >-
        `order.paid`, `customer.segment.entered`,
        `customer.loyalty.tier.upgraded`, `customer.loyalty.tier.downgraded`,
        `customer.loyalty.tier.prolonged`, `customer.loyalty.tier.joined`,
        `customer.loyalty.tier.left`
      type: string
    ValidityTimeframe:
      title: Validity Timeframe
      type: object
      description: >-
        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`.
      properties:
        duration:
          type: string
          description: >-
            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.
          example: PT1H
        interval:
          type: string
          description: >-
            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.
          example: P2D
    ValidityDayOfWeek:
      title: Validity Day Of Week
      type: array
      description: >-
        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
      items:
        type: integer
        enum:
          - 0
          - 1
          - 2
          - 3
          - 4
          - 5
          - 6
    ValidityHours:
      title: Validity Hours
      type: object
      description: Determines the hours of validity, e.g. to create a happy hours scenario.
      properties:
        daily:
          type: array
          description: >-
            Defines the recurring period(s) when the resource is active. The
            periods should not overlap.
          items:
            type: object
            description: Defines the recurring period(s) when the resource will be active.
            properties:
              start_time:
                type: string
                format: time
                description: >-
                  Defines the starting hour of validity in the HH:mm format. The
                  resource is *inactive before* this time.
                example: '12:00'
              days_of_week:
                type: array
                description: >-
                  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
                items:
                  type: integer
                  enum:
                    - 0
                    - 1
                    - 2
                    - 3
                    - 4
                    - 5
                    - 6
              expiration_time:
                type: string
                format: time
                description: >-
                  Defines the ending hour of validity in the HH:mm format. The
                  resource is *inactive after* this time.
                example: '14:00'
    EarningRuleExpirationRules:
      title: Earning Rule Expiration Rules
      type: object
      description: >-
        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.
      properties:
        period_type:
          type: string
          description: >-
            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.
          enum:
            - FIXED_DAY_OF_YEAR
            - MONTH
        period_value:
          type: integer
          description: 'Value of the period. Required for the `period_type: MONTH`.'
        rounding_type:
          type: string
          description: >-
            Type of rounding of the expiration period. Optional for the
            `period_type: MONTH`.
          enum:
            - END_OF_MONTH
            - END_OF_QUARTER
            - END_OF_HALF_YEAR
            - END_OF_YEAR
            - PARTICULAR_MONTH
        rounding_value:
          type: integer
          description: >-
            Value of rounding of the expiration period. Required for the
            `rounding_type`.
        fixed_month:
          type: integer
          description: >-
            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`.
          minimum: 1
          maximum: 12
        fixed_day:
          type: integer
          description: >-
            Determines the day of the month when the points expire. Required for
            the `period_type: FIXED_DAY_OF_YEAR`.
          minimum: 1
          maximum: 31
      required:
        - period_type
    EarningRuleProportionalOrder:
      title: Define amount of points proportional to the order
      oneOf:
        - $ref: '#/components/schemas/EarningRuleProportionalOrderAmount'
        - $ref: '#/components/schemas/EarningRuleProportionalOrderTotalAmount'
        - $ref: '#/components/schemas/EarningRuleProportionalOrderMetadata'
    EarningRuleProportionalOrderItems:
      title: Define amount of points proportional to order items
      oneOf:
        - $ref: '#/components/schemas/EarningRuleProportionalOrderItemsQuantity'
        - $ref: '#/components/schemas/EarningRuleProportionalOrderItemsAmount'
        - $ref: '#/components/schemas/EarningRuleProportionalOrderItemsSubtotalAmount'
    EarningRuleProportionalCustomerMetadata:
      title: Define amount of points proportional to customer metadata
      type: object
      properties:
        type:
          type: string
          default: PROPORTIONAL
          enum:
            - PROPORTIONAL
          description: >-
            Defines how the points will be added to the loyalty
            card.PROPORTIONAL adds points based on a pre-defined ratio.
        calculation_type:
          type: string
          default: CUSTOMER_METADATA
          enum:
            - CUSTOMER_METADATA
          description: >-
            CUSTOMER_METADATA: Customer Metadata (X points for every Y in
            metadata attribute, defined in the property key under the
            customer.metadata object)
        customer:
          type: object
          required:
            - metadata
          properties:
            metadata:
              type: object
              required:
                - every
                - points
                - property
              description: >-
                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.
              properties:
                every:
                  type: integer
                  description: >-
                    For how many increments of the customer metadata property to
                    grant points for.
                points:
                  type: integer
                  description: >-
                    Number of points to be awarded, i.e. how many points to be
                    added to the loyalty card.
                points_formula:
                  type: string
                  description: Formula used to dynamically calculate the rewarded points.
                property:
                  type: string
                  description: Customer metadata property.
      required:
        - type
        - calculation_type
        - customer
    EarningRuleProportionalCustomEvent:
      title: Earning Rule Proportional Custom Event
      type: object
      properties:
        type:
          type: string
          default: PROPORTIONAL
          enum:
            - PROPORTIONAL
          description: >-
            Defines how the points will be added to the loyalty
            card.PROPORTIONAL adds points based on a pre-defined ratio.
        calculation_type:
          type: string
          default: CUSTOM_EVENT_METADATA
          enum:
            - CUSTOM_EVENT_METADATA
          description: >-
            CUSTOM_EVENT_METADATA: Custom event metadata (X points for every Y
            in metadata attribute).
        custom_event:
          type: object
          required:
            - metadata
          properties:
            metadata:
              type: object
              required:
                - every
                - points
                - property
              description: >-
                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.
              properties:
                every:
                  type: integer
                  description: >-
                    For how many increments of the customer metadata property to
                    grant points for.
                points:
                  type: integer
                  description: >-
                    Number of points to be awarded, i.e. how many points to be
                    added to the loyalty card.
                points_formula:
                  type: string
                  description: Formula used to dynamically calculate the rewarded points.
                property:
                  type: string
                  description: |-

                    Custom event metadata property.
      required:
        - type
        - calculation_type
        - custom_event
    EarningRuleProportionalOrderAmount:
      title: Order Amount
      type: object
      properties:
        type:
          type: string
          default: PROPORTIONAL
          enum:
            - PROPORTIONAL
          description: >-
            Defines how the points will be added to the loyalty
            card.PROPORTIONAL adds points based on a pre-defined ratio.
        calculation_type:
          type: string
          default: ORDER_AMOUNT
          enum:
            - ORDER_AMOUNT
          description: >-
            `ORDER_AMOUNT`: Pre-discount order amount (X points for every Y
            spent excluding discounts)
        order:
          type: object
          required:
            - amount
          properties:
            amount:
              type: object
              required:
                - every
                - points
              description: >-
                Defines the ratio based on the property defined in the
                calculation_type parameter. For every set 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
                calculation_type, give points.
              properties:
                every:
                  type: integer
                  description: >-
                    Value is multiplied by 100 to precisely represent 2 decimal
                    places. For example, a $10 order amount is written as 1000.
                points:
                  type: integer
                  description: >-
                    Number of points to be awarded, i.e. how many points to be
                    added to the loyalty card.
                points_formula:
                  type: string
                  description: Formula used to dynamically calculate the rewarded points.
      required:
        - type
        - calculation_type
        - order
    EarningRuleProportionalOrderTotalAmount:
      title: Order Total Amount
      type: object
      properties:
        type:
          type: string
          default: PROPORTIONAL
          enum:
            - PROPORTIONAL
          description: >-
            Defines how the points will be added to the loyalty
            card.PROPORTIONAL adds points based on a pre-defined ratio.
        calculation_type:
          type: string
          default: ORDER_TOTAL_AMOUNT
          enum:
            - ORDER_TOTAL_AMOUNT
          description: >-
            `ORDER_TOTAL_AMOUNT`: Total order amount (X points for every Y spent
            including discount)
        order:
          type: object
          required:
            - total_amount
          properties:
            total_amount:
              type: object
              required:
                - every
                - points
              description: >-
                Defines the ratio based on the property defined in the
                calculation_type parameter. For every set 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
                calculation_type, give points.
              properties:
                every:
                  type: integer
                  description: >-
                    Value is multiplied by 100 to precisely represent 2 decimal
                    places. For example, a $10 order amount is written as 1000.
                points:
                  type: integer
                  description: >-
                    Number of points to be awarded, i.e. how many points to be
                    added to the loyalty card.
                points_formula:
                  type: string
                  description: Formula used to dynamically calculate the rewarded points.
      required:
        - type
        - calculation_type
        - order
    EarningRuleProportionalOrderMetadata:
      title: Order Metadata
      type: object
      properties:
        type:
          type: string
          default: PROPORTIONAL
          enum:
            - PROPORTIONAL
          description: >-
            Defines how the points will be added to the loyalty
            card.PROPORTIONAL adds points based on a pre-defined ratio.
        calculation_type:
          type: string
          default: ORDER_METADATA
          enum:
            - ORDER_METADATA
          description: >-
            `ORDER_METADATA`: Order Metadata (X points for every Y in metadata
            attribute, defined in the property key under the order.metadata
            object)
        order:
          type: object
          required:
            - metadata
          description: Defines the formula for calculating points proportionally.
          properties:
            metadata:
              type: object
              required:
                - every
                - points
                - property
              description: >-
                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.
              properties:
                every:
                  type: integer
                  description: >-
                    For how many increments of the order metadata property to
                    grant points for.
                points:
                  type: integer
                  description: >-
                    Number of points to be awarded, i.e. how many points to be
                    added to the loyalty card.
                points_formula:
                  type: string
                  description: Formula used to dynamically calculate the rewarded points.
                property:
                  type: string
                  description: Order metadata property.
      required:
        - type
        - calculation_type
        - order
    EarningRuleProportionalOrderItemsQuantity:
      title: Order Items Quantity
      type: object
      properties:
        type:
          type: string
          default: PROPORTIONAL
          enum:
            - PROPORTIONAL
          description: >-
            Defines how the points will be added to the loyalty
            card.PROPORTIONAL adds points based on a pre-defined ratio.
        calculation_type:
          type: string
          default: ORDER_ITEMS_QUANTITY
          enum:
            - ORDER_ITEMS_QUANTITY
          description: >-
            `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:
          type: object
          required:
            - quantity
          properties:
            quantity:
              type: object
              required:
                - every
                - points
              description: >-
                Defines the ratio based on the property defined in the
                calculation_type parameter. For every set 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
                calculation_type, give points.
              properties:
                every:
                  type: integer
                  description: >-
                    Value is multiplied by 100 to precisely represent 2 decimal
                    places. For example, a $10 order amount is written as 1000.
                points:
                  type: integer
                  description: >-
                    Number of points to be awarded, i.e. how many points to be
                    added to the loyalty card.
                points_formula:
                  type: string
                  description: Formula used to dynamically calculate the rewarded points.
                object:
                  type: string
                  description: >-
                    Type of object which will be covered by the earning rule.
                    This is required together with `id`. Can be replaced by the
                    `applicable_to` array. In response, the value of the first
                    object is returned even if `applicable_to` array was used.
                  enum:
                    - products_collection
                    - product
                    - sku
                id:
                  type: string
                  description: >-
                    Unique ID of the resource assigned by Voucherify. This is
                    required together with `object`. Can be replaced by the
                    `applicable_to` array. In response, the value of the first
                    object is returned even if `applicable_to` array was used.
                    Values are, for example, `pc_75U0dHlr7u75BJodrW1AE3t6` for
                    product collection, `prod_0bae32322150fd0546` for a product,
                    or `sku_0b7d7dfb090be5c619` for a SKU.
                applicable_to:
                  type: array
                  description: >-
                    Defines products, SKUs, or product collections covered by
                    the earning rule. Can be replaced by `object` and `id` to
                    define only one object.
                  items:
                    type: object
                    properties:
                      object:
                        type: string
                        description: >-
                          Type of object which will be covered by the earning
                          rule.
                        enum:
                          - products_collection
                          - product
                          - sku
                      id:
                        type: string
                        description: >-
                          Unique ID of the resource assigned by Voucherify.
                          Values are, for example, `pc_75U0dHlr7u75BJodrW1AE3t6`
                          for product collection, `prod_0bae32322150fd0546` for
                          a product, or `sku_0b7d7dfb090be5c619` for a SKU.
      required:
        - type
        - calculation_type
        - order_items
    EarningRuleProportionalOrderItemsAmount:
      title: Order Items Amount
      type: object
      properties:
        type:
          type: string
          default: PROPORTIONAL
          enum:
            - PROPORTIONAL
          description: >-
            Defines how the points will be added to the loyalty
            card.PROPORTIONAL adds points based on a pre-defined ratio.
        calculation_type:
          type: string
          default: ORDER_ITEMS_AMOUNT
          enum:
            - ORDER_ITEMS_AMOUNT
          description: >-
            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:
          type: object
          required:
            - amount
          properties:
            amount:
              type: object
              required:
                - every
                - points
              description: >-
                Defines the ratio based on the property defined in the
                calculation_type parameter. For every set 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
                calculation_type, give points.
              properties:
                every:
                  type: integer
                  description: >-
                    Value is multiplied by 100 to precisely represent 2 decimal
                    places. For example, a $10 order amount is written as 1000.
                points:
                  type: integer
                  description: >-
                    Number of points to be awarded, i.e. how many points to be
                    added to the loyalty card.
                points_formula:
                  type: string
                  description: Formula used to dynamically calculate the rewarded points.
                object:
                  type: string
                  description: >-
                    Type of object which will be covered by the earning rule.
                    This is required together with `id`. Can be replaced by the
                    `applicable_to` array. In response, the value of the first
                    object is returned even if `applicable_to` array was used.
                  enum:
                    - products_collection
                    - product
                    - sku
                id:
                  type: string
                  description: >-
                    Unique ID of the resource assigned by Voucherify. This is
                    required together with `object`. Can be replaced by the
                    `applicable_to` array. In response, the value of the first
                    object is returned even if `applicable_to` array was used.
                    Values are, for example, `pc_75U0dHlr7u75BJodrW1AE3t6` for
                    product collection, `prod_0bae32322150fd0546` for a product,
                    or `sku_0b7d7dfb090be5c619` for a SKU.
                applicable_to:
                  type: array
                  description: >-
                    Defines products, SKUs, or product collections covered by
                    the earning rule. Can be replaced by `object` and `id` to
                    define only one object.
                  items:
                    type: object
                    properties:
                      object:
                        type: string
                        description: >-
                          Type of object which will be covered by the earning
                          rule.
                        enum:
                          - products_collection
                          - product
                          - sku
                      id:
                        type: string
                        description: >-
                          Unique ID of the resource assigned by Voucherify.
                          Values are, for example, `pc_75U0dHlr7u75BJodrW1AE3t6`
                          for product collection, `prod_0bae32322150fd0546` for
                          a product, or `sku_0b7d7dfb090be5c619` for a SKU.
      required:
        - type
        - calculation_type
        - order_items
    EarningRuleProportionalOrderItemsSubtotalAmount:
      title: Order Items Subtotal Amount
      type: object
      properties:
        type:
          type: string
          default: PROPORTIONAL
          enum:
            - PROPORTIONAL
          description: >-
            Defines how the points will be added to the loyalty
            card.PROPORTIONAL adds points based on a pre-defined ratio.
        calculation_type:
          type: string
          default: ORDER_ITEMS_SUBTOTAL_AMOUNT
          enum:
            - ORDER_ITEMS_SUBTOTAL_AMOUNT
          description: >-
            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:
          type: object
          required:
            - subtotal_amount
          properties:
            subtotal_amount:
              type: object
              required:
                - every
                - points
              description: >-
                Defines the ratio based on the property defined in the
                calculation_type parameter. For every set 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
                calculation_type, give points.
              properties:
                every:
                  type: integer
                  description: >-
                    Value is multiplied by 100 to precisely represent 2 decimal
                    places. For example, a $10 order amount is written as 1000.
                points:
                  type: integer
                  description: >-
                    Number of points to be awarded, i.e. how many points to be
                    added to the loyalty card.
                points_formula:
                  type: string
                  description: Formula used to dynamically calculate the rewarded points.
                object:
                  type: string
                  description: >-
                    Type of object which will be covered by the earning rule.
                    This is required together with `id`. Can be replaced by the
                    `applicable_to` array. In response, the value of the first
                    object is returned even if `applicable_to` array was used.
                  enum:
                    - products_collection
                    - product
                    - sku
                id:
                  type: string
                  description: >-
                    Unique ID of the resource assigned by Voucherify. This is
                    required together with `object`. Can be replaced by the
                    `applicable_to` array. In response, the value of the first
                    object is returned even if `applicable_to` array was used.
                    Values are, for example, `pc_75U0dHlr7u75BJodrW1AE3t6` for
                    product collection, `prod_0bae32322150fd0546` for a product,
                    or `sku_0b7d7dfb090be5c619` for a SKU.
                applicable_to:
                  type: array
                  description: >-
                    Defines products, SKUs, or product collections covered by
                    the earning rule. Can be replaced by `object` and `id` to
                    define only one object.
                  items:
                    type: object
                    properties:
                      object:
                        type: string
                        description: >-
                          Type of object which will be covered by the earning
                          rule.
                        enum:
                          - products_collection
                          - product
                          - sku
                      id:
                        type: string
                        description: >-
                          Unique ID of the resource assigned by Voucherify.
                          Values are, for example, `pc_75U0dHlr7u75BJodrW1AE3t6`
                          for product collection, `prod_0bae32322150fd0546` for
                          a product, or `sku_0b7d7dfb090be5c619` for a SKU.
      required:
        - type
        - calculation_type
        - order_items
  securitySchemes:
    X-App-Id:
      type: apiKey
      name: X-App-Id
      in: header
    X-App-Token:
      type: apiKey
      name: X-App-Token
      in: header
    X-Voucherify-OAuth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://api.voucherify.io/v1/oauth/token
          scopes:
            api: Gives access to whole server-side API.
            vouchers: >-
              Gives access to all endpoints and methods starting with
              `v1/vouchers`.
            client_api: Gives access to whole client-side API.
            client_vouchers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/vouchers`.
            promotions: >-
              Gives access to all endpoints and methods starting with
              `/v1/promotions`.
            client_promotions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/promotions`
            campaigns: >-
              Gives access to all endpoints and methods starting with
              `v1/campaigns`.
            client_publish: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/publish`.
            exports: >-
              Gives access to all endpoints and methods starting with
              `/v1/exports`.
            publications: >-
              Gives access to all endpoints and methods starting with
              `/v1/publications`.
            client_validate: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validate`.
            validations: >-
              Gives access to all endpoints and methods starting with
              `/v1/validations`.
            client_validations: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validations`.
            qualifications: >-
              Gives access to all endpoints and methods starting with
              `/v1/qualifications`.
            client_qualifications: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/qualifications`.
            client_redeem: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redeem
            redemptions: >-
              Gives access to all endpoints and methods starting with
              `/v1/redemptions`.
            client_redemptions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redemptions`
            customers: >-
              Gives access to all endpoints and methods starting with
              `/v1/customers`.
            client_customers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/customers`.
            orders: >-
              Gives access to all endpoints and methods starting with
              `/v1/orders`.
            products: >-
              Gives access to all endpoints and methods starting with
              `/v1/products`.
            skus: >-
              Gives access to all endpoints and methods starting with
              `/v1/SKUs`.
            validation-rules: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules`.
            validation-rules-assignments: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules-assignments
            segments: >-
              Gives access to all endpoints and methods starting with
              `/v1/segments`.
            events: >-
              Gives access to all endpoints and methods starting with
              `/v1/events`.
            client_events: >-
              Gives access to all endpoints and methods starting with
              `client/v1/events`.
            rewards: >-
              Gives access to all endpoints and methods starting with
              `/v1/rewards`.
            assets: >-
              Gives access to all endpoints and methods starting with
              `/v1/assets`.
            task-results: >-
              Gives access to all endpoints and methods starting with
              `/v1/task-results`.
            loyalties: >-
              Gives access to all endpoints and methods starting with
              `/v1/loyalties`.
            client_consents: >-
              Gives access to all endpoints and methods starting with
              `client/v1/consents`.
            consents: >-
              Gives access to all endpoints and methods starting with
              `/v1/consents`.
            async-actions: >-
              Gives access to all endpoints and methods starting with
              `/v1/async-actions`.
            product-collections: >-
              Gives access to all endpoints and methods starting with
              `/v1/product-collections`.
            categories: >-
              Gives access to all endpoints and methods starting with
              `/v1/categories`.
            metadata-schemas: >-
              Gives access to all endpoints and methods starting with
              `/v1/metadata-schemas`.
            locations: >-
              Gives access to all endpoints and methods starting with
              `/v1/locations`.
            referrals: >-
              Gives access to all endpoints and methods starting with
              `/v1/referrals`.
            trash-bin: >-
              Gives access to all endpoints and methods starting with
              `/v1/trash-bin`.
            templates: >-
              Gives access to all endpoints and methods starting with
              `/v1/templates`.

````