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

# Return an unused reward for its points

> Cancels one of the authenticated customer's redeemed discount codes and credits the redeemed points back.

Only available when the merchant enabled "Let customers return unused rewards" in Advanced Settings.
The reward must belong to the authenticated customer, be UNUSED, not expired, bought with points
(not store credit or a gifted VIP/birthday/referral reward), and Shopify must report the code was never used.
The discount code is removed from Shopify before the points are credited.

Returns the updated customer loyalty details, like redeem-points.




## OpenAPI

````yaml /loyalty/storefront-api-swagger.json post /loyalty/cp/api/return-reward/{rewardId}
openapi: 3.0.1
info:
  description: >
    These endpoints are called **from the shop's storefront, in the shopper's
    browser**, through the Shopify App Proxy:

    `https://{store-domain}/apps/loyalty/cp/api/...`. Shopify signs every
    proxied request and attaches the logged-in

    customer (`logged_in_customer_id`), and that signature is the only
    credential these endpoints accept.


    - **No API key, no Bearer token, no customer ID parameter.** The customer is
    always the one logged in to the storefront.

    - Requests sent straight to `loyalty-admin.appstle.com` (including this
    page's "Try it" button, Postman, or a server)
      have no App Proxy signature and are rejected with **401 Unauthorized**.
    - Non-GET requests must also send `X-Requested-With: XMLHttpRequest`.

    - If the merchant changed the proxy path in Advanced Settings, replace
    `/apps/loyalty` with that path.


    **Headless storefronts and server-to-server integrations** can't use the App
    Proxy. Use the Admin APIs instead

    (`/api/external/**` with the `X-API-Key` header, passing `customerId` or
    `customerEmail` explicitly).
  title: Storefront APIs
  version: 0.0.1
servers:
  - description: >-
      Shop's storefront domain (App Proxy). Must be called from the storefront
      by a logged-in customer.
    url: https://{storeDomain}/apps
    variables:
      storeDomain:
        default: your-store.myshopify.com
security: []
tags:
  - description: >-
      Storefront APIs for the signed-in customer to enroll, enable the loyalty
      program, view their loyalty profile, sync metafields, and update profile
      attributes.
    name: Customer Enrollment & Profile
  - description: >-
      Storefront APIs for the signed-in customer to view point transactions,
      claim social-media reward points, and record store visits.
    name: Points & Earn Rules
  - description: >-
      Storefront APIs for the signed-in customer to redeem loyalty points for
      rewards or discount codes.
    name: Redemptions & Discount Codes
  - description: >-
      Storefront APIs for managing the signed-in customer's referral activity:
      generating referral URLs, sending invites, viewing referral history, and
      accepting referral offers.
    name: Referrals
  - description: >-
      Storefront APIs for the signed-in customer to submit product reviews and
      retrieve existing reviews for a product.
    name: Reviews
  - description: >-
      Storefront APIs for retrieving product and collection data, proxied
      through the Shopify Storefront API for loyalty widgets.
    name: Product Catalog
paths:
  /loyalty/cp/api/return-reward/{rewardId}:
    post:
      tags:
        - Redemptions & Discount Codes
      summary: Return an unused reward for its points
      description: >
        Cancels one of the authenticated customer's redeemed discount codes and
        credits the redeemed points back.


        Only available when the merchant enabled "Let customers return unused
        rewards" in Advanced Settings.

        The reward must belong to the authenticated customer, be UNUSED, not
        expired, bought with points

        (not store credit or a gifted VIP/birthday/referral reward), and Shopify
        must report the code was never used.

        The discount code is removed from Shopify before the points are
        credited.


        Returns the updated customer loyalty details, like redeem-points.
      operationId: returnReward
      parameters:
        - description: ID of the customer's reward to return
          in: path
          name: rewardId
          required: true
          schema:
            format: int64
            type: integer
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerLoyaltyResponseVM'
          description: Reward cancelled and points returned
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerLoyaltyResponseVM'
          description: >-
            Reward can't be returned. errorKey is one of rewardReturnDisabled,
            idnotfound, rewardNotUnused, rewardNotReturnable, rewardExpired,
            rewardUsageUnverified, rewardActionInProgress
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerLoyaltyResponseVM'
          description: Customer not authenticated
components:
  schemas:
    CustomerLoyaltyResponseVM:
      properties:
        achievableTierId:
          format: int64
          type: integer
        availablePoints:
          format: double
          type: number
        createAt:
          format: date-time
          type: string
        creditedPoints:
          format: double
          type: number
        currentVipTier:
          type: string
        customerStatus:
          enum:
            - ACTIVE
            - INACTIVE
            - EXCLUDED
            - EXCLUDED_BY_CUSTOMER
          type: string
        dob:
          format: date
          type: string
        dobYearProvided:
          type: boolean
        expiringPointsAmount:
          format: double
          type: number
        pendingPoints:
          format: double
          type: number
        pointsExpireAt:
          format: date-time
          type: string
        referralLink:
          type: string
        referredCompleted:
          format: int64
          type: integer
        rewardedForCreatingAccount:
          type: boolean
        rewardedForFacebook:
          type: boolean
        rewardedForInstagram:
          type: boolean
        rewardedForNewsLetter:
          type: boolean
        rewardedForPinterest:
          type: boolean
        rewardedForSharingOnFacebook:
          type: boolean
        rewardedForSharingOnX:
          type: boolean
        rewardedForSms:
          type: boolean
        rewardedForTiktok:
          type: boolean
        rewardedForTwitter:
          type: boolean
        rewardedForYoutube:
          type: boolean
        rewards:
          items:
            $ref: '#/components/schemas/CustomerReward'
          type: array
        spentAmount:
          format: double
          type: number
        storeCreditBalance:
          format: double
          type: number
        storeCreditCurrency:
          type: string
        vipTierExpiredAt:
          format: date-time
          type: string
        vipTierSpentAmount:
          format: double
          type: number
      type: object
    CustomerReward:
      properties:
        activeFrom:
          format: date-time
          type: string
        amount:
          format: double
          type: number
        createAt:
          format: date-time
          type: string
        customerId:
          format: int64
          type: integer
        description:
          type: string
        discountCode:
          type: string
        discountCodeId:
          type: string
        expireDate:
          format: date-time
          type: string
        id:
          format: int64
          type: integer
        lastExpiryReminderSentDate:
          format: date-time
          type: string
        orderId:
          format: int64
          type: integer
        orderName:
          type: string
        pointRedeemRuleId:
          format: int64
          type: integer
        pointTransactionId:
          format: int64
          type: integer
        productData:
          type: string
        rewardType:
          enum:
            - STORE_CREDIT
            - DISCOUNT_CODE
            - POINTS
          type: string
        shop:
          type: string
        status:
          enum:
            - USED
            - UNUSED
            - REFUNDED
            - EXPIRED
            - SUBSCRIPTION_ACTIVE
            - CANCELED
          type: string
        usageCount:
          format: int64
          type: integer
        usedAt:
          format: date-time
          type: string
        variantId:
          format: int64
          type: integer
      required:
        - createAt
        - customerId
        - discountCode
        - shop
        - status
      type: object

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.