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

# Create Earning Rule

> Create earning rules for a loyalty campaign.

> 🚧 Maximum number of earning rules
>
> You can create up to 100 earning rules per project. The limit can be customized for clients with a single-tenant setup.



## OpenAPI

````yaml /openapi/loyalties.json post /v1/loyalties/{campaignId}/earning-rules
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:
    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`. 
    post:
      tags:
        - Loyalties
      summary: Create Earning Rule
      description: >-
        Create earning rules for a loyalty campaign.


        > 🚧 Maximum number of earning rules

        >

        > You can create up to 100 earning rules per project. The limit can be
        customized for clients with a single-tenant setup.
      operationId: create-earning-rule
      parameters: []
      requestBody:
        description: >-
          Customize the request body based on the type of earning rules you
          would like to create. The request body is an array of objects. The
          required minimum properties to include in the payload for each object
          are `event` and `loyalty`. Additionally, if you choose to add a
          `validity_timeframe`, you must include a `start_date`. Furthermore, an
          earning rule `event` type:  


          - `customer.segment.entered` requires a `segment` object

          - a custom event requires a `custom_event` object

          - a `customer.loyalty.tier.joined`, `customer.loyalty.tier.left`,
          `customer.loyalty.tier.upgraded`, `customer.loyalty.tier.downgraded`,
          `customer.loyalty.tier.prolonged` requires a `loyalty_tier` object
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoyaltiesEarningRulesCreateRequestBody'
            examples:
              Example:
                value:
                  - event: order.paid
                    validation_rule_id: val_7SxpdhPeBngA
                    loyalty:
                      type: FIXED
                      points: '5'
                    source:
                      banner: Order paid 5 points.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: Order paid - fixed amount of points
                  - event: order.paid
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: ORDER_AMOUNT
                      order:
                        amount:
                          every: 1
                          points: 1
                    source:
                      banner: >-
                        Order paid - 1 point for 1 dollar spent excluding
                        discounts.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: Order paid- points proportional to order amount
                  - event: order.paid
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: ORDER_TOTAL_AMOUNT
                      order:
                        total_amount:
                          every: 1
                          points: 1
                    source:
                      banner: >-
                        Order paid - 1 point for 1 dollar spent including
                        discounts.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: Order paid- points proportional to order total amount
                  - event: order.paid
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: ORDER_METADATA
                      order:
                        metadata:
                          every: 2
                          points: 1
                          property: number_of_store_visits
                    source:
                      banner: Order paid - 2 points for each store visit.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: >-
                        Order paid- points proportional to numerical order
                        metadata property 
                  - event: order.paid
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: ORDER_ITEMS_AMOUNT
                      order_items:
                        amount:
                          every: 2
                          points: 1
                          object: product
                          id: prod_0bae32322150fd0546
                    source:
                      banner: >-
                        Order paid - 2 points for 1 dollar spent on items
                        excluding discounts.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: Order paid- points proportional to order items amount
                  - event: order.paid
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: ORDER_ITEMS_SUBTOTAL_AMOUNT
                      order_items:
                        subtotal_amount:
                          every: 2
                          points: 1
                          object: products_collection
                          id: pc_75U0dHlr7u75BJodrW1AE3t6
                    source:
                      banner: >-
                        Order paid - 2 points for every dollar spent on the
                        product collection.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: >-
                        Order paid- points proportional to order items subtotal
                        amount
                  - event: order.paid
                    validation_rule_id: null
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: ORDER_ITEMS_QUANTITY
                      order_items:
                        quantity:
                          every: 1
                          points: 1
                          object: sku
                          id: sku_0b7d7dfb090be5c619
                    source:
                      banner: Order paid - 1 point for every brand phone in your cart.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: >-
                        Order paid - points proportional to quantity of items in
                        a cart of a product varient.
                  - event: order.paid
                    validation_rule_id: val_7SxpdhPeBngA
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: CUSTOMER_METADATA
                      customer:
                        metadata:
                          every: 1
                          points: 1
                          property: customer_life_time_value
                    source:
                      banner: >-
                        Order paid 1 point for 1 month of being a customer with
                        us.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: >-
                        Order paid - points proportional to customer metadata
                        property
                  - event: customer.segment.entered
                    segment:
                      id: seg_OlE7DmfzMI5pHyD5VAv512r1
                    validation_rule_id: val_7SxpdhPeBngA
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: CUSTOMER_METADATA
                      customer:
                        metadata:
                          every: 1
                          points: 1
                          property: customer_life_time_value
                    source:
                      banner: >-
                        Customer entered birthday segment - 1 point for each
                        month of being a customer with us.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: >-
                        Entered segment - points proportional to customer
                        metadata property
                  - event: customer.segment.entered
                    segment:
                      id: seg_OlE7DmfzMI5pHyD5VAv512r1
                    validation_rule_id: val_7SxpdhPeBngA
                    loyalty:
                      type: FIXED
                      points: '5'
                    source:
                      banner: Customer entered birthday segment - 5 points
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: Entered segment - fixed points
                  - event: page_view
                    validation_rule_id: val_7SxpdhPeBngA
                    loyalty:
                      points: 3
                      type: FIXED
                    custom_event:
                      schema_id: ms_gn4Qe4xsFPf7orCArCiNVY13
                    source:
                      banner: See page - 3 points
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: Custom Event - fixed points for viewing a page
                  - event: page_view
                    validation_rule_id: val_7SxpdhPeBngA
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: CUSTOM_EVENT_METADATA
                      custom_event:
                        metadata:
                          every: 1
                          points: 2
                          property: volume_number
                    custom_event:
                      schema_id: ms_gn4Qe4xsFPf7orCArCiNVY13
                    source:
                      banner: See page X - get 2 points multiplied by the page number
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: >-
                        Custom Event - proportional points for viewing a page
                        based on custom event metadata
                  - event: page_view
                    validation_rule_id: val_7SxpdhPeBngA
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: CUSTOMER_METADATA
                      customer:
                        metadata:
                          every: 1
                          points: 2
                          property: customer_life_time_value
                    custom_event:
                      schema_id: ms_gn4Qe4xsFPf7orCArCiNVY13
                    source:
                      banner: >-
                        Get 2 points for every month you're a customer for
                        viewing a page
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: >-
                        Custom Event - proportional points for viewing a page
                        based on customer metadata
                  - event: customer.loyalty.tier.prolonged
                    validation_rule_id: val_7SxpdhPeBngA
                    loyalty:
                      type: PROPORTIONAL
                      calculation_type: CUSTOMER_METADATA
                      customer:
                        metadata:
                          every: 1
                          points: 2
                          property: customer_life_time_value
                    loyalty_tier:
                      id: ltr_pudTGWasuIqxdiDM0go31OV1
                    source:
                      banner: >-
                        Get 2 points for every month you're a customer when your
                        loyalty tier is prolonged.
                    active: true
                    start_date: '2022-11-02T13:00:00.000Z'
                    expiration_date: '2023-03-03T14:30:00.000Z'
                    validity_timeframe:
                      duration: PT1H
                      interval: P1D
                    validity_day_of_week:
                      - 0
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                    metadata:
                      Type: >-
                        Custom Event - proportional points for extending a
                        loyalty tier based on customer metadata.
        required: true
      responses:
        '200':
          description: Returns an array of earning rule objects.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/LoyaltiesEarningRulesCreateResponseBody'
              examples:
                Example:
                  value:
                    - id: ern_63g6NQgtepfXn2z0QbT2ksLf
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      validation_rule_id: val_7SxpdhPeBngA
                      loyalty:
                        points: 5
                        type: FIXED
                      event: order.paid
                      source:
                        banner: Order paid 5 points.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_knM56LS3oygL0Ue0oeSNt4WA
                      metadata:
                        Type: Order paid - fixed amount of points
                    - id: ern_Ov5RWerVFubVSjIHOMco34dv
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: ORDER_AMOUNT
                        order:
                          amount:
                            every: 1
                            points: 1
                      event: order.paid
                      source:
                        banner: >-
                          Order paid - 1 point for 1 dollar spent excluding
                          discounts.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_2R4x6pMFVEIPz1Lhz5ZVo33Y
                      metadata:
                        Type: Order paid- points proportional to order amount
                    - id: ern_5rWPz4arGlTv4FVc1vETeFfe
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: ORDER_TOTAL_AMOUNT
                        order:
                          total_amount:
                            every: 1
                            points: 1
                      event: order.paid
                      source:
                        banner: >-
                          Order paid - 1 point for 1 dollar spent including
                          discounts.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_fXasfs6Eh7P2haZkI33PEumI
                      metadata:
                        Type: Order paid- points proportional to order total amount
                    - id: ern_Xs3o43dHr1O3RM5ojoeu1l6b
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: ORDER_METADATA
                        order:
                          metadata:
                            every: 2
                            points: 1
                            property: number_of_store_visits
                      event: order.paid
                      source:
                        banner: Order paid - 2 points for each store visit.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_jucMzF25jisrqiG3k6JyyviT
                      metadata:
                        Type: >-
                          Order paid- points proportional to numerical order
                          metadata property 
                    - id: ern_9CjMBP2V8zgpsHLga4YOQo0A
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: ORDER_ITEMS_AMOUNT
                        order_items:
                          amount:
                            every: 2
                            points: 1
                            object: product
                            id: prod_0bae32322150fd0546
                      event: order.paid
                      source:
                        banner: >-
                          Order paid - 2 points for 1 dollar spent on items
                          excluding discounts.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_y60lx7XsW1YdOOOFuDaYjvG4
                      metadata:
                        Type: Order paid- points proportional to order items amount
                    - id: ern_uI7hRj8PNodK8xWRsn3gpDdG
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: ORDER_ITEMS_SUBTOTAL_AMOUNT
                        order_items:
                          subtotal_amount:
                            every: 2
                            points: 1
                            object: products_collection
                            id: pc_75U0dHlr7u75BJodrW1AE3t6
                      event: order.paid
                      source:
                        banner: >-
                          Order paid - 2 points for every dollar spent on the
                          product collection.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_Lk1WROGexXA72FabUWhR1p7X
                      metadata:
                        Type: >-
                          Order paid- points proportional to order items
                          subtotal amount
                    - id: ern_dL13AmZEO0ToImOY44YUP1ru
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: ORDER_ITEMS_QUANTITY
                        order_items:
                          quantity:
                            every: 1
                            points: 1
                            object: sku
                            id: sku_0b7d7dfb090be5c619
                      event: order.paid
                      source:
                        banner: >-
                          Order paid - 1 point for every brand phone in your
                          cart.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_4F9iJG0hmKTiqSsmkfbB8vUF
                      metadata:
                        Type: >-
                          Order paid - points proportional to quantity of items
                          in a cart of a product varient.
                    - id: ern_ublD9yGhxPrd9ayPAMTc4aOZ
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      validation_rule_id: val_7SxpdhPeBngA
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: CUSTOMER_METADATA
                        customer:
                          metadata:
                            every: 1
                            points: 1
                            property: customer_life_time_value
                      event: order.paid
                      source:
                        banner: >-
                          Order paid 1 point for 1 month of being a customer
                          with us.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_raft7C1hVw427OnEobmzhXjD
                      metadata:
                        Type: >-
                          Order paid - points proportional to customer metadata
                          property
                    - id: ern_6tBwufmR7UNJInhZq8zNRrj5
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      validation_rule_id: val_7SxpdhPeBngA
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: CUSTOMER_METADATA
                        customer:
                          metadata:
                            every: 1
                            points: 1
                            property: customer_life_time_value
                      segment:
                        id: seg_OlE7DmfzMI5pHyD5VAv512r1
                      event: customer.segment.entered
                      source:
                        banner: >-
                          Customer entered birthday segment - 1 point for each
                          month of being a customer with us.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_mQ8SCABGLnrGMBbh8QS6DUpX
                      metadata:
                        Type: >-
                          Entered segment - points proportional to customer
                          metadata property
                    - id: ern_yBR0JtdcDyJXgZf30C8KQLPw
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      validation_rule_id: val_7SxpdhPeBngA
                      loyalty:
                        points: 5
                        type: FIXED
                      segment:
                        id: seg_OlE7DmfzMI5pHyD5VAv512r1
                      event: customer.segment.entered
                      source:
                        banner: Customer entered birthday segment - 5 points
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_Co7zjgYPIKZ45vcK0jn7qrY8
                      metadata:
                        Type: Entered segment - fixed points
                    - id: ern_Ic2AUznt4cJInIl1wt6n0Fbv
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      validation_rule_id: val_7SxpdhPeBngA
                      loyalty:
                        points: 3
                        type: FIXED
                      custom_event:
                        schema_id: ms_gn4Qe4xsFPf7orCArCiNVY13
                      event: page_view
                      source:
                        banner: See page - 3 points
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_KWvcBS3bdmJnWD4BTw29eRNT
                      metadata:
                        Type: Custom Event - fixed points for viewing a page
                    - id: ern_4SRj1TY1j8Q617R2Y4qiN1sy
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      validation_rule_id: val_7SxpdhPeBngA
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: CUSTOM_EVENT_METADATA
                        custom_event:
                          metadata:
                            every: 1
                            points: 2
                            property: volume_number
                      custom_event:
                        schema_id: ms_gn4Qe4xsFPf7orCArCiNVY13
                      event: page_view
                      source:
                        banner: >-
                          See page X - get 2 points multiplied by the page
                          number
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_WWESERcKoTRSbCDal7Hr7H0A
                      metadata:
                        Type: >-
                          Custom Event - proportional points for viewing a page
                          based on custom event metadata
                    - id: ern_WXBa4b5a6N5XZt9A9Nf9dagA
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      validation_rule_id: val_7SxpdhPeBngA
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: CUSTOMER_METADATA
                        customer:
                          metadata:
                            every: 1
                            points: 2
                            property: customer_life_time_value
                      custom_event:
                        schema_id: ms_gn4Qe4xsFPf7orCArCiNVY13
                      event: page_view
                      source:
                        banner: >-
                          Get 2 points for every month you're a customer for
                          viewing a page
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_zv3mCOeZOaHCsFMG0yIKu0ax
                      metadata:
                        Type: >-
                          Custom Event - proportional points for viewing a page
                          based on customer metadata
                    - id: ern_DvdegDzcaMUXzf2fayzCqMEV
                      created_at: '2022-11-29T11:10:46.523Z'
                      updated_at: null
                      validation_rule_id: val_7SxpdhPeBngA
                      loyalty:
                        type: PROPORTIONAL
                        calculation_type: CUSTOMER_METADATA
                        customer:
                          metadata:
                            every: 1
                            points: 2
                            property: customer_life_time_value
                      event: customer.loyalty.tier.prolonged
                      loyalty_tier:
                        id: ltr_pudTGWasuIqxdiDM0go31OV1
                      source:
                        banner: >-
                          Get 2 points for every month you're a customer when
                          your loyalty tier is prolonged.
                        object_id: camp_fkZ28pe7DUAEmmabofkxHI8N
                        object_type: campaign
                      active: true
                      start_date: '2022-11-02T13:00:00.000Z'
                      expiration_date: '2023-03-03T14:30:00.000Z'
                      validity_timeframe:
                        duration: PT1H
                        interval: P1D
                      validity_day_of_week:
                        - 0
                        - 1
                        - 2
                        - 3
                        - 4
                        - 5
                      object: earning_rule
                      automation_id: auto_fpfYyNcpVskgwcrs21kQ91Wx
                      metadata:
                        Type: >-
                          Custom Event - proportional points for extending a
                          loyalty tier based on customer metadata.
        '400':
          description: Returns an error if a parameters is defined incorrectly.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/e_400_missing_param'
              examples:
                Example:
                  value:
                    code: 400
                    key: invalid_payload
                    message: Invalid payload
                    details: >-
                      Loyalty order rules must contain one of the following
                      properties - 'total_amount'
                    request_id: v-0c127fa5d4424c8411
        '404':
          description: >-
            Returns an error if a parameter's value is not found in the
            respository.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Example:
                  value:
                    code: 404
                    key: not_found
                    message: Resource not found
                    details: >-
                      Cannot find loyalty_tier with id
                      ltr_pudTGWasuIqxdiDM0go31OV1
                    request_id: v-0c12808f33ce673c42
                    resource_id: ltr_pudTGWasuIqxdiDM0go31OV1
                    resource_type: loyalty_tier
      security:
        - X-App-Id: []
          X-App-Token: []
        - X-Voucherify-OAuth:
            - api
            - loyalties
components:
  schemas:
    ParameterCampaignId:
      type: string
      example: camp_rRsfatlwN7unSeUIJDCYedal
    LoyaltiesEarningRulesCreateRequestBody:
      description: >-
        This data model represents the Request body schema for the
        `/loyalties/{campaignId}/earning-rules` endpoint.
      title: Create Earning Rule Request Body
      type: array
      items:
        oneOf:
          - $ref: >-
              #/components/schemas/LoyaltiesEarningRulesCreateOrderPaidRequestBody
          - $ref: >-
              #/components/schemas/LoyaltiesEarningRulesCreateEnteredSegmentRequestBody
          - $ref: >-
              #/components/schemas/LoyaltiesEarningRulesCreateCustomEventRequestBody
          - $ref: >-
              #/components/schemas/LoyaltiesEarningRulesCreateTierChangeRequestBody
    LoyaltiesEarningRulesCreateResponseBody:
      type: object
      title: Loyalties Earning Rules Get Response Body
      description: >-
        Response body schema for **POST**
        `v1/loyalties/{campaignId}/earning-rules`.
      allOf:
        - $ref: '#/components/schemas/EarningRule'
    e_400_missing_param:
      description: 'Error: Bad Request &rarr; Missing Parameters'
      type: object
      title: Missing Parameters
      properties:
        code:
          type: integer
          default: 400
          description: Error's HTTP status code.
        key:
          type: string
          default: missing_param
          description: Short string describing the kind of error which occurred.
        message:
          type: string
          default: Missing required parameter
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          example: Parameter 'custom_event.schema_id' is required
          description: A human-readable message providing more details about the error.
        request_id:
          type: string
          example: v-0a96c19b1a41c03999
          description: >-
            This ID is useful when troubleshooting and/or finding the root cause
            of an error response by our support team.
    Error:
      title: Error Object
      type: object
      description: Error details
      properties:
        code:
          type: integer
          description: Error's HTTP status code.
        key:
          type: string
          description: Short string describing the kind of error which occurred.
        message:
          type: string
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          description: A human-readable message providing more details about the error.
        request_id:
          type: string
          example: v-0a885062c80375740f
          description: >-
            This ID is useful when troubleshooting and/or finding the root cause
            of an error response by our support team.
        resource_id:
          type: string
          description: >-
            Unique resource ID that can be used in another endpoint to get more
            details.
          example: rf_0c5d710a87c8a31f86
        resource_type:
          type: string
          description: The resource type.
          example: voucher
        error:
          type: object
          description: Includes additional information about the error.
          properties:
            message:
              type: string
              description: The message configured by the user in a validation rule.
      required:
        - code
        - message
    LoyaltiesEarningRulesCreateOrderPaidRequestBody:
      description: This is an object representing an earning rule for a paid order.
      type: object
      title: Earning Rule Object for Order Paid
      properties:
        validation_rule_id:
          type: string
          example: val_248vs7tUjlIE
          description: >-
            A unique validation rule identifier assigned by the Voucherify API.
            The validation rule is verified before points are added to the
            balance.
        loyalty:
          description: >-
            An object that defines the number of points that will be added to a
            loyalty card and how the points will be added.


            - `FIXED` adds a fixed number of `points`

            - `PROPORTIONAL` adds points proportionally based on a pre-defined
            ratio
          oneOf:
            - $ref: '#/components/schemas/EarningRuleFixed'
            - $ref: '#/components/schemas/EarningRuleProportionalOrder'
            - $ref: '#/components/schemas/EarningRuleProportionalOrderItems'
        event:
          type: string
          default: order.paid
          enum:
            - order.paid
          description: >-
            Defines the event which triggers the earning rule to add points to a
            loyalty card.  


            - `order.paid` an event defined by the Voucherify API corresponding
            to an order status `PAID`. 
        source:
          type: object
          description: Contains the custom earning rule name and parent campaign.
          properties:
            banner:
              type: string
              example: Order Paid - You will get 100 points
              description: >-
                Name of the earning rule. This is displayed as a header for the
                earning rule in the Dashboard.
        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
        start_date:
          type: string
          example: '2022-02-02T13:00:00.000Z'
          format: date-time
          description: >-
            Start date defines when the earning rule starts to be active.
            Activation timestamp is presented in the ISO 8601 format. Earning
            rule is *inactive before* this date. If you don't define the start
            date for an earning rule, it will inherit the campaign start date by
            default. 
        expiration_date:
          type: string
          format: date-time
          example: '2022-03-03T14:30:00.000Z'
          description: >-
            Expiration date defines when the earning rule expires. Expiration
            timestamp is presented in the ISO 8601 format.  Earning rule is
            *inactive after* this date.If you don't define the expiration date
            for an earning rule, it will inherit the campaign expiration date by
            default.
        pending_points:
          type: object
          nullable: true
          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
        expiration_rules:
          $ref: '#/components/schemas/EarningRuleExpirationRules'
        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.
    LoyaltiesEarningRulesCreateEnteredSegmentRequestBody:
      description: >-
        This is an object representing an earning rule for entering a customer
        segment.
      type: object
      title: Earning Rule Object for Entered Segment
      properties:
        validation_rule_id:
          type: string
          example: val_248vs7tUjlIE
          description: >-
            A unique validation rule identifier assigned by the Voucherify API.
            The validation rule is verified before points are added to the
            balance.
        loyalty:
          description: >-
            An object that defines the number of points that will be added to a
            loyalty card and how the points will be added.


            - `FIXED` adds a fixed number of `points`

            - `PROPORTIONAL` adds points proportionally based on a pre-defined
            ratio
          oneOf:
            - $ref: '#/components/schemas/EarningRuleFixed'
            - $ref: '#/components/schemas/EarningRuleProportionalCustomerMetadata'
        segment:
          type: object
          description: >-
            Contains the ID of a customer segment. **Required** for the
            `customer.segment.entered` option in `event`.
          properties:
            id:
              type: string
              description: >-
                Contains a unique identifier of a customer segment. Assigned by
                the Voucherify API.
        event:
          type: string
          default: customer.segment.entered
          enum:
            - customer.segment.entered
          description: >-
            Defines the event which triggers the earning rule to add points to a
            loyalty card.  


            - `customer.segment.entered` an event defined by the Voucherify API
            corresponding to a customer entering a pre-defined customer segment.
        source:
          type: object
          description: Contains the custom earning rule name and parent campaign.
          properties:
            banner:
              type: string
              example: Order Paid - You will get 100 points
              description: >-
                Name of the earning rule. This is displayed as a header for the
                earning rule in the Dashboard.
        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
        start_date:
          type: string
          example: '2022-02-02T13:00:00.000Z'
          format: date-time
          description: >-
            Start date defines when the earning rule starts to be active.
            Activation timestamp is presented in the ISO 8601 format. Earning
            rule is *inactive before* this date. If you don't define the start
            date for an earning rule, it will inherit the campaign start date by
            default. 
        expiration_date:
          type: string
          format: date-time
          example: '2022-03-03T14:30:00.000Z'
          description: >-
            Expiration date defines when the earning rule expires. Expiration
            timestamp is presented in the ISO 8601 format.  Earning rule is
            *inactive after* this date.If you don't define the expiration date
            for an earning rule, it will inherit the campaign expiration date by
            default.
        expiration_rules:
          $ref: '#/components/schemas/EarningRuleExpirationRules'
        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.
    LoyaltiesEarningRulesCreateCustomEventRequestBody:
      description: >-
        This is an object representing an earning rule triggered by a custom
        event.
      type: object
      title: Earning Rule Object for Custom Event
      properties:
        validation_rule_id:
          type: string
          example: val_248vs7tUjlIE
          description: >-
            A unique validation rule identifier assigned by the Voucherify API.
            The validation rule is verified before points are added to the
            balance.
        loyalty:
          description: >-
            An object that defines the number of points that will be added to a
            loyalty card and how the points will be added.


            - `FIXED` adds a fixed number of `points`

            - `PROPORTIONAL` adds points proportionally based on a pre-defined
            ratio
          oneOf:
            - $ref: '#/components/schemas/EarningRuleFixed'
            - $ref: '#/components/schemas/EarningRuleProportionalCustomEvent'
        custom_event:
          type: object
          description: >-
            Contains the schema id of a custom event. **Required** for the
            custom event option in `event`.
          properties:
            schema_id:
              type: string
              description: >-
                Contains a unique identifier of a custom event schema. Assigned
                by the Voucherify API.
              example: ms_gn4Qe4xsFPf7orCArCiNVY13
        event:
          type: string
          description: >-
            Defines the event which triggers the earning rule to add points to a
            loyalty card.  


            - `custom_event_name` the name of a custom event defined in the
            Dashboard &rarr; **Project Settings** &rarr; **EVENT SCHEMA** &rarr;
            **Add event definition**. Read more on defining [custom
            events](/prepare/custom-events). 
        source:
          type: object
          description: Contains the custom earning rule name and parent campaign.
          properties:
            banner:
              type: string
              example: Order Paid - You will get 100 points
              description: >-
                Name of the earning rule. This is displayed as a header for the
                earning rule in the Dashboard.
        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
        start_date:
          type: string
          example: '2022-02-02T13:00:00.000Z'
          format: date-time
          description: >-
            Start date defines when the earning rule starts to be active.
            Activation timestamp is presented in the ISO 8601 format. Earning
            rule is *inactive before* this date. If you don't define the start
            date for an earning rule, it will inherit the campaign start date by
            default. 
        expiration_date:
          type: string
          format: date-time
          example: '2022-03-03T14:30:00.000Z'
          description: >-
            Expiration date defines when the earning rule expires. Expiration
            timestamp is presented in the ISO 8601 format.  Earning rule is
            *inactive after* this date.If you don't define the expiration date
            for an earning rule, it will inherit the campaign expiration date by
            default.
        expiration_rules:
          $ref: '#/components/schemas/EarningRuleExpirationRules'
        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.
    LoyaltiesEarningRulesCreateTierChangeRequestBody:
      description: This is an object representing an earning rule for tiers.
      type: object
      title: Earning Rule Object for Tiers
      properties:
        validation_rule_id:
          type: string
          example: val_248vs7tUjlIE
          description: >-
            A unique validation rule identifier assigned by the Voucherify API.
            The validation rule is verified before points are added to the
            balance.
        loyalty:
          description: >-
            An object that defines the number of points that will be added to a
            loyalty card and how the points will be added.


            - `FIXED` adds a fixed number of `points`.
          oneOf:
            - $ref: '#/components/schemas/EarningRuleFixed'
        event:
          type: string
          description: >-
            Defines the event which triggers the earning rule to add points to a
            loyalty card.  


            - `customer.loyalty.tier.joined` an event defined by the Voucherify
            API corresponding to a customer joining a tier    

            - `customer.loyalty.tier.left` an event defined by the Voucherify
            API corresponding to a customer leaving a tier    

            - `customer.loyalty.tier.upgraded` an event defined by the
            Voucherify API corresponding to a customer's tier being upgraded    

            - `customer.loyalty.tier.downgraded` an event defined by the
            Voucherify API corresponding to a customer's tier being upgraded    

            - `customer.loyalty.tier.prolonged` an event defined by the
            Voucherify API corresponding to a customer's tier being prolonged
          enum:
            - customer.loyalty.tier.joined
            - customer.loyalty.tier.left
            - customer.loyalty.tier.upgraded
            - customer.loyalty.tier.downgraded
            - customer.loyalty.tier.prolonged
        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
        source:
          type: object
          description: Contains the custom earning rule name and parent campaign.
          properties:
            banner:
              type: string
              example: Order Paid - You will get 100 points
              description: >-
                Name of the earning rule. This is displayed as a header for the
                earning rule in the Dashboard.
        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
        start_date:
          type: string
          example: '2022-02-02T13:00:00.000Z'
          format: date-time
          description: >-
            Start date defines when the earning rule starts to be active.
            Activation timestamp is presented in the ISO 8601 format. Earning
            rule is *inactive before* this date. If you don't define the start
            date for an earning rule, it will inherit the campaign start date by
            default. 
        expiration_date:
          type: string
          format: date-time
          example: '2022-03-03T14:30:00.000Z'
          description: >-
            Expiration date defines when the earning rule expires. Expiration
            timestamp is presented in the ISO 8601 format.  Earning rule is
            *inactive after* this date.If you don't define the expiration date
            for an earning rule, it will inherit the campaign expiration date by
            default.
        expiration_rules:
          $ref: '#/components/schemas/EarningRuleExpirationRules'
        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.
    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
    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
    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'
    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
    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'
    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
    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
    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
    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
  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`.

````