> ## Documentation Index
> Fetch the complete documentation index at: https://voucherify-mk-bogo.mintlify.site/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 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 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.
          properties:
            source_id:
              type: string
              description: >-
                The unique ID assigned by Voucherify of an existing order that
                will be linked to the loyalty point estimation (qualification).
                This property can be also sent as `id` instead.
            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. 
              additionalProperties: true
            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. Use if
                the related order doesn't have an amount value calculated.
      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'
    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`.

````