---
schema_version: "1"
id: 7eb2640a0e0b5bf7c58c16d9d928cfd93663eee427c88c636e1907d5c3f49de1
title: Coupons, Gift Certificates, and Bonus Products
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/commerce-api/guides/coupons-giftcerts-bonus-products.md
canonical_url: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/coupons-giftcerts-bonus-products.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d1b076bc24a9b034eabc38e1429fa9a6134d905ee4556ba27c6a8bb8dfc49f1a
products:
  - Composable Storefront
  - Salesforce APIs
---
# Coupons, Gift Certificates, and Bonus Products

This topic covers less common use cases for working with baskets.

## Add a Coupon to a Basket

1. Configure coupons using the information in [Using Coupons as Promotion Qualifiers for B2C Commerce](https://help.salesforce.com/s/articleView?id=cc.b2c_using_coupons_as_qualifiers.htm&type=5).
2. Get a guest token.
3. Create a basket.
4. Add a coupon to the basket using the [addCouponToBasket](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=addCouponToBasket) endpoint.

```sh
echo '--> Create basket...'
curl "$BASE_BASKET/baskets?siteId=$SITE" \
 -sSfH "Authorization: Bearer $TOKEN" \
 -H "Content-Type: application/json" \
 -d '{
"productItems": [{ "quantity": 1, "productId": "750518699585M"}],
"couponItems": [{ "code": "menssuits" }]
}' | jq -r '.couponItems'
```

For additional code examples, see [addCouponToBasket](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=addCouponToBasket).

## Gift Certificates

For gift certificate overview information and how to create a gift certificate, see [Gift Certificates](https://help.salesforce.com/s/articleView?id=cc.b2c_gift_certificates.htm&type=5).

Use the Shopper Baskets [addGiftCertificateItemToBasket](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=addGiftCertificateItemToBasket) endpoint to add a gift certificate to a basket, as shown in the following example:

```sh
curl "$BASE_BASKETS/$BASKET_ID/gift-certificate-items?siteId=$SITE" \
   -sS --fail-with-body \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
  -d '{
  "amount": 1,
  "recipientEmail": "miller@salesforce-test.com",
  "shipmentId": "me"
}'
```

## Create a Basket and Add Bonus Products With Choice

1. [Configure the bonus product in Business Manager](https://help.salesforce.com/s/articleView?id=cc.b2c_choice_of_bonus_product_discount.htm&type=5).
2. Get a guest token.
3. Create a basket.
4. Add one or more products that are associated with a bonus product choice promotion using the [createBasket](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=createBasket) or [addItemToBasket](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=addItemToBasket) endpoint.
5. After a product is added to the basket, applicable bonus items become available. The basket response includes a property called `bonusDiscountLineItems`, which is a set of bonus products from which a customer can choose.
6. Copy the `productId` and the `bonusDiscountLineItemId` from the response and use it to select the bonus product using the [addItemToBasket](https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-baskets?meta=addItemToBasket) endpoint. Quantity is a compulsory field and cannot exceed the number of bonus products allowed in the promotion. In this case, it is 1.

```sh
echo '--> Create basket...'
RESPONSE=$(
    curl "$BASE_BASKET/baskets?siteId=$SITE" \
        -sS --fail-with-body \
        -H "Authorization: Bearer $TOKEN" \
        -H "Content-Type: application/json" \
        -d '{"productItems": [{ "quantity": 1, "productId": "750518894553M"}]}'
)
BASKET=$(echo $RESPONSE | jq -r '.basketId')
echo $RESPONSE | jq -r '.bonusDiscountLineItems'
BONUS=$(echo $RESPONSE | jq -r '.bonusDiscountLineItems[0].id')

echo '--> Add the bonus product...'
curl "$BASE_BASKET/baskets/$BASKET/items?siteId=$SITE" \
    -sS --fail-with-body \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d '[{ "quantity": 1, "productId": "793775370033M", "bonusDiscountLineItemId": "'$BONUS'"}]' \
 | jq '.productItems'
```

The previous script adds a product with bonus products to the basket. The first bonus product available in the bonusDiscountLineItems array is added to the basket.
