Skip to content
flint

Free tool

Discount code generator

Make up to 10,000 unique discount or promo codes at a time, with your prefix, length, and characters, and download them as a CSV. Then turn the batch into a Flint promotion that checks every code at checkout: once per customer, first orders only, and the stacking rules you choose.

Optional. Letters and digits, then hyphens and underscores if you like, such as SPRING or VIP_.
Leaves out 0, O, 1, I, and L, so a code read aloud or off a card can't be mistyped.

100 unique codes, 16 characters each

  • Drawing 100 codes…

Odds that someone guesses a live code: 1 in 8.5 billion per try. Drawn in your browser with a cryptographic random generator; the codes aren't sent anywhere.

Run it in Flint

Make these codes work at checkout

A list of codes is only text until checkout checks them. In Flint, one promotion holds the offer and every code in the batch:

  • A code works once, or as many times as you allow
  • First-order offers limited to one use per customer
  • Stacking rules decide which offers combine
  • Buyers type codes in any letter case

Free sandbox, no credit card. Run the script below with a sandbox API key.

The offer

Buyers see “15% off your first order” at checkout and on their order.

create-discount-codes.sh
#!/usr/bin/env bash
# Creates a Flint promotion for the codes in discount-codes.csv: the first 100
# with the promotion, then the rest one at a time, under the API's rate limit.
# Needs bash, curl 7.76 or later, and jq. Stops at the first error.
set -euo pipefail

: "${FLINT_API_KEY:?Set FLINT_API_KEY to a sandbox API key}"
CSV="${1:-discount-codes.csv}"
API="${FLINT_BASE_URL:-https://api.withflintpay.com}"

flint() {
  curl -sS --fail-with-body --retry 5 \
    -H "Authorization: Bearer $FLINT_API_KEY" \
    -H "Flint-Version: 2026-09-07" \
    -H "Content-Type: application/json" "$@"
}

# The codes, without the header row or Windows line ends.
CODES=$(tail -n +2 "$CSV" | tr -d '\r' | sed '/^$/d')
FIRST=$(head -n 100 <<<"$CODES" | sed 's/.*/{"code":"&","max_uses":1}/' | paste -sd, -)

# 1. The promotion, with the first 100 codes.
PROMOTION=$(flint -X POST "$API/v1/promotions" \
  -H "Idempotency-Key: promotion-$(head -n 1 <<<"$CODES")" \
  -d @- <<JSON
{
  "name": "WELCOME batch",
  "display_name": "15% off your first order",
  "redemption_type": "code",
  "discount_class": "order",
  "application_method": {
    "type": "percent_off",
    "percent_off": 15
  },
  "eligibility_rules": {
    "all": [
      {
        "attribute": "customer.paid_order_count",
        "operator": "eq",
        "values": [
          0
        ]
      }
    ]
  },
  "max_uses_per_customer": 1,
  "codes": [$FIRST]
}
JSON
)
PROMOTION_ID=$(jq -er '.data.promotion_id' <<<"$PROMOTION")
echo "Created $PROMOTION_ID"

# 2. Every other code, about 9 a second.
COUNT=0
while read -r CODE; do
  [ -n "$CODE" ] || continue
  flint -X POST "$API/v1/promotion-codes" \
    -H "Idempotency-Key: promotion-code-$CODE" \
    -d "$(printf '{"promotion_id":"%s","code":"%s","max_uses":1}' "$PROMOTION_ID" "$CODE")" >/dev/null
  COUNT=$((COUNT + 1))
  sleep 0.11
done < <(tail -n +101 <<<"$CODES")
echo "Added $COUNT more codes to $PROMOTION_ID"

Save the CSV beside it and run FLINT_API_KEY=… bash create-discount-codes.sh. It creates the promotion with the first 100 codes. Each request has an idempotency key, so running it again within 24 hours never creates a code twice. Needs curl 7.76 or later and jq.

Choosing a format

What makes a good discount code

Easy to type, impossible to guess, and clear about where it came from.

A prefix that says where it came from

SPRING, VIP_, or a partner's name tells you at a glance which campaign a redeemed code belongs to, before you open a report.

Enough random characters

Eight is plenty for most batches. Add more for large batches or big discounts: each character multiplies the codes a guesser has to try.

No look-alike characters

Codes get read off cards and screens. Leaving out 0, O, 1, I, and L means nobody types a code wrong and writes to support.

Groups of four for long codes

ABCD-2345-EFGH reads and types more easily than twelve characters in a row. Hyphens count toward the length.

First order discounts

A first order discount needs more than a code

A WELCOME15 code shared online gets used by returning customers too. The rule has to follow the customer, not the code.

A first-order offer is only first-order if checkout knows who the buyer is and whether they’ve paid before. A unique code per new subscriber helps, since each one works once, but it can’t stop a repeat customer from signing up again.

In Flint, the promotion checks the customer. A customer.paid_order_count rule of zero makes only their first paid order eligible, and max_uses_per_customer: 1 reserves their one use when payment starts, so two checkouts opened at once can’t both get it. A customer who already used it is turned away with a reason your checkout can show, and a failed payment gives the use back.

{
  "name": "First order 15",
  "display_name": "15% off your first order",
  "redemption_type": "code",
  "eligibility_rules": {
    "all": [{
      "attribute": "customer.paid_order_count",
      "operator": "eq",
      "values": [0]
    }]
  },
  "application_method": {
    "type": "percent_off",
    "percent_off": 15
  },
  "max_uses_per_customer": 1,
  "codes": [{ "code": "FIRST15" }]
}

POST /v1/promotions, from the promotions guide’s First order only recipe.

At checkout

What Flint checks when a buyer enters a code

Codes live on a promotion, and the promotion holds the rules. Hosted checkout shows a code field while you have an active code promotion, and your own checkout applies codes with one call.

One use per code, or many. Limit each code, and the promotion across all its codes. A use counts when payment starts, and a failed payment gives it back.

max_uses

Once per customer. Limit how many times one customer can use the offer, across every code in the batch.

max_uses_per_customer

First orders only. Only a customer’s first paid order qualifies. Guest purchases count once they’re linked to the customer.

customer.paid_order_count

Codes for one customer. Bind a code to a customer for a win-back offer, and nobody else can redeem it.

promotion_code.customer_id

Stacking you decide. Choose which kinds of discount combine, put competing offers in a group so only one applies, and cap promotions per order.

combines_with, exclusivity

A reason when a code doesn’t apply. A code below its minimum says how much more the buyer needs to add, so checkout can say “add $60.00” instead of “invalid code.”

reason: "minimum_not_met"

A start and an end. Schedule the promotion for a sale weekend, and codes stop working when it ends.

schedule.ends_at

Promotions on Flint

  1. 01
    Promotions guideCodes, automatic offers, stacking, and decline reasons.
  2. 02
    Promotions APIEvery field on a promotion and its codes.
  3. 03
    Multiple coupons on Stripe CheckoutWhy Stripe takes one code, and how Flint stacks them.

no monthly fee · free sandbox · no credit card

FAQ

Discount code questions

Is this discount code generator free?

Yes. There's no sign-up and no limit beyond 10,000 codes a batch, and you can make as many batches as you like. The codes are drawn in your browser with a cryptographic random generator and never sent anywhere, so nobody else has a copy.

How long should a discount code be?

Long enough that guessing one is hopeless. Eight characters from the 31-character set without look-alikes gives about 852 billion possible codes, so with 100 live codes a guess has about a 1 in 8.5 billion chance. A shared code everyone types, such as SPRING20, can be short because it isn't secret; unique codes that each carry a discount shouldn't be.

What's the difference between a discount code, a promo code, and a coupon code?

Nothing, in practice. All three are a code a buyer enters at checkout for a discount. Stores pick the word their buyers know; the generator makes the same codes for any of them.

Should codes be single-use or shared?

Shared when the code is the campaign: one code in a newsletter or a podcast ad, where you count redemptions. Single-use when each code is a gift: one per customer, per influencer follower, or per printed card, so a code posted online can be used once and no more. Flint sets this per code with max_uses, and limits the promotion as a whole separately.

How do I give a discount on the first order only?

Tie the offer to the customer, not the code. In Flint, a customer.paid_order_count rule of zero makes only a customer’s first paid order eligible, and max_uses_per_customer: 1 guarantees one use even if two checkouts start at once. The generator’s Flint script sets both when First order only is checked. First order only in the promotions guide has the details.

Can buyers combine discount codes?

In Flint, yes, as far as your rules allow. An order takes up to two promotions by default, and you can set 1 to 10. Each promotion says which kinds of discount it combines with, and promotions in the same exclusivity group compete so only the best one applies. Control how offers stack walks through it.

How do I import the codes into my store?

Download the CSV, which has one code per row under a code header, and import it where your store takes a list of codes. To use the codes on Flint, run the script beside the batch: it creates a promotion with the first 100 codes and adds the rest through the API.

Are uppercase and lowercase codes different?

Not in Flint, which matches codes without regard to case, so a buyer can type spring10 for SPRING10. That's why the generator writes upper case only: mixed case would make codes harder to read without making them any harder to guess.

Start

Put the batch to work

Create a free sandbox, run the script with a sandbox key, and try a code at checkout with a test card.

A list of codes is where a promotion starts. Flint keeps the rest: which codes are used, who used them, whether this is their first order, and which offers can share a cart, all checked the moment a buyer enters a code.

Create a promotion in the Flint dashboard and add codes to it, or create the whole batch with POST /v1/promotions and POST /v1/promotion-codes.

Then read these

  1. 01
    First order onlyThe eligibility rule and the per-customer limit.
  2. 02
    Control how offers stackWhich promotions share an order, and which compete.
  3. 03
    Commerce APICatalog, promotions, tax, and payments on one order.

no monthly fee · free sandbox · no credit card