---
title: "Calculate purchase discount and cashback"
method: POST
path: "/operations/calc"
tags: ["Operations"]
---

# Calculate purchase discount and cashback

`POST /operations/calc`

Returns information about available bonus points for redemption or discount amount (depending on
loyalty program settings), the payment amount after applying discounts/bonuses, and the number of
bonus points that will be awarded after the operation is completed.

**Always call this endpoint before POST /operations** to get the correct `cash` value.
Do not calculate discounts manually — the server applies all loyalty rules including
membership tier rates, point limits, and skip-loyalty exclusions.

The response depends on your company's `baseDiscountPolicy`:
- **APPLY_DISCOUNT** — returns discount amount and percentage
- **CHARGE_SCORES** — returns cashback points to be earned

## Request body

- PurchaseCalcRequest — Request body for calculating purchase discounts and cashback. Provide the customer identifier (code, uid, or phone) and receipt total to receive the loyalty calculation.
  - `code` string, nullable — UDS promo-code.
  - `participant` object, nullable — Customer information.
    - `uid` string, nullable — Customer ID in the UDS.
    - `phone` string, nullable — Customer phone number.
  - `receipt` object, required — Receipt information.
    - `total` number, required — Total receipt amount (in currency units).
    - `skipLoyaltyTotal` number — A part of the bill amount for which cashback is not credited and to which the discount does not apply (in currency units).
    - `unredeemableTotal` number — A part of total that cannot be redeemed with points
    - `points` number — Desired points to withdraw. Not required, would be max possible if not specified.

## Response `200`

Purchase calculation result

- PurchaseCalcResponse
  - `user` CustomerDetail, required — A customer enrolled in your company's loyalty program. Contains UDS profile information, current point balance, membership tier, and transaction statistics. Returned by list and search endpoints.
    - `uid` string, nullable — Customer ID in the UDS.
    - `avatar` string, nullable — Avatar URL.
    - `displayName` string — Customer name.
    - `gender` 'MALE' | 'FEMALE' | 'NOT_SPECIFIED', nullable — Customer's gender for personalization and marketing segmentation.
    - `phone` string, nullable — Participant phone number.
    - `birthDate` string, date, nullable — Customer birth date
    - `participant` Participant — Customer's loyalty program details within your company — point balance, discount rates, transaction statistics, and membership tier. This is the core loyalty data for a customer.
      - `id` integer, nullable — Participant ID.
      - `inviterId` integer, nullable — ID of the inviting participant.
      - `points` number — Available loyalty points that the customer can redeem for discounts on future purchases.
      - `discountRate` number — Current discount rate (percentage) based on the customer's membership tier. Applied to purchases when baseDiscountPolicy is APPLY_DISCOUNT.
      - `cashbackRate` number — Current cashback rate (percentage) based on the customer's membership tier. Determines points earned per purchase when baseDiscountPolicy is CHARGE_SCORES.
      - `cashSpent` number — Total amount the customer has paid in currency across all completed purchases (excluding point payments). Used for automatic membership tier upgrades based on spending thresholds.
      - `savedFunds` number — Total amount the customer has saved through discounts, point redemptions, and certificates across all transactions.
      - `invitedCount` integer — Total number of people this customer has invited to join the loyalty program via referral link.
      - `effectiveInvitedCount` integer — Number of invited people who made at least one purchase (effective referrals). Used for membership tier upgrade conditions.
      - `operationsCount` integer — Total number of completed purchase transactions by this customer.
      - `fullRefundsCount` integer — Number of fully refunded transactions for this customer.
      - `note` string, nullable — Note.
      - `membershipTier` MembershipTier — Membership tier (loyalty level) configuration. Defines the discount/cashback rate and automatic upgrade conditions based on spending or referral count.
        - `uid` string — Tier ID.
        - `name` string, required — Tier name.
        - `rate` number, required — Tier rate.
        - `maxScoresDiscount` number, nullable — The maximum discount (in percentage) allowed when redeeming points.
        - `conditions` object — Conditions to upgrade customer tiers automatically.
          - `totalCashSpent` object, nullable — Upgrade to tier when customer reaches target `cashSpent`.
            - `target` number — Amount of cash spent.
          - `effectiveInvitedCount` object, nullable — Upgrade to tier when customer reaches target `effectiveInvitedCount`.
            - `target` integer — Amount of invited count.
      - `dateCreated` string, date-time, nullable — Date and time when customer was registered in company.
      - `lastTransactionTime` string, date-time, nullable — Date and time when the customer made the last transaction.
      - `pointsExpireIn` string, date-time, nullable — Date and time when the customer's points will be expired.
    - `channelName` string, nullable — Acquisition channel name
    - `email` string, nullable — Customer email
    - `tags` TagModel[] — List of tags
      - `id` integer — Tag identifier
      - `name` string — Tag name
  - `purchase` PurchaseCalc, required — Loyalty program calculation result for a purchase. Shows discount amounts, point values, final cash payment, and projected cashback. All monetary values are in company currency units.
    - `maxPoints` number — Maximum number of loyalty points the customer can redeem for this purchase, considering their balance and tier limits.
    - `total` number — Original purchase total before any loyalty benefits are applied (in currency units).
    - `skipLoyaltyTotal` number — Portion of the purchase total excluded from loyalty program benefits — no discount applied, no cashback earned (e.g., alcohol, tobacco, gift cards). In currency units.
    - `unredeemableTotal` number — Portion of the purchase total that cannot be paid with loyalty points (in currency units).
    - `discountAmount` number — Discount amount in currency units. Only applicable when baseDiscountPolicy is APPLY_DISCOUNT.
    - `discountPercent` number — Discount as a percentage of the total. Only applicable when baseDiscountPolicy is APPLY_DISCOUNT.
    - `points` number — Number of loyalty points being redeemed (deducted from customer balance) for this purchase.
    - `pointsPercent` number — Points redemption as a percentage of the total purchase amount.
    - `netDiscount` number — Total combined discount from both loyalty discount and point redemption (in currency units).
    - `netDiscountPercent` number — Total combined discount as a percentage (loyalty discount + point redemption).
    - `certificatePoints` number — Number of certificate points deducted (separate from regular loyalty points).
    - `cash` number — Final amount the customer pays in currency after all discounts and point redemptions. Use this value in POST /operations.
    - `cashTotal` number — Total amount to be paid including extra charges like delivery fees (in currency units).
    - `cashBack` number — Loyalty points the customer will earn from this purchase. Applied after operation is completed (may be deferred by deferPointsForDays setting).
    - `extras` object — Additional payments will not be taken into account by the loyalty program.
      - `delivery` number — Delivery cost (in currency units).
    - `maxScoresDiscount` number — The maximum discount (in percentage) allowed when redeeming points.

---

[API](https://skmtc.dev/uds/apis/uds-api.md) · [All operations](https://skmtc.dev/uds/apis/uds-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/uds/uds-api/revisions/6fbbbc79e671/schema)
