> 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

# Method name: createCoupon(couponInfo: CouponInfo)

# Method package: wixMarketingBackend

# Method menu location: wixMarketingBackend --> Coupons --> createCoupon

# Method Link: https://dev.wix.com/docs/velo/apis/wix-marketing-backend/coupons/create-coupon.md

# Method Description:

Creates a new coupon.

The `createCoupon()` function returns a Promise that resolves to an object containing the ID of
 the new coupon after it has been successfully created.

 When creating a coupon, the specified `couponInfo` object must
 contain a value for exactly 1 of the following coupon properties. This
 defines the coupon type.

 + `"moneyOffAmount"`
 + `"percentOffRate"`
 + `"fixedPriceAmount"`
 + `"buyXGetY"`
 + `"freeShipping"`

 When creating a new coupon, the specified `couponInfo` object must
 contain values for `name`, `code`, `startTime`, and either `scope` or `minimumSubtotal`.
 The exception is for a `freeShipping` coupon type, for which you cannot apply
 a `scope` and `minimumSubtotal` is optional.

The coupon scope defines the items a coupon applies to. You can apply a coupon to
all items in a specific Wix application, a group within the application,
or a single item within a group.

The following table lists the currently supported coupon scopes:

| namespace | group | entityId | Result |
|---|---|---|---|
| stores | -- | -- | Applies to all store products |
| stores | product | product ID | Applies to the specific store product with the provided ID |
| stores | collection | collection ID | Applies to the specific store collection with the provided ID |
| bookings | -- | -- | Applies to all bookings services |
| bookings | service | service ID | Applies to the specific bookings service with the provided ID |
| events | event | event ID | Applies to the specific event with the provided ID |
| events | ticket | -- | Applies to all event tickets |
| events | ticket | ticket ID | Applies to the specific event ticket with the provided ID |
| pricingPlans | -- | -- | Applies to all pricing plans |
| pricingPlans | plan | plan ID | Applies to the specific pricing plan with the provided ID |



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Create a new coupon with options

```javascript
import { coupons } from 'wix-marketing-backend';

export function createCoupon() {
  let couponInfo = {
    "name": "My Coupon",
    "code": "myCouponCode",
    "startTime": new Date(),
    "expirationTime": new Date(2020, 12, 31),
    "usageLimit": 100,
    "limitedToOneItem": true,
    "limitPerCustomer": 1,
    "active": true,
    "scope": {
      "namespace": "stores"
    },
    "moneyOffAmount": 10
  };

  return coupons.createCoupon(couponInfo);
}

// Returns promise that resolves to:
// {"id": "058b0b56-e90d-4f4e-a8a3-8bf90b3fc4e6"}
```

## Create a new "money off" coupon

```javascript
import { coupons } from 'wix-marketing-backend';

export function createCoupon() {
  let couponInfo = {
    "name": "My Coupon",
    "code": "myCouponCode",
    "startTime": new Date(),
    "scope": {
      "namespace": "stores"
    },
    "moneyOffAmount": 10 // $10 off original price
  };

  return coupons.createCoupon(couponInfo);
}

// Returns promise that resolves to:
// {"id": "058b0b56-e90d-4f4e-a8a3-8bf90b3fc4e6"}
```

## Create a new free shipping coupon

```javascript
import { coupons } from 'wix-marketing-backend';

export function createCoupon() {
  let couponInfo = {
    "name": "My Coupon",
    "code": "myCouponCode",
    "startTime": new Date(),
    "freeShipping": true
  };

  return coupons.createCoupon(couponInfo);
}

// Returns promise that resolves to:
// {"id": "058b0b56-e90d-4f4e-a8a3-8bf90b3fc4e6"}
```

## Create a new "buy x, get y" coupon

```javascript
import { coupons } from 'wix-marketing-backend';

export function createCoupon() {
  let couponInfo = {
    "name": "My Coupon",
    "code": "myCouponCode",
    "startTime": new Date(),
    "scope": {
      "namespace": "stores"
    },
    "buyXGetY": { // Buy 2 items, get 1 free
      "x": 2,
      "y": 1
    }
  };

  return coupons.createCoupon(couponInfo);
}

// Returns promise that resolves to:
// {"id": "058b0b56-e90d-4f4e-a8a3-8bf90b3fc4e6"}
```

## Create a new coupon that applies to a specific store product

```javascript
import { coupons } from 'wix-marketing-backend';

export function createCoupon() {
  let couponInfo = {
    "name": "My Coupon",
    "code": "myCouponCode",
    "startTime": new Date(),
    "scope": { // Coupon applies to the store product with the specified ID
      "namespace": "stores",
      "group": {
        "name": "product",
        "entityId": "3db41c71-6cb6-45f5-88fc-aaf05ed22e54"
      }
    },
    "moneyOffAmount": 10
  };

  return coupons.createCoupon(couponInfo);
}

// Returns promise that resolves to:
// {"id": "058b0b56-e90d-4f4e-a8a3-8bf90b3fc4e6"}
```

## Create a new coupon that applies to all event tickets

```javascript
import { coupons } from 'wix-marketing-backend';

export function createCoupon() {
  let couponInfo = {
    "name": "My Coupon",
    "code": "myCouponCode",
    "startTime": new Date(),
    "scope": { // Coupon applies to all event tickets
      "namespace": "events",
      "group": {
        "name": "ticket"
      }
    },
    "moneyOffAmount": 5 // $5 off original ticket price
  };

  return coupons.createCoupon(couponInfo);
}

// Returns promise that resolves to:
// {"id": "058b0b56-e90d-4f4e-a8a3-8bf90b3fc4e6"}
```

## Create a new "percent off" coupon that applies to all pricing plans

```javascript
import { coupons } from 'wix-marketing-backend';

export function createCoupon() {
  let couponInfo = {
    "name": "Summer Sale 20%",
    "code": "SUMMER20",
    "startTime": new Date(),
    "expirationTime": new Date('Sep 23, 2022 23:59:00'),
    "scope": { // Coupon applies to all pricing plans
      "namespace": "pricingPlans"
    },
    "percentOffRate": 20
  };

  return coupons.createCoupon(couponInfo);
}

// Returns promise that resolves to:
// {"id": "c2750c68-c253-42ce-85a4-2c9d09bfbcd8"}
```

---