---
schema_version: "1"
id: d563680925003817bddbce7b7fb30fcfc14356284f0b6b7eec98bb9d7e0f9795
title: Offer a Limited Number of Coupon Codes in MobileConnect
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/mktg/264-0-0/mc_moc_offer_coupon_codes_via_ampscript.md
canonical_url: https://help.salesforce.com/s/articleView?id=mktg.mc_moc_offer_coupon_codes_via_ampscript.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 8344e13476850ef6b9d6b213aa3bedc23bfad35bda6f3eebf957b96951487354
description: You can dynamically assign coupon codes using AMPscript and a data extension in Marketing Cloud Engagement.
products:
  - Marketing
  - Marketing Cloud Engagement
release: "264"
---
# Offer a Limited Number of Coupon Codes in MobileConnect

You can dynamically assign coupon codes using AMPscript and a data extension in Marketing Cloud Engagement.

For example, Northern Trail Outfitters wants to distribute a limited number of coupon codes to customers, so they create a text response message tied to a data extension via AMPscript. When customers send a message to the text response keyword, they receive a coupon code from the data extension. When the coupon codes are sent out, the customer receives a message thanking them for their response and explaining that Northern Trail Outfitters sent out all available codes.

1. Create a .csv file that contains the coupon codes.
2. Create a data extension that contains these required columns:
    - IsClaimed—A Boolean value that indicates whether the code is claimed or unclaimed. 0 is false, unclaimed. 1 is true, claimed.
    - CouponCode—A string value that contains the coupon code
    - SubscriberKey—A string value that contains the subscriber key or contact key for the customer who claims the code
3. Import your data from the .csv file into the data extension.
4. Create a text response message. Include the following AMPscript in the response message. `ClaimRowDE` is the external key for the example data extension.
    
    ```
    %%[VAR @CouponRow SET @CouponRow = ClaimRow("ClaimRowDE", "IsClaimed", "SubscriberKey", 
    MOBILE_NUMBER) IF EMPTY(@CouponRow) THEN ]%%Sorry - No coupons available.%%[ ELSE ]%%Congrats! 
    Your promo code is %%=FIELD(@CouponRow,"CouponCode")=%% and expires in 3 days. Thanks for Responding! 
    %%[ENDIF]%%
    ```
5. Schedule or send the text response message.