WooCommerce logo WooCommerce automation

Create single-use WooCommerce coupon codes

A campaign needs a personal code per customer, and in WooCommerce every coupon is its own form with a code, a discount type, restrictions, limits and an expiry date.

Cotlet does it in your own WooCommerce account with list_coupons and create_coupon, called by your AI agent, an n8n workflow or a script.

Hosted · nothing to install or maintain

Can WooCommerce do this on its own?

WooCommerce creates coupons through the admin form, and the REST API has a coupons endpoint with a read/write key (checked 16 Oct 2026). The MCP developer preview has no coupon ability. The repetition across a customer list, and the check that a code does not exist yet, is what you wire yourself.

How you do it in WooCommerce today

  1. In the admin go to Marketing > Coupons and click Add new coupon; coupons must be enabled first under WooCommerce > Settings > General > Enable coupons.
  2. On the General tab type a code or click Generate coupon code, pick a Discount Type and enter the Coupon amount as a plain number without the % sign.
  3. Set an Expiry date if the code should stop working, and tick Allow Free Shipping if it should work with free shipping.
  4. On the Usage Restrictions tab fill Allowed Emails to lock the code to a customer, and on the Usage Limits tab set Usage limit per coupon.
  5. Click Publish, then repeat the form for the next customer on the list.

How to create single-use WooCommerce coupon codes

Prompt

Create one 15% coupon for each email on this list, valid for one use only and until 30 November. Name them SPRING- plus four random characters and give me the list of codes.
  1. 01

    Check the code is free

    list_coupons searches for the code before each create. WooCommerce codes are not case-sensitive, so the agent compares them ignoring case and picks a new random suffix if one already exists.

  2. 02

    Build one coupon per customer

    create_coupon gets the discount type percent, the amount as a plain number, the expiry date and one email in the allowed emails, so a code only works for the customer it was made for.

  3. 03

    Limit the use

    The agent sets usage_limit and usage_limit_per_user to 1, so a forwarded code cannot be used twice, and tells you when your prompt left either one open.

  4. 04

    Ask once for the whole batch

    Creating a coupon gives money away, so create_coupon asks for your OK by default; with a 40-row list the agent shows the first coupon in full and the count, and you confirm the pattern for the rest.

  5. 05

    Return the code list

    The agent reports each email with its code and expiry date in one table, ready to paste into your mailing tool, and lists the rows it skipped.

What you get back

Example data

Coupons created: 3 of 3
jordan.lee@example.com: SPRING-JL3K, 15%, 1 use, expires 2026-11-30
maria.costa@example.com: SPRING-MC8P, 15%, 1 use, expires 2026-11-30
sam.ortiz@example.com: SPRING-SO2X, 15%, 1 use, expires 2026-11-30
Skipped: none

Other ways to ask

  • Create a fixed cart discount of 10.00 for orders over 80.00 for each customer who ordered last month.
  • Create a coupon for free shipping only, usable once per customer, valid until the end of the year.
  • List the coupons that expire this week and the ones that reached their usage limit.

What WooCommerce allows, and what to know first

  • WooCommerce has three discount types: Percentage discount, Fixed cart discount and Fixed product discount, and the Coupon amount is a number only, with no currency or % sign.
  • Allowed Emails are checked against the customer's billing email and accept wildcards such as *@gmail.com.
  • Usage limit per coupon counts uses across all customers, and Usage limit per user counts uses by one customer.
  • In WooCommerce 11.2 and later the Minimum spend of a coupon cannot be higher than its Maximum spend.
  • Coupon discounts are applied before tax, and coupons do not reduce shipping unless they are free shipping coupons.

create_coupon asks for your OK by default. To run it on a schedule without you, switch confirmation off for that tool in your dashboard.

Sources: WooCommerce Docs: Coupon management · WooCommerce REST API documentation: coupons · WooCommerce developer blog: Call for testing, WooCommerce MCP (beta)

Call create_coupon from a script

curl

curl -X POST https://cotlet.dev/api/v1/woocommerce/coupons \
  -H "Authorization: Bearer $COTLET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"SPRING-JL3K","amount":"15","discount_type":"percent","date_expires":"2026-11-30","usage_limit":1,"usage_limit_per_user":1,"email_restrictions":["jordan.lee@example.com"]}'

Example response

{
  "coupon_id": 2210,
  "code": "SPRING-JL3K",
  "discount_type": "percent",
  "amount": "15",
  "date_expires": "2026-11-30",
  "usage_limit": 1,
  "usage_limit_per_user": 1,
  "email_restrictions": [
    "jordan.lee@example.com"
  ]
}

MCP: add https://cotlet.dev/mcp/v1 with the same key; the call is woocommerce_write → create_coupon. Example data.

Schedule it in n8n, Make, Zapier or cron

WooCommerce tools this automation uses

Cotlet WooCommerce tools used to create single-use WooCommerce coupon codes
Tool Parameters
list_coupons code, search, limit, page
create_coupon code, amount, discount_type, date_expires, usage_limit, usage_limit_per_user, minimum_amount, free_shipping, email_restrictions
All 11 WooCommerce tools with descriptions

Frequently asked questions

What if the code does not apply at checkout?

Check that coupons are enabled under WooCommerce > Settings > General > Enable coupons, then that the customer's billing email matches the allowed email on the coupon.

Is it safe to connect WooCommerce to Cotlet?

Yes. You sign in to WooCommerce yourself, in your own Cloud Browser in the EU, and we never save your password. Your agents only get WooCommerce once you enable it, every background request is listed, and the browser profile is stored encrypted with AES-256-GCM, the cipher 1Password uses for its vaults. The AI model never sees a login, posts and messages wait for your OK, and Disable for agents cuts access in one click. Independent scanners grade cotlet.dev A+ on Qualys SSL Labs, securityheaders.com and Mozilla Observatory; live results are on https://cotlet.dev/security.

Give your agent access to WooCommerce.

Free 7-day trial with 2,000 credits, no card needed. Cotlet is independent and not affiliated with WooCommerce.