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

# Update discount code status



## OpenAPI

````yaml /loyalty/admin-api-swagger.json put /api/external/update-discount
openapi: 3.0.1
info:
  description: ''
  title: Admin APIs
  version: 0.0.1
servers:
  - url: https://loyalty-admin.appstle.com
security: []
tags:
  - description: >-
      Admin APIs for enrolling customers into the loyalty program, retrieving
      customer loyalty details, and updating profile information such as birth
      date.
    name: Customer Enrollment & Profile
  - description: >-
      Admin APIs for managing customer point balances, transaction history,
      point earning rules, top customers leaderboard, and approving pending
      transactions.
    name: Points & Earn Rules
  - description: >-
      Admin APIs for redeeming customer points, managing redemption rules, and
      validating or updating discount codes generated through loyalty
      redemptions.
    name: Redemptions & Discount Codes
  - description: >-
      Admin APIs for retrieving storefront widget label translations consumed by
      the loyalty widget on the merchant's storefront.
    name: Storefront Widgets & Labels
paths:
  /api/external/update-discount:
    put:
      tags:
        - Redemptions & Discount Codes
      summary: Update discount code status
      operationId: updateDiscount
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateDiscountRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              example:
                createAt: '2025-01-15T10:30:00Z'
                customerId: 67890
                discountCode: LOYALTY15OFF
                discountType: PERCENTAGE
                discountValue: 15
                expiryDate: '2025-06-30T23:59:59Z'
                id: 12345
                pointsRedeemed: 100
                status: USED
                usedAt: '2025-01-29T10:45:00Z'
              schema:
                $ref: '#/components/schemas/CustomerReward'
          description: Discount code status successfully updated
        '400':
          content:
            application/json:
              schema:
                example:
                  currentStatus: USED
                  error: Discount code already marked as used
                  usedAt: '2025-01-20T14:30:00Z'
                type: string
          description: Invalid request
        '401':
          content:
            application/json:
              schema:
                example:
                  error: Invalid API key
                type: string
          description: Unauthorized - Invalid or missing X-API-Key
      security:
        - X-API-Key: []
components:
  schemas:
    UpdateDiscountRequest:
      description: Request containing customer ID, discount code, and new status
      example:
        customerId: 67890
        discountCode: LOYALTY15OFF
        status: USED
      properties:
        customerId:
          description: >
            Shopify customer ID (numeric). Identifies which customer owns the
            discount code.

            Used to verify the discount code belongs to this customer before
            updating.

            Example: 67890
          example: 67890
          format: int64
          type: integer
        discountCode:
          description: >
            The discount code to update. Case-insensitive.

            Must be a valid loyalty discount code that belongs to the specified
            customer.

            Examples: "LOYALTY15OFF", "VIP20", "WELCOME10"
          example: LOYALTY15OFF
          maxLength: 100
          type: string
        status:
          description: |
            New status for the discount code. Valid values:
            - USED: Mark code as used after checkout (most common)
            - SUBSCRIPTION_ACTIVE: Mark code as active for subscription renewals
            - UNUSED: Reset code to unused state (use carefully)
            - EXPIRED: Manually expire a code

            Status transitions:
            - UNUSED → USED: Normal checkout flow
            - UNUSED → SUBSCRIPTION_ACTIVE: Subscription created
            - SUBSCRIPTION_ACTIVE → USED: Subscription ended
            - Any → EXPIRED: Manual expiration

            Note: Cannot mark already USED codes as USED again.
          enum:
            - USED
            - UNUSED
            - REFUNDED
            - EXPIRED
            - SUBSCRIPTION_ACTIVE
            - CANCELED
            - USED
            - UNUSED
            - SUBSCRIPTION_ACTIVE
            - EXPIRED
          example: USED
          type: string
      required:
        - customerId
        - discountCode
        - status
      type: object
    CustomerReward:
      properties:
        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

````