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

# Estimate loyalty points

> Estimates the number of points a customer will receive for a given order in the loyalty campaign under its earning rules. This endpoint also returns point estimation for created transactions (orders with status `PAID`)

This endpoint returns only an estimation, not a precise point value.

Also, this estimation works only for the Order paid earning rules. If a campaign includes tiers, mappings, and multiple earning rules, the calculation becomes more complex. During final calculation, a customer may change tiers and earn more or fewer points depending on other factors.



## OpenAPI

````yaml /openapi/loyalties.json post /v1/loyalties/{campaignId}/qualifications
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}/qualifications:
    parameters:
      - schema:
          $ref: '#/components/schemas/ParameterCampaignId'
        name: campaignId
        in: path
        required: true
        description: Unique campaign ID of the loyalty program.
    post:
      tags:
        - Loyalties
      summary: Estimate loyalty points
      description: >-
        Estimates the number of points a customer will receive for a given order
        in the loyalty campaign under its earning rules. This endpoint also
        returns point estimation for created transactions (orders with status
        `PAID`)


        This endpoint returns only an estimation, not a precise point value.


        Also, this estimation works only for the Order paid earning rules. If a
        campaign includes tiers, mappings, and multiple earning rules, the
        calculation becomes more complex. During final calculation, a customer
        may change tiers and earn more or fewer points depending on other
        factors.
      operationId: estimate-points
      parameters: []
      requestBody:
        description: Provide customer `source_id` and order `source_id`.
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/LoyaltiesQualificationsCheckEligibilityRequestBody
            examples:
              Point estimation request:
                value:
                  customer:
                    source_id: customerSourceID
                    metadata:
                      reason: loyaltyQualifications
                  order:
                    source_id: ord_113628fa0685537f99
                    metadata:
                      source: qualifyPoints
        required: true
      responses:
        '200':
          description: Returns campaign details and estimated number of points.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/LoyaltiesQualificationsCheckEligibilityResponseBody
              examples:
                Point estimation response:
                  value:
                    campaign:
                      id: camp_6hAtKbSF3iMj8wN8HjlvPuQG
                      name: Loyalty-campaign
                      object: campaign
                    points_estimation: 51
        '400':
          description: >-
            Returns an error if a required property is missing or the campaign
            or loyalty card is inactive. Also, returns an error if point
            estimation is made for a customer who doesn't participate in the
            loyalty campaign and the auto-join setting is turned off.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Auto-join turned off:
                  value:
                    code: 400
                    key: campaign_not_allow_auto_join
                    message: >-
                      Loyalty campaign 'camp_MuI0R45sm7Zc071zTKr4l7U2' does not
                      allow auto-join for non-members
                    details: Given campaign does not allow auto-join
                    request_id: v-11a681dec0d56f0616
                Customer object missing:
                  value:
                    code: 400
                    key: invalid_payload
                    message: Invalid payload
                    details: Property .customer must be object
                    request_id: v-11a682e603156f14ea
                Order object missing:
                  value:
                    code: 400
                    key: invalid_payload
                    message: Invalid payload
                    details: Property .order must be object
                    request_id: v-11a683295e48bae514
                Inactive campaign:
                  value:
                    code: 400
                    key: campaign_not_active
                    message: >-
                      Loyalty campaign 'camp_MuI0R45sm7Zc071zTKr4l7U2' is not
                      active
                    details: Given campaign is not active
                    request_id: v-11a683767b556f1ec4
                Inactive loyalty card:
                  value:
                    code: 400
                    key: loyalty_card_not_active
                    message: Customer's loyalty card 'Loyalty-ZC4Vg' is not active
                    details: Given customer's loyalty card is not active
                    request_id: v-11a683f3eec8baf2cd
        '404':
          description: >-
            Returns an error if the campaign ID that was specified in the path
            parameter is not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Not Found:
                  value:
                    code: 404
                    key: not_found
                    message: Resource not found
                    details: Cannot find campaign with id camp_MuIR45sm7Zc071zTKr4l7U2
                    request_id: v-11a681ab00d56f0327
                    resource_id: camp_MuIR45sm7Zc071zTKr4l7U2
                    resource_type: campaign
      security:
        - X-App-Id: []
          X-App-Token: []
        - X-Voucherify-OAuth:
            - api
            - loyalties
components:
  schemas:
    ParameterCampaignId:
      type: string
      example: camp_rRsfatlwN7unSeUIJDCYedal
    LoyaltiesQualificationsCheckEligibilityRequestBody:
      title: Loyalties Campaigns Qualifications Request Body
      type: object
      description: >-
        Request body schema for estimating loyalty points for an order with
        **POST** `/loyalties/{campaignId}/qualifications`.
      properties:
        customer:
          $ref: '#/components/schemas/Customer'
        order:
          type: object
          description: >-
            Details regarding the order being processed. You can provide either
            `source_id` of an existing order or an inline order/cart object (for
            example `amount`, `items`, or `metadata`). When both are provided,
            inline order data takes precedence.
          properties:
            id:
              type: string
              description: Unique ID assigned by Voucherify of an existing order.
            source_id:
              type: string
              description: >-
                The unique ID of an existing order to be linked to the loyalty
                point estimation (qualification). This property can also be sent
                as `id`. If inline order fields are provided as well, the inline
                order data takes precedence.
            status:
              type: string
              description: The order status.
              enum:
                - CREATED
                - PAID
                - CANCELED
                - FULFILLED
            amount:
              type: integer
              description: >-
                A positive integer in the smallest currency unit (e.g. 100 cents
                for $1.00) representing the total amount of the order. This is
                the sum of the order items' amounts.
            initial_amount:
              type: integer
              description: >-
                A positive integer in the smallest currency unit (e.g. 100 cents
                for $1.00) representing the total amount of the order. This is
                the sum of the order items' amounts.
            discount_amount:
              type: integer
              description: >-
                Sum of all order-level discounts applied to the order. It is
                expressed as an integer in the smallest currency unit (e.g. 100
                cents for $1.00).
            items:
              type: array
              description: >-
                Array of items applied to the order. It can include up to 500
                items.
              items:
                type: object
                title: Order Item Calculated
                properties:
                  id:
                    type: string
                    description: Unique identifier of the order line item.
                  sku_id:
                    type: string
                    description: >-
                      Unique identifier of the SKU. It is assigned by
                      Voucherify.
                  product_id:
                    type: string
                    description: >-
                      Unique identifier of the product. It is assigned by
                      Voucherify.
                  related_object:
                    type: string
                    enum:
                      - product
                      - sku
                    description: >-
                      Used along with the source_id property, can be set to
                      either sku or product.
                  source_id:
                    type: string
                    description: >-
                      The merchant's product/SKU ID (if it is different from the
                      Voucherify product/SKU ID). It is useful in the
                      integration between multiple systems. It can be an ID from
                      an eCommerce site, a database, or a third-party service.
                  quantity:
                    type: integer
                    description: The quantity of the particular item in the cart.
                  discount_quantity:
                    type: integer
                    description: Number of dicounted items.
                  initial_quantity:
                    type: integer
                    description: >-
                      A positive integer in the smallest unit quantity
                      representing the total amount of the order; this is the
                      sum of the order items' quantity.
                  amount:
                    type: integer
                    description: The total amount of the order item (price * quantity).
                  discount_amount:
                    type: integer
                    description: >-
                      Sum of all order-item-level discounts applied to the
                      order.
                  applied_discount_amount:
                    type: integer
                    description: This field shows the order-level discount applied.
                  applied_discount_quantity:
                    type: integer
                    description: Number of the discounted items applied in the transaction.
                  applied_quantity:
                    type: integer
                    description: >-
                      Quantity of items changed by the application of a new
                      quantity items. It can be positive when an item is added
                      or negative if an item is replaced.
                  applied_quantity_amount:
                    type: integer
                    description: >-
                      Amount for the items changed by the application of a new
                      quantity items. It can be positive when an item is added
                      or negative if an item is replaced.
                  initial_amount:
                    type: integer
                    description: >-
                      A positive integer in the smallest currency unit (e.g. 100
                      cents for $1.00) representing the total amount of the
                      order. This is the sum of the order items' amounts.
                  price:
                    type: integer
                    description: >-
                      Unit price of an item. The value is multiplied by 100 to
                      represent 2 decimal places. For example `10000 cents` for
                      `$100.00`.
                  subtotal_amount:
                    type: integer
                    description: >-
                      Final order item amount after the applied item-level
                      discount.  If there are no item-level discounts applied,
                      this item is equal to the `amount`.   

                      `subtotal_amount`=`amount`-`applied_discount_amount`
                  product:
                    type: object
                    description: An object containing details of the related product.
                    properties:
                      id:
                        type: string
                        description: >-
                          A unique identifier that represents the product and is
                          assigned by Voucherify.
                      source_id:
                        type: string
                        description: >-
                          The merchant's product ID (if it is different than
                          Voucherify's product ID). It is really useful in case
                          of integration between multiple systems. It can be an
                          ID from an eCommerce site, a database or a 3rd party
                          service.
                      override:
                        type: boolean
                        description: >-
                          The override set to `true` is used to store the
                          product information in the system. If the product does
                          not exist, it will be created with a source_id; if it
                          does exist, the provided values for the name, price,
                          and metadata will replace those already stored in the
                          system.
                      name:
                        type: string
                        description: Product name.
                      metadata:
                        type: object
                        description: >-
                          A set of custom key/value pairs that you can attach to
                          a product. It can be useful for storing additional
                          information about the product in a structured format.
                          It can be used to create product collections.
                      price:
                        type: number
                        description: >-
                          Product price. A positive integer in the smallest
                          currency unit (e.g. 100 cents for $1.00).
                  sku:
                    type: object
                    description: An object containing details of the related SKU.
                    properties:
                      id:
                        type: string
                        description: >-
                          A unique identifier that represents the SKU and is
                          assigned by Voucherify.
                      source_id:
                        type: string
                        description: >-
                          The merchant's SKU ID (if it is different than
                          Voucherify's SKU ID). It is really useful in case of
                          integration between multiple systems. It can be an ID
                          from an eCommerce site, a database or a 3rd party
                          service.
                      override:
                        type: boolean
                        description: >-
                          The override set to `true` is used to store the
                          product information in the system. If the product does
                          not exist, it will be created with a source_id; if it
                          does exist, the provided values for the name, price,
                          and metadata will replace those already stored in the
                          system.
                      sku:
                        type: string
                        description: The SKU name.
                      price:
                        type: number
                        description: >-
                          SKU price. A positive integer in the smallest currency
                          unit (e.g. 100 cents for $1.00).
                      metadata:
                        type: object
                        description: >-
                          A set of custom key/value pairs that you can attach to
                          an SKU. It can be useful for storing additional
                          information about the SKU in a structured format. It
                          can be used to create product collections.
                  object:
                    type: string
                    default: order_item
                    enum:
                      - order_item
                    description: The type of the object represented by JSON.
                  metadata:
                    type: object
                    description: >-
                      A set of custom key/value pairs that you can attach to an
                      item object. It can be useful for storing additional
                      information about the item in a structured format. It can
                      be used to define business validation rules or discount
                      formulas.
                required:
                  - object
            customer_id:
              type: string
              nullable: true
              description: >-
                Unique customer identifier of the customer making the purchase.
                The ID is assigned by Voucherify.
              example: cust_7iUa6ICKyU6gH40dBU25kQU1
            referrer_id:
              type: string
              nullable: true
              description: Unique referrer ID.
              example: cust_nM4jqPiaXUvQdVSA6vTRUnix
            customer:
              allOf:
                - $ref: '#/components/schemas/CustomerId'
            referrer:
              allOf:
                - $ref: '#/components/schemas/ReferrerId'
            metadata:
              type: object
              description: >-
                A set of custom key/value pairs that you can attach to an order.
                It can be useful for storing additional information about the
                order in a structured format. It can be used to define business
                validation rules or discount formulas.
      required:
        - customer
        - order
    LoyaltiesQualificationsCheckEligibilityResponseBody:
      title: Loyalties Campaigns Qualifications Response Body
      type: object
      description: >-
        Response body schema for estimating loyalty points for an order with
        **POST** `/loyalties/{campaignId}/qualifications`.
      properties:
        campaign:
          type: object
          description: Details about the campaign associated with the estimation.
          properties:
            id:
              type: string
              description: The unique identifier for the campaign, assigned by Voucherify.
            name:
              type: string
              description: The human-readable name of the campaign.
            object:
              type: string
              description: The type of the object represented by JSON.
              enum:
                - campaign
          required:
            - id
            - name
            - object
        points_estimation:
          type: integer
          description: >-
            The calculated estimation of points based on the order data and
            loyalty campaign's earning rules.
      required:
        - campaign
        - points_estimation
    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
    Customer:
      title: Customer
      allOf:
        - type: object
          title: Customer Id And Source Id
          properties:
            id:
              type: string
              description: The ID of an existing customer.
            source_id:
              type: string
              description: >-
                A unique identifier of the customer who validates a voucher. It
                can be a customer ID or email from a CRM system, database, or a
                third-party service. If you also pass a customer ID (unique ID
                assigned by Voucherify), the source ID will be ignored.
        - $ref: '#/components/schemas/CustomerBase'
    CustomerId:
      title: Customer Id
      type: object
      properties:
        id:
          type: string
          description: A unique identifier of an existing customer.
        object:
          type: string
          description: The type of the object represented by JSON.
          default: customer
          enum:
            - customer
      required:
        - id
        - object
    ReferrerId:
      title: Referrer Id
      allOf:
        - $ref: '#/components/schemas/CustomerId'
    CustomerBase:
      title: Customer Base
      type: object
      properties:
        name:
          type: string
          description: Customer's first and last name.
        description:
          type: string
          description: An arbitrary string that you can attach to a customer object.
        email:
          type: string
          description: Customer's email address.
        phone:
          type: string
          description: >-
            Customer's phone number. This parameter is mandatory when you try to
            send out codes to customers via an SMS channel.
        birthday:
          type: string
          description: '`Deprecated`. ~~Customer''s birthdate; format YYYY-MM-DD~~.'
          format: date
        birthdate:
          type: string
          description: Customer's birthdate; format YYYY-MM-DD.
          format: date
        address:
          type: object
          nullable: true
          description: Customer's address.
          properties:
            city:
              type: string
              description: City
            state:
              type: string
              description: State
            line_1:
              type: string
              description: First line of address.
            line_2:
              type: string
              description: Second line of address.
            country:
              type: string
              description: Country.
            postal_code:
              type: string
              description: Postal code.
        metadata:
          type: object
          description: >-
            A set of custom key/value pairs that you can attach to a customer.
            The metadata object stores all custom attributes assigned to the
            customer. It can be useful for storing additional information about
            the customer in a structured format. This metadata can be used for
            validating whether the customer qualifies for a discount or it can
            be used in building customer segments.
  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`.

````