> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetLoyaltyCoupon

# Package: rewards

# Namespace: LoyaltyCoupons

# Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/rewards/coupons/get-loyalty-coupon.md

## Permission Scopes:
Read Loyalty: SCOPE.DC-LOYALTY.READ-LOYALTY

## Introduction

Retrieves a loyalty coupon.

---

## REST API

### Schema

```
 Method: getLoyaltyCoupon
 Description: Retrieves a loyalty coupon.
 URL: https://www.wixapis.com/loyalty-coupons/v1/coupons/{loyaltyCouponId}
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  loyaltyCouponId
 Method parameters: 
   param name: loyaltyCouponId | type:   none | required: true 
 Return type: GetLoyaltyCouponResponse
  - name: loyaltyCoupon | type: LoyaltyCoupon | description: Retrieved loyalty coupon.  
     - name: id | type: string | description: Loyalty coupon GUID.  | read-only: true | validation: format GUID
     - name: accountId | type: string | description: Loyalty [account GUID](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/account-object.md) of the customer that redeemed points for a coupon.  | read-only: true | validation: format GUID
     - name: memberId | type: string | description: Member GUID of the customer that redeemed points for a coupon. See the Members API for more information.  | read-only: true | validation: format GUID
     - name: transactionId | type: string | description: [Transaction GUID](https://dev.wix.com/docs/rest/crm/loyalty-program/transactions/loyalty-transaction-object.md) for the transaction that created a coupon.  | read-only: true | validation: format GUID
     - name: couponReference | type: CouponReference | description: Reference coupon information for the corresponding [coupon](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/coupon-object.md) that is created along with the loyalty coupon.  | read-only: true 
        - name: couponId | type: string | description: Coupon GUID.  | read-only: true | validation: format GUID
        - name: code | type: string | description: Coupon code.  Unique code entered by a customer to apply the coupon.  | read-only: true | validation: maxLength 20
        - name: name | type: string | description: Name of coupon.  | read-only: true | validation: maxLength 80
        - name: specification | type: Specification | description: The information to use when creating the coupon.  | read-only: true 
           - ONE-OF: 
              - name: moneyOffAmount | type: number | description: Fixed price discount.  | validation: minimum 0.01
              - name: percentOffRate | type: number | description: Discount as a percentage.  
              - name: freeShipping | type: boolean | description: Free shipping. If true, the coupon applies to all items in all `namespaces` on a site.  
              - name: fixedPriceAmount | type: number | description: Specific sale price. Currently only supported for coupons with a `stores` `namespace`.  
              - name: buyXGetY | type: BuyXGetY | description: Free products when making a purchase. `buyXGetY` is an object that specifies `x` and `y` in the following scenario: if a visitor purchases x number of products, they receive y number of products for free. C urrently only supported for coupons with a `stores` `namespace`.  
                 - name: x | type: integer | description: Number of purchased items required to receive free items.  
                 - name: y | type: integer | description: Number of items received for free if required number of items were purchased.  
           - ONE-OF: 
              - name: scope | type: Scope | description: Scope of the coupon. When no scope is defined, the coupon applies to all items in all `namespaces` in the site.  
                 - name: name | type: string | description: Group within a `namespace` for which the coupon is applicable.  If no group is specified, the coupon applies to all items in the namespace. `group` is required in some namespaces. See [Scope Values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values) for a list of currently supported groups for each namespace.  
                 - name: entityId | type: string | description: GUID of the specific entity in the group for which the coupon is applicable.  If no `entityId` is specified, the coupon applies to all entities in the group. In some cases when a group is specified, an `entityId` is required. See [Scope Values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values) for a list of currently supported entities for each namespace and group.  
                 - name: namespace | type: string | description: Wix application for which the coupon is applicable.  One of the following: + `"stores"` + `"bookings"` + `"events"` + `"pricingPlans"`  
              - name: minimumSubtotal | type: number | description: The coupon is only applicable when the order subtotal is over this amount.  | validation: format double
           - name: name | type: string | description: Name of coupon.  
           - name: type | type: Type | description:   
                 - enum: UNKNOWN, MONEY_OFF_AMOUNT, PERCENT_OFF_RATE, FREE_SHIPPING, FIXED_PRICE_AMOUNT, BUY_X_GET_Y
           - name: limitedToOneItem | type: boolean | description: Whether the coupon is limited to 1 discount per order. If true and a customer pays for multiple items that the coupon applies to, only the lowest priced item is discounted. Coupons with a `bookings` `namespace` are always limited to 1 item.  
           - name: appliesToSubscriptions | type: boolean | description: Whether the coupon also applies to subscriptions.  
           - name: discountedCycleCount | type: integer | description: Specifies the amount of cycles to apply the discount to for a subscription item.  Can only be set when `appliesToSubscriptions` is `TRUE` and `specification.scope.namespace` is `pricingPlans`. If `discountedCycleCount` is empty, the coupon applies to all available cycles.  Min: `1`  Max: `999`  | validation: format int32
        - name: deleted | type: boolean | description: Whether the referenced coupon was deleted.  | read-only: true 
     - name: status | type: Status | description: Loyalty coupon status.  This status relates to the corresponding coupon that is created at the same time as the loyalty coupon and is included in `couponReference`.  | read-only: true 
         - enum:
         -     UNKNOWN: Unknown status.
         -     PENDING: The reference coupon was created but the loyalty points have not been redeemed yet.
         -     ACTIVE: The reference coupon is active and available to the customer.
         -     APPLIED: The reference coupon was applied and is no longer available for use.
         -     FAILED: The reference coupon was created but something went wrong when redeeming points from the loyalty account.
         -     ARCHIVED: The reference coupon was deleted.
     - name: rewardName | type: string | description: Name of reward that was redeemed to create this coupon.  | read-only: true | validation: minLength 1, maxLength 50
     - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty coupon is updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty coupon.  | validation: format uint64, immutable
     - name: createdDate | type: string | description: Date and time the loyalty coupon was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the loyalty coupon was last updated.  | read-only: true | validation: format date-time
     - name: refundable | type: boolean | description: Whether the loyalty coupon was created in a "refundable workflow" i.e. checkout-exchange, and therefore can be deleted in the background. Refundable coupons should not be visible to customers in the UI.  | read-only: true 


```

### Examples

### Get loyalty coupon
```curl
curl -X GET \
  'https://www.wixapis.com/loyalty-coupons/v1/coupons/c90918b2-e9a5-4147-b4a4-953e235b9ddd' \
  -H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.loyalty.coupons.getLoyaltyCoupon(loyaltyCouponId)
 Description: Retrieves a loyalty coupon.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  loyaltyCouponId
 Method parameters: 
   param name: loyaltyCouponId | type: string | description: GUID of the loyalty coupon to retrieve. | required: true | validation: format GUID
 Return type: PROMISE<LoyaltyCoupon>
  - name: _id | type: string | description: Loyalty coupon GUID.  | read-only: true | validation: format GUID
  - name: accountId | type: string | description: Loyalty [account GUID](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/account-object.md) of the customer that redeemed points for a coupon.  | read-only: true | validation: format GUID
  - name: memberId | type: string | description: Member GUID of the customer that redeemed points for a coupon. See the Members API for more information.  | read-only: true | validation: format GUID
  - name: transactionId | type: string | description: [Transaction GUID](https://dev.wix.com/docs/rest/crm/loyalty-program/transactions/loyalty-transaction-object.md) for the transaction that created a coupon.  | read-only: true | validation: format GUID
  - name: couponReference | type: CouponReference | description: Reference coupon information for the corresponding [coupon](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/coupon-object.md) that is created along with the loyalty coupon.  | read-only: true 
     - name: couponId | type: string | description: Coupon GUID.  | read-only: true | validation: format GUID
     - name: code | type: string | description: Coupon code.  Unique code entered by a customer to apply the coupon.  | read-only: true | validation: maxLength 20
     - name: name | type: string | description: Name of coupon.  | read-only: true | validation: maxLength 80
     - name: specification | type: Specification | description: The information to use when creating the coupon.  | read-only: true 
        - ONE-OF: 
           - name: moneyOffAmount | type: number | description: Fixed price discount.  | validation: minimum 0.01
           - name: percentOffRate | type: number | description: Discount as a percentage.  
           - name: freeShipping | type: boolean | description: Free shipping. If true, the coupon applies to all items in all `namespaces` on a site.  
           - name: fixedPriceAmount | type: number | description: Specific sale price. Currently only supported for coupons with a `stores` `namespace`.  
           - name: buyXGetY | type: BuyXGetY | description: Free products when making a purchase. `buyXGetY` is an object that specifies `x` and `y` in the following scenario: if a visitor purchases x number of products, they receive y number of products for free. C urrently only supported for coupons with a `stores` `namespace`.  
              - name: x | type: integer | description: Number of purchased items required to receive free items.  
              - name: y | type: integer | description: Number of items received for free if required number of items were purchased.  
        - ONE-OF: 
           - name: scope | type: Scope | description: Scope of the coupon. When no scope is defined, the coupon applies to all items in all `namespaces` in the site.  
              - name: name | type: string | description: Group within a `namespace` for which the coupon is applicable.  If no group is specified, the coupon applies to all items in the namespace. `group` is required in some namespaces. See [Scope Values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values) for a list of currently supported groups for each namespace.  
              - name: entityId | type: string | description: GUID of the specific entity in the group for which the coupon is applicable.  If no `entityId` is specified, the coupon applies to all entities in the group. In some cases when a group is specified, an `entityId` is required. See [Scope Values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values) for a list of currently supported entities for each namespace and group.  
              - name: namespace | type: string | description: Wix application for which the coupon is applicable.  One of the following: + `"stores"` + `"bookings"` + `"events"` + `"pricingPlans"`  
           - name: minimumSubtotal | type: number | description: The coupon is only applicable when the order subtotal is over this amount.  
        - name: name | type: string | description: Name of coupon.  
        - name: type | type: Type | description:   
             - enum: UNKNOWN, MONEY_OFF_AMOUNT, PERCENT_OFF_RATE, FREE_SHIPPING, FIXED_PRICE_AMOUNT, BUY_X_GET_Y
        - name: limitedToOneItem | type: boolean | description: Whether the coupon is limited to 1 discount per order. If true and a customer pays for multiple items that the coupon applies to, only the lowest priced item is discounted. Coupons with a `bookings` `namespace` are always limited to 1 item.  
        - name: appliesToSubscriptions | type: boolean | description: Whether the coupon also applies to subscriptions.  
        - name: discountedCycleCount | type: integer | description: Specifies the amount of cycles to apply the discount to for a subscription item.  Can only be set when `appliesToSubscriptions` is `TRUE` and `specification.scope.namespace` is `pricingPlans`. If `discountedCycleCount` is empty, the coupon applies to all available cycles.  Min: `1`  Max: `999`  | validation: format int32
     - name: deleted | type: boolean | description: Whether the referenced coupon was deleted.  | read-only: true 
  - name: status | type: Status | description: Loyalty coupon status.  This status relates to the corresponding coupon that is created at the same time as the loyalty coupon and is included in `couponReference`.  | read-only: true 
     - enum:
     -     UNKNOWN: Unknown status.
     -     PENDING: The reference coupon was created but the loyalty points have not been redeemed yet.
     -     ACTIVE: The reference coupon is active and available to the customer.
     -     APPLIED: The reference coupon was applied and is no longer available for use.
     -     FAILED: The reference coupon was created but something went wrong when redeeming points from the loyalty account.
     -     ARCHIVED: The reference coupon was deleted.
  - name: rewardName | type: string | description: Name of reward that was redeemed to create this coupon.  | read-only: true | validation: minLength 1, maxLength 50
  - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty coupon is updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty coupon.  | validation: format uint64, immutable
  - name: _createdDate | type: Date | description: Date and time the loyalty coupon was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the loyalty coupon was last updated.  | read-only: true 
  - name: refundable | type: boolean | description: Whether the loyalty coupon was created in a "refundable workflow" i.e. checkout-exchange, and therefore can be deleted in the background. Refundable coupons should not be visible to customers in the UI.  | read-only: true 


```

### Examples

### Get loyalty coupon (with elevated permissions)
```javascript
import { coupons } from "@wix/loyalty";
import { auth } from "@wix/essentials";

/* Sample loyaltyCouponId value:
 *
 * {
 *     "loyaltyCouponId": "6fb2cdc0-863f-4b4b-b76d-a73608654aee"
 * }
 */ 

const elevatedGetLoyaltyCoupon = auth.elevate(coupons.getLoyaltyCoupon);

async function getLoyaltyCoupon(loyaltyCouponId) {
  try {
    const result = await elevatedGetLoyaltyCoupon(loyaltyCouponId);
    return result;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "_createdDate": "2024-06-12T08:14:16.884Z",
 *   "_id": "6fb2cdc0-863f-4b4b-b76d-a73608654aee",
 *   "_updatedDate": "2024-06-12T08:14:17.403Z",
 *   "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
 *   "couponReference": {
 *     "code": "6QLGLVTGVH8A",
 *     "couponId": "27d5d44d-eb61-4533-8f72-01177097e470",
 *     "name": "10% off all events",
 *     "specification": {
 *       "type": "PERCENT_OFF_RATE",
 *       "percentOffRate": 10,
 *       "scope": {
 *         "name": "ticket",
 *         "namespace": "events"
 *       },
 *       "limitedToOneItem": false
 *     }
 *   },
 *   "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
 *   "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
 *   "revision": "2",
 *   "rewardName": "10% off all events",
 *   "status": "ACTIVE",
 *   "transactionId": "0b24afeb-2964-4bb2-a5ab-b32e04128c20"
 * }
 */
```

### Get loyalty coupon
```javascript
import { coupons } from "@wix/loyalty";

/* Sample loyaltyCouponId value:
 *
 * {
 *     "loyaltyCouponId": "6fb2cdc0-863f-4b4b-b76d-a73608654aee"
 * }
 */ 

async function getLoyaltyCoupon(loyaltyCouponId) {
  try {
    const result = await coupons.getLoyaltyCoupon(loyaltyCouponId);
    return result;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "_createdDate": "2024-06-12T08:14:16.884Z",
 *   "_id": "6fb2cdc0-863f-4b4b-b76d-a73608654aee",
 *   "_updatedDate": "2024-06-12T08:14:17.403Z",
 *   "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
 *   "couponReference": {
 *     "code": "6QLGLVTGVH8A",
 *     "couponId": "27d5d44d-eb61-4533-8f72-01177097e470",
 *     "name": "10% off all events",
 *     "specification": {
 *       "type": "PERCENT_OFF_RATE",
 *       "percentOffRate": 10,
 *       "scope": {
 *         "name": "ticket",
 *         "namespace": "events"
 *       },
 *       "limitedToOneItem": false
 *     }
 *   },
 *   "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
 *   "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
 *   "revision": "2",
 *   "rewardName": "10% off all events",
 *   "status": "ACTIVE",
 *   "transactionId": "0b24afeb-2964-4bb2-a5ab-b32e04128c20"
 * }
 */
```

### getLoyaltyCoupon (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { coupons } from '@wix/loyalty';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { coupons },
  // Include the auth strategy and host as relevant
});


async function getLoyaltyCoupon(loyaltyCouponId) {
  const response = await myWixClient.coupons.getLoyaltyCoupon(loyaltyCouponId);
};
```

---