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

# Reverse Earned Points

> When a member cancels a purchase transaction or returns an order, this endpoint cancels all the points earned in that transaction.



## OpenAPI

````yaml member post /v2/earn/reverse
openapi: 3.0.1
info:
  title: Loyalty (Member)
  description: >-
    fabric **Loyalty** formerly **Member** is a Loyalty Management System (LMS)
    that enables marketers to create multiple loyalty strategies under a loyalty
    program to cater to various businesses and customer segments. <br />
    **Member overview**: <br /> During onboarding, you are given the necessary
    **credentials** (client_id and client_secret) to obtain an access token,
    which is required to run every call. Membership hierarchy is organized into
    Programs, Clubs, and Tiers. <br /> **Program** is the first hierarchy level
    and is where rewards and benefits are configured for the organization. <br
    /> **Club** is the second hierarchy level and is where Rules for the program
    are configured. <br />Each Club must have at least one **Tier**, which is
    used to define membership and to configure criteria and thresholds
    (including free vs paid). Additional hierarchy levels can be added to
    support the needs of your business.  <br /> Members are always enrolled into
    a **Default Tier** within a club. When members make purchases, they earn
    Points based on the rules set at the club level and/or based on promotions.
    When points in a member account reach a predefined **Threshold Value**,
    points are converted to **Rewards**. This conversion may be manual or
    automatic depending on the program configuration. Members can **Redeem**
    their rewards within the reward **Expiry Period**. Account point balances
    are updated after each point-impacting activity.
  version: 1.0.0
  contact:
    email: support@fabric.inc
  license:
    name: fabric Inc
    url: https://fabric.inc
servers:
  - url: https://vanilla-dev02-loyalty.fabric.zone/api
    description: For developers to work outside of the production environment.
  - url: https://vanilla-stg-loyalty.fabric.zone/api
    description: Replica of the production environment for testing.
  - url: https://loyalty-sbx.fabric.zone/api
    description: >-
      An isolated testing environment (UAT) to run programs without affecting
      the application, system or platform on which they run.
  - url: https://loyalty.fabric.zone/api
    description: Production environment.
security:
  - bearerAuth: []
paths:
  /v2/earn/reverse:
    post:
      tags:
        - Earn
      summary: Reverse Earned Points
      description: >-
        When a member cancels a purchase transaction or returns an order, this
        endpoint cancels all the points earned in that transaction.
      operationId: earn_reverse_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EarnReverse'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EarnReverseApiResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericResponseClass1'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericResponseClass2'
components:
  schemas:
    EarnReverse:
      required:
        - profileId
        - activityTimestamp
        - checkForDuplicateTransaction
        - discountValue
        - entityReference
        - fetchUpdatedMemberPointTotals
        - netAmount
        - reverseTransactionExternalRef
        - totalTax
        - totalAmountPaid
        - transactionExternalReference
        - transactionGrossAmount
        - transactionTypeExternalReference
      type: object
      description: Transaction details to reverse the earned points
      properties:
        profileId:
          type: string
          description: >-
            Profile ID of the member. In an ecosystem, it acts as a primary ID
            to keep the various systems (apps, websites, etc.) in sync.
            `profileId` is generated as part of the `Enroll Member` endpoint -
            POST /members.
          example: 67460e74-02e3-11e8-b443-00163e990bdb
          format: uuid
        entityReference:
          maxLength: 15
          minLength: 3
          type: string
          description: >-
            Unique name or ID of store (or entity) where the transaction took
            place.
          example: LIBERTY_STORE
        reverseTransactionExternalRef:
          maxLength: 100
          minLength: 1
          type: string
          description: External reference number of the transaction to be reversed
          example: LOYALTY-12345
        transactionTypeExternalReference:
          maxLength: 15
          minLength: 3
          type: string
          description: >-
            External reference for transaction type such `purchase`, `return`,
            or `exchange` (configurable as per requirement).
          example: RETURN
        activityTimestamp:
          type: string
          description: >-
            Activity date (in UTC format). An activity could be enrolling a
            member, making a transaction, etc.
          example: '2020-02-08 09:30:26'
          format: date-time
        transactionExternalReference:
          maxLength: 100
          minLength: 1
          type: string
          description: >-
            Order ID or receipt ID for the transaction (received from the
            store). This is needed to cancel or return an order.
          example: LOYALTY-8675
        checkForDuplicateTransaction:
          type: integer
          description: >-
            0 indicates the system allows duplicate and 1 indicates there is a
            validation in place to identify duplicates.
          example: 1
          format: int32
        fetchUpdatedMemberPointTotals:
          type: integer
          description: >-
            A value of 1 indicates the total points (including the points earned
            in the latest transaction) are calculated and displayed to the
            member. A value of 0 indicates the total points are not calculated
            and the member is only notified if the earn is successful. The
            response is faster when the value is 0 because there is no
            calculations involved.
          example: 1
          format: int32
        transactionGrossAmount:
          type: number
          format: float
          description: >-
            Transaction gross amount. For example, gross amount of item1 is
            50.00 and gross amount of item2 is 100.00, then
            transactionGrossAmount is 150.00
          example: -100
        discountValue:
          type: number
          description: Discount amount applied on the transaction.
          example: -20
          nullable: true
          format: float
        totalAmountPaid:
          description: >-
            Total amount paid for the items. For example, the amount paid for
            item1 is 100.00 and the amount of item2 is 200.00 so the total
            amount paid is 300.00.
          example: -80
          type: number
          format: float
        totalTax:
          type: number
          format: float
          description: >-
            Final tax amount based on the number of items in the transaction.
            Example - the tax amount of item1 is 2.00; Tax amount of item2 is
            2.00. The totalTax is 4.00.
          example: -10
        netAmount:
          type: number
          format: float
          description: >-
            Net transaction amount. Example - the net amount of item1 is 100.00
            and net amount of item2 is 200.00. So, the netAmount is 300.00.
          example: -70
        discounts:
          type: array
          description: Discount details.
          items:
            $ref: '#/components/schemas/DiscountData'
        issueAuditUser:
          maxLength: 100
          minLength: 1
          type: string
          description: Representative who issued the earn transaction.
          example: Joe
          nullable: true
        cancelAuditUser:
          title: Cancelaudituser
          maxLength: 100
          minLength: 1
          type: string
          description: Representative who cancelled the earn transaction.
          example: Mia
          nullable: true
        redemptionCode:
          description: >-
            Redemption code used to identify and link the rewards used in a
            specific transaction. This code is generated in the response of the
            `Issue Variable Rewards` endpoint - POST
            /api/v1/redeem/reward/issue.
          type: array
          items:
            type: string
          nullable: true
          example: []
        setToPending:
          title: Settopending
          type: boolean
          description: >-
            true: Points in Pending status <br /> false: Points in Active
            status. **Note**: The time period for Pending state is configurable.
        reasonCode:
          title: Reasoncode
          maxLength: 4
          minLength: 1
          type: string
          description: >-
            Reason code to categorize transactions. A parent company can
            configure custom codes for their stores as required.
          example: '9393'
          nullable: true
        reasonDescription:
          title: Reasondescription
          maxLength: 20
          minLength: 1
          type: string
          description: >-
            When reason codes are not configured, store can make use of the
            reason description.
          example: returning item
          nullable: true
        transactionItems:
          type: array
          description: Details of the transaction items to be reversed.
          items:
            $ref: '#/components/schemas/TransactionItemsSerializerEarnReverse'
        isCompanyUser:
          title: Iscompanyuser
          type: boolean
          description: >-
            true: Company user is running the endpoint <br /> false: Client user
            is running the endpoint.
          default: false
    EarnReverseApiResponse:
      type: object
      description: Metadata for the `Earn Reverse` response
      properties:
        status:
          title: Status
          type: integer
          description: Status code for the call
          example: 201
          format: int32
        message:
          title: Message
          type: string
          description: Message corresponding to the status code.
          example: earn reversed
        errors:
          title: Errors
          type: object
          description: In a successful response, this is always a blank object
          properties: {}
          example: {}
        data:
          $ref: '#/components/schemas/EarnReverseApiResponseDetails'
          description: Earn Reverse response details
    GenericResponseClass1:
      type: object
      description: Bad request
      properties:
        message:
          title: Message
          minLength: 1
          type: string
          description: Message corresponding to the call.
          example: Error message string
        errors:
          title: Errors
          type: object
          properties: {}
          description: A dictionary of lists with different number of errors or exceptions.
          example:
            ExceptionString:
              - Invalid Field
        data:
          title: Data
          type: object
          properties: {}
          description: Returns data in the form of a list of dictionaries or null
          example: null
        status:
          title: Status
          type: integer
          description: Status code of the call
          example: 400
          format: int32
    GenericResponseClass2:
      type: object
      description: Unauthorized
      properties:
        detail:
          title: Detail
          type: string
          description: Message corresponding to the response
          example: Authentication Failed
    DiscountData:
      required:
        - id
        - value
      type: object
      description: Discount details
      properties:
        type:
          title: Type
          minLength: 1
          type: string
          description: Discount type (configurable).
          example: promotion
        description:
          title: Description
          type: string
          description: Description of the discount.
          example: Black Friday discount
        id:
          title: Id
          type: integer
          description: Discount ID
          example: 2345
          format: int32
        value:
          title: Value
          type: number
          format: float
          description: Discount amount
          example: 20
    TransactionItemsSerializerEarnReverse:
      required:
        - SKU
        - grossAmount
        - itemPrice
        - itemQuantity
        - lineNumber
        - netAmount
        - taxAmount
        - totalAmountPaid
      type: object
      description: Details of items returned
      properties:
        grossAmount:
          title: Grossamount
          type: number
          format: float
          description: Gross amount of the item, before discount
          example: 100
        taxAmount:
          title: Taxamount
          type: number
          format: float
          description: Tax amount of the item
          example: 10
        discounts:
          type: array
          description: Details of item-level discounts
          items:
            $ref: '#/components/schemas/DiscountData'
          example: []
        totalAmountPaid:
          title: Totalamountpaid
          type: number
          format: float
          description: Amount paid for the item
          example: 100
        netAmount:
          title: Netamount
          type: number
          format: float
          description: Item net amount, after any item-level discounts.
          example: 90
        categories:
          type: array
          items:
            minLength: 1
            type: string
            description: Item category name
            example: Supplements
        itemName:
          title: Itemname
          minLength: 1
          type: string
          description: Item name
          example: demo item
        itemPrice:
          title: Itemprice
          type: number
          description: Item price
          example: 45
          format: float
        itemQuantity:
          title: Itemquantity
          type: integer
          description: Item quantity
          example: 2
          format: int32
        SKU:
          title: Sku
          maxLength: 100
          minLength: 1
          type: string
          description: Stock Keeping Unit (SKU) of the item.
          example: '12345'
        lineNumber:
          title: Linenumber
          type: integer
          description: Line number of the item in the overall transaction
          example: 1
          format: int32
        UOM:
          title: Uom
          minLength: 1
          type: string
          description: Unit of Measurement (UOM)
          example: unit
        couponCodes:
          type: array
          items:
            minLength: 1
            type: string
            description: Coupon Codes
          example: []
    EarnReverseApiResponseDetails:
      required:
        - profileId
        - transactionNumber
        - transactionType
      type: object
      description: Details of points reversal
      properties:
        transactionCode:
          title: Transactioncode
          type: string
          description: Transaction Code
          example: 62660e74-02e3-11e8-b443-00163e990abc
          format: uuid
        profileId:
          title: Profileid
          type: string
          description: >-
            Profile ID of member. In an ecosystem, it acts as a primary ID to
            keep the various systems (apps, websites, etc.) in sync.
          example: 67460e74-02e3-11e8-b443-00163e990bdb
          format: uuid
        transactionNumber:
          title: Transactionnumber
          minLength: 1
          type: string
          description: >-
            Transaction number. This is same as the transactionExternalReference
            and indicates a unique order ID or the receipt ID.
          example: LOYALTY-8675
        transactionDateTime:
          type: string
          description: Transaction date, in UTC format.
          example: '2020-03-20T14:28:23.382748'
          format: date
        activityTimestamp:
          title: Activitytimestamp
          type: string
          description: Transaction activity time, in UTC format.
          example: '2020-03-20T14:28:23.382748'
          format: date
        totalAmountPaid:
          title: Totalamountpaid
          description: >-
            Total amount paid for the items. For example, the amount paid for
            item1 is 100.00 and the amount of item2 is 200.00 so the total
            amount paid is 300.00.
          example: -80
          type: number
          format: float
        totalTax:
          title: Totaltax
          type: number
          description: Total tax applied on items eligible for earning points.
          example: -10
          format: float
        transactionNetAmount:
          title: Transactionnetamount
          type: number
          format: float
          description: Net total amount of the transaction.
          example: -70
        points:
          title: points
          type: number
          format: float
          description: Total points reversed in this transaction.
          example: -70
        basePoints:
          title: Basepoints
          type: number
          format: float
          description: Base points reversed in this transaction
          example: 70
        bonusPoints:
          title: Bonuspoints
          type: number
          format: float
          description: Bonus points reversed in this transaction
          example: 0
        promotionalPoints:
          title: Promotionalpoints
          type: number
          format: float
          description: Promotional points reversed in this transaction
          example: 0
        currentPointsBalance:
          title: currentPointsBalance
          type: number
          format: float
          description: Points available in the member's account after this transaction.
          example: 500
        reasonCode:
          title: Reasoncode
          minLength: 1
          type: string
          description: >-
            Reason code to categorize transactions. A parent company can
            configure custom codes for their stores as required.
          example: '9393'
        reasonDescription:
          title: Reasondescription
          minLength: 1
          type: string
          description: >-
            When reason codes are not configured, store can make use of the
            reason description to add notes on the transaction.
          example: returning item
        discounts:
          type: array
          description: Discount details.
          items:
            $ref: '#/components/schemas/DiscountData'
        discountValue:
          title: Discountvalue
          type: number
          format: float
          description: Discount amount for this transaction.
          example: 20
        transactionItems:
          type: array
          description: Details of the reversed transaction items
          items:
            $ref: '#/components/schemas/TransactionItemsSerializerEarnReverseResponse'
        rewards:
          type: array
          description: Details of the variable rewards.
          items:
            $ref: '#/components/schemas/Reward'
          example: []
        issueAuditUser:
          title: Issueaudituser
          minLength: 1
          type: string
          description: Representative who issued the earn transaction.
          example: Joe
          nullable: true
        cancelAuditUser:
          title: Cancelaudituser
          minLength: 1
          type: string
          description: Representative who cancelled the earn transaction.
          example: Mia
          nullable: true
        deviceId:
          title: Deviceid
          type: string
          description: Device ID used to reverse the transaction
          example: D10626
        transactionType:
          title: Transactiontype
          type: string
          description: >-
            This field specifies the type of transaction activity, such as `Earn
            Transaction`, `Burn Transaction`, `Earn Reverse Transaction` and so
            on
          example: EARN_REVERSE
          enum:
            - EARN
            - BURN
            - EXPIRY
            - EARN_REVERSE
            - BURN_REVERSE
            - ADJUSTMENT
            - DEDUCT
            - TRANSFER
            - MERGE
            - FORFEITED
            - CONVERT
            - UNMERGE
        transactionActivityType:
          title: Transactionactivitytype
          type: string
          description: Configurable alias for the `transactionType`
          example: TRANS_CANCEL
        transactionTypeExternalReference:
          title: Transactiontypeexternalreference
          type: string
          description: >-
            External reference for the transaction type such as `purchase`,
            `return`, or `exchange`. Supports any value as configured by store.
          example: RETURN
        transactionExternalReference:
          title: Transactionexternalreference
          minLength: 1
          type: string
          description: >-
            Order ID or receipt ID for the transaction (received from the
            store). This is unique and needed to cancel or return an order.
          example: LOYALTY-8675
        transactionEntityReference:
          title: Transactionentityreference
          minLength: 1
          type: string
          description: Reference to the entity where the transaction occurred
          example: LIBERTY_STORE
    TransactionItemsSerializerEarnReverseResponse:
      required:
        - SKU
        - categories
        - grossAmount
        - itemPrice
        - itemQuantity
        - lineNumber
        - netAmount
        - taxAmount
      type: object
      description: Details of the items returned
      properties:
        grossAmount:
          title: Grossamount
          type: number
          format: float
          description: Gross amount of the item, before discount
          example: 100
        taxAmount:
          title: Taxamount
          type: number
          format: float
          description: Tax amount of item
          example: 10
        discounts:
          type: array
          description: Details of item-level discounts
          items:
            $ref: '#/components/schemas/DiscountData'
          example: []
        netAmount:
          title: Netamount
          type: number
          format: float
          description: Item net amount, after any item-level discounts.
          example: 90
        categories:
          type: array
          items:
            minLength: 1
            type: string
            description: Item category name
            example: Supplements
        itemName:
          minLength: 1
          type: string
          description: Item name
          example: demo item
        itemPrice:
          title: Itemprice
          type: number
          description: Item price
          example: 45
          format: float
        itemQuantity:
          title: Itemquantity
          type: integer
          description: Item quantity.
          example: 2
          format: int32
        SKU:
          title: Sku
          maxLength: 100
          minLength: 1
          type: string
          description: Stock Keeping Unit (SKU) of item
          example: '12345'
        lineNumber:
          title: Linenumber
          type: integer
          description: Line number of the item in the overall transaction
          example: 1
          format: int32
        UOM:
          title: Uom
          minLength: 1
          type: string
          description: Unit of Measurement (UOM)
          example: unit
        couponCodes:
          type: array
          items:
            minLength: 1
            type: string
            description: Coupon Codes
          example: []
    Reward:
      type: object
      description: Reward details
      properties:
        reward_id:
          title: Reward ID
          type: integer
          description: >-
            Variable reward IDs (also referred to as reward certificate).
            **Note**:Multiple rewards can be used a transaction.
          example: 111
          format: int32
        core_rule_id:
          title: Core rule ID
          type: integer
          description: ID of the core rule based on which the rewards are generated.
          example: 2
          format: int32
        reward_portion:
          title: Reward portion
          type: number
          format: float
          description: Total reward amount.
          example: 10
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````