Promotions
A promotion is a reusable discount rule: 20% off hats, $10 off orders of $50 or more, buy two tees and get one free. Buyers redeem it with a code, or Flint applies it automatically to every order that qualifies. One promotion can have many codes, each with its own usage limit and expiry.
Creating and changing promotions needs the commerce.promotions.write scope. Applying them to orders needs commerce.orders.write. Test keys work the same way with no real money, so you can run every request below against your sandbox.
How promotions apply to an order#
Flint prices discounts on the order. When a promotion applies, it becomes an entry in the order's discounts with status: "pending". Pending discounts are recalculated every time the order changes: a discount that no longer qualifies is removed, and an automatic promotion that now qualifies is added. When the order is paid in full, its discounts are redeemed and no longer change.
- pending moves to redeemed on order paid
- pending moves to canceled on order closed
- pending on removed: leaves discounts
Each promotion combines four decisions:
| Decision | Field | Example |
|---|---|---|
| What the discount is | application_method | percent_off, amount_off, or buy_x_get_y |
| What it discounts | discount_class | The whole order, matching line items, or charges such as shipping |
| When it applies | eligibility_rules | Spend at least $50, or a customer in your wholesale segment |
| What it can combine with | combines_with, exclusivity | Never stack with another order discount |
redemption_type decides how a buyer gets it: code when the buyer enters a code, automatic when Flint applies it to every qualifying order.
Create a promotion code#
This promotion takes $10 off the order when the buyer enters SPRING10. The code can be redeemed 500 times. Amounts are integers in the currency's minor unit, so 1000 is $10.00.
curl -X POST https://api.withflintpay.com/v1/promotions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: promotion-spring-sale-001" \
-d '{
"name": "Spring sale 2026",
"display_name": "$10 off your order",
"redemption_type": "code",
"discount_class": "order",
"application_method": {
"type": "amount_off",
"amount_off_money": {"amount": 1000, "currency": "USD"}
},
"codes": [
{"code": "SPRING10", "max_uses": 500}
]
}'
The response is 201 with the promotion and the codes it created:
{
"data": {
"promotion_id": "promo_1kmn0aExample",
"name": "Spring sale 2026",
"display_name": "$10 off your order",
"status": "active",
"available": true,
"redemption_type": "code",
"application_method": {
"type": "amount_off",
"allocation": "across",
"amount_off_money": {"amount": 1000, "currency": "USD"}
},
"discount_class": "order",
"combines_with": {"order": true, "line_item": true, "service_charge": true},
"max_uses_per_customer": null,
"uses_count": 0,
"codes_summary": {"total_count": 1, "active_count": 1, "newest_active_code": "SPRING10"},
"codes": [
{
"promotion_code_id": "pcode_1kmn0aExample",
"promotion_id": "promo_1kmn0aExample",
"code": "SPRING10",
"status": "active",
"available": true,
"max_uses": 500,
"customer_id": null,
"uses_count": 0,
"created_at": "2026-10-14T22:13:29Z",
"updated_at": "2026-10-14T22:13:29Z"
}
],
"created_at": "2026-10-14T22:13:29Z",
"updated_at": "2026-10-14T22:13:29Z"
}
}
codesholds the codes this request created, in request order, with thepromotion_code_idyou use to manage each one. Only the create response includes it. One request creates at most 100 codes; add more withPOST /v1/promotion-codes, withpromotion_idin the body.nameis your internal label.display_nameis what buyers see at checkout and on the order, where it appears ascustomer_facing_name. It defaults toname.- Codes are unique within a sandbox or live mode, ignoring case but distinguishing accents, so a buyer can type
spring10orSpring10.CAFÉandcafématch the same code;CAFEis a separate code. Flint keeps the spelling you created. Leading and trailing spaces are rejected, not trimmed. - Fields you leave out take defaults:
combines_withallows every class, and there is noexclusivitygroup. Control how offers stack covers both.
Apply a code to an order#
To try the code, create an order. This one totals $40.00:
curl -X POST https://api.withflintpay.com/v1/orders \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-promotions-guide-001" \
-d '{
"line_items": [
{
"type": "custom",
"name": "Canvas tote",
"quantity": 1,
"unit_price_money": {"amount": 3000, "currency": "USD"},
"fulfillment": {"requirement": "none"}
},
{
"type": "custom",
"name": "Enamel pin",
"quantity": 2,
"unit_price_money": {"amount": 500, "currency": "USD"},
"fulfillment": {"requirement": "none"}
}
]
}'
Then apply the code the buyer entered. Send it as typed; Flint matches it without regard to case.
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/discounts \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: apply-spring10-001" \
-d '{
"promotion": {"promotion_code": "spring10"}
}'
The response is 200 with the repriced order, abridged here:
{
"data": {
"order_id": "ord_1kmn0aExample",
"status": "open",
"discounts": [
{
"order_discount_id": "ad_1kmn0aExample",
"customer_facing_name": "$10 off your order",
"source": "promotion",
"discount_class": "order",
"promotion_id": "promo_1kmn0aExample",
"promotion_code": "SPRING10",
"amount_money": {"amount": 1000, "currency": "USD"},
"applied_money": {"amount": 1000, "currency": "USD"},
"status": "pending"
}
],
"deferred_promotions": [],
"pricing_amounts": {
"subtotal_money": {"amount": 4000, "currency": "USD"},
"discount_money": {"amount": 1000, "currency": "USD"},
"total_money": {"amount": 3000, "currency": "USD"}
}
}
}
applied_money is what the discount takes off this order. Show customer_facing_name and applied_money in your cart, and keep order_discount_id if the buyer can remove the code.
Applying or removing a code requotes an existing delivery selection. When its method, price, route, and delivery window remain valid, Flint keeps the selection and recalculates shipping discounts and tax. A free-shipping code applied after selecting shipping discounts that shipping charge. If the selection becomes invalid, the response includes delivery_requote_required in meta.warnings. Create a new delivery quote and select delivery again before payment.
You can also apply codes when you create the order by sending the same object in its discounts array: "discounts": [{"promotion": {"promotion_code": "spring10"}}]. Manual discounts in discounts apply first, in the order you send them. Flint then ranks the promotion codes together with the order's automatic promotions. A code that loses, including one past max_promotions_per_order, comes back as a promotion_declined warning in meta.warnings on the 201 response instead of failing the request.
Hosted checkout shows a code field and applies codes itself. You only call this endpoint when you collect the code in your own UI.
Apply a promotion when you create a checkout session#
Send discounts when you create a quick_pay or subscription_plan session to apply an offer before the buyer opens checkout:
{
"type": "subscription_plan",
"subscription_plan_id": "plan_1kmn0aExample",
"customer_id": "cus_1kmn0aExample",
"discounts": [{"promotion": {"promotion_id": "promo_1kmn0aExample"}}],
"promotion_config": {"codes_enabled": false}
}
Each of the 1 to 10 entries takes either promotion_id or promotion_code. Use an ID for an offer your server selected. It needs no code and records promotion_code: null; the buyer can't remove it. Use a code when the buyer supplied one; the buyer can remove that discount. Account promotion settings apply to both, so a code-type promotion applied by ID still requires account codes to be enabled.
Set session promotion_config.codes_enabled: false with a pre-applied offer when you don't want buyers adding codes. This controls buyer actions and doesn't block your discounts entries. Automatic promotions still follow account settings and the normal stacking rules.
Flint creates the order with its lines, subscription terms, customer, and tax inputs, then ranks all requested promotions as already on that order. A ranking loss returns 201 with a promotion_declined warning in meta.warnings. An unredeemable promotion returns 409 PROMOTION_DECLINED at discounts[i].promotion, with the usual reason and facts; an unknown ID returns 404 RESOURCE_NOT_FOUND at discounts[i].promotion.promotion_id. A failure creates neither an order nor a session, so you can retry the corrected request with the same idempotency key.
Read the result in order.discounts by expanding order on a session read or calling GET /v1/orders/{order_id}. A trial plan defers an eligible offer to order.deferred_promotions, ready for its first charged cycle. A once offer on a signup without a trial is consumed by the signup order. See Discounts and first-shipment offers.
Buyer changes to subscription terms, address, or entered codes keep a by-ID promotion while it remains eligible. If it becomes unusable before payment, the next reprice removes it. If payment finds the change first, it returns 409 VERSION_CONFLICT without charging, so checkout can show the new total. Customer eligibility is different: see Handle a code that doesn't apply.
discounts isn't accepted with type: "order"; apply it to the existing order through POST /v1/orders/{order_id}/discounts.
Handle a code that doesn't apply#
A code the buyer enters ends in one of three ways. Branch on the outcome and the machine-readable reason, not on the message text.
| Outcome | Response | Where to read the reason |
|---|---|---|
| Applied | 200, and the code is in discounts or deferred_promotions | None |
| Valid, but not applied | 200, the order unchanged, and an entry in meta.warnings | meta.warnings[].reason |
| Can't be redeemed | 409 with error.code: "PROMOTION_DECLINED" | error.details[0].reason |
PROMOTION_DECLINED errors return 409 conflict_error, including an unknown code, an ineligible order, or an incompatible currency. A promotion that is accepted but cannot apply can instead return a promotion_declined warning. Applying a code to a $0 order returns 200 with reason no_discountable_balance; creating a $0 order with the code instead returns 409 PROMOTION_DECLINED with the same reason. The promotion is not added to discounts. For expired, not_yet_started, exhausted, and inactive, details[0].current_status gives the stored status of the promotion or code, such as active for a promotion that has ended. A code with invalid characters or length returns 400 INVALID_REQUEST with detail INVALID_VALUE at the code's parameter.
POST /v1/orders/{order_id}/pay returns 409 PROMOTION_DECLINED with details[0].reason exhausted when another payment takes the last use while this one is starting. Retry with a new Idempotency-Key; Flint removes the discount and returns 409 VERSION_CONFLICT.
When the order's customer isn't eligible at payment, POST /v1/orders/{order_id}/pay returns 409 PROMOTION_DECLINED with reason customer_required, customer_mismatch, or customer_limit_reached. Flint charges nothing and leaves the discount on the order, so a retry returns the same error. Make the customer eligible, such as by setting the order's customer, or remove the discount if it can be removed, before paying again. Buyers can't remove an automatic or by-ID discount themselves, so give them a way to contact you.
The order is $40.00 and the code needs $100.00. For minimum_not_met, the error says how far the order is from the minimum, so you can tell the buyer to add $60.00 without parsing the message:
{
"error": {
"type": "validation_error",
"code": "PROMOTION_DECLINED",
"message": "Minimum purchase is not met for this promotion.",
"param": "promotion",
"doc_url": "https://developers.withflintpay.com/docs/errors#promotion_declined",
"remediation": {
"retry": "none"
},
"details": [
{
"code": "PROMOTION_DECLINED",
"param": "promotion",
"message": "Minimum purchase is not met for this promotion.",
"reason": "minimum_not_met",
"required_money": {"amount": 10000, "currency": "USD"},
"current_money": {"amount": 4000, "currency": "USD"},
"gap_money": {"amount": 6000, "currency": "USD"}
}
]
}
}
The code is valid, but the order already has as many promotions as your settings allow. Nothing on the order changed:
{
"data": {
"order_id": "ord_1kmn0aExample",
"discounts": ["…the discounts already on the order, unchanged…"]
},
"meta": {
"warnings": [
{
"code": "promotion_declined",
"severity": "warning",
"reason": "max_promotions_reached",
"message": "Promotion code was accepted but did not apply.",
"resource_type": "promotion",
"resource_id": "promo_1kmn0aExample",
"promotion_code": "FIVE",
"would_have_applied_money": {"amount": 500, "currency": "USD"}
}
]
}
}
These are the reasons a buyer-entered code most often returns. The Promotions reference lists every value. Treat a reason you don't recognize like not_eligible.
reason | Returned as | Tell the buyer |
|---|---|---|
code_invalid | Error | The code isn't recognized. Check for a typo. |
expired, inactive, exhausted | Error | The code is no longer available. |
not_yet_started | Error | The offer hasn't started yet. |
minimum_not_met | Error | Add gap_money more to use the code. |
not_eligible | Error | The cart doesn't qualify for the offer. |
customer_limit_reached | Error | You've already used this offer the allowed number of times. |
customer_mismatch | Error | This code was made for a different customer than the one identified on the order. |
customer_required | Error | Your integration needs to identify the buyer first. Set the order's customer, or name the customer on the checkout session, then apply the code again. An email typed at checkout doesn't identify a customer. This also applies to a code bound to a customer. |
already_applied | Error | The code is already on the order. |
codes_disabled | Error | Codes can't be used on this order. |
max_promotions_reached | Warning | The order already has the maximum number of offers. |
superseded_by_better_offer | Warning | Another offer from the same group is already applied. |
superseded_by_higher_priority | Warning | Another offer in the same group takes priority. |
not_combinable | Warning | The code can't be combined with an offer already applied. |
no_discountable_balance | Warning or error | Nothing is left to discount. Applying to an existing $0 order returns a warning. Creating a $0 order with the code, or rejecting a code because a manual discount consumed its balance, returns an error. |
buy_item_missing | Warning | Add enough qualifying items and separate reward items. A unit cannot count toward both quantities. |
Applying a code can also change discounts already on the order. Flint ranks every offer again on each apply and keeps the highest-value ones the stacking rules allow, so a new code worth more can replace one the buyer entered earlier. Render the cart from the returned discounts after every apply rather than adding the new code to what you showed before.
Each promotion the apply removed comes back in meta.warnings as a promotion_removed warning. reason says why it lost, promotion_code is set when a code applied it, and would_have_applied_money is the amount it took off:
{
"code": "promotion_removed",
"severity": "warning",
"reason": "superseded_by_better_offer",
"message": "A promotion already on the order was removed.",
"resource_type": "promotion",
"resource_id": "promo_1kmn0cExample",
"promotion_code": "WELCOME5",
"would_have_applied_money": {"amount": 500, "currency": "USD"}
}
Preview a discount#
POST /v1/discount-previews shows what a code would do without changing the order. Use it to explain a code before the buyer commits, or to show how close the cart is to an automatic offer.
curl -X POST https://api.withflintpay.com/v1/discount-previews \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Content-Type: application/json" \
-d '{
"order_id": "ord_1kmn0aExample",
"discount": {
"promotion": {"promotion_code": "spring10"}
}
}'
The response is 200 with three lists, abridged here:
{
"data": {
"applied": [
{
"promotion_id": "promo_1kmn0aExample",
"promotion_code": "SPRING10",
"customer_facing_name": "$10 off your order",
"discount_class": "order",
"amount_money": {"amount": 1000, "currency": "USD"},
"applied_money": {"amount": 1000, "currency": "USD"}
}
],
"skipped": [],
"available": [
{
"promotion_id": "promo_1kmn0bExample",
"customer_facing_name": "$5 off orders over $50",
"discount_class": "order",
"promotion_decline_reason": "minimum_not_met",
"threshold_money": {"amount": 5000, "currency": "USD"},
"current_money": {"amount": 4000, "currency": "USD"},
"gap_money": {"amount": 1000, "currency": "USD"}
}
]
}
}
appliedis every discount the order would have, including ones already on it.skippedis every promotion that was considered and didn't apply, each with apromotion_decline_reasonand, when Flint can price it,would_have_applied_money. A previewed code with an unmet minimum appears here withthreshold_money,current_money, andgap_money. Promotions already on the order that the previewed code would remove appear here too, with the reason they'd lose.availableis automatic promotions the order misses only by anorder.subtotalororder.merchandise_subtotal_before_discountsminimum. Usegap_moneyfor a message like "Add $10.00 more to get $5 off."
Leave out discount to preview only the automatic promotions. Unlike the apply endpoint, the body wraps the discount in discount, so sending an apply body here returns 400 INVALID_REQUEST with detail UNKNOWN_FIELD. A preview creates nothing, so it doesn't need an Idempotency-Key. A code that doesn't exist returns the same 400 error as applying it.
Remove a discount#
Send the order_discount_id values from discounts, the deferred_promotion_id values from deferred_promotions (see Signup promotions), or both. Send at least one of order_discount_ids and deferred_promotion_ids; a request with neither returns 400 INVALID_REQUEST. You can remove several in one request:
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/discounts/remove \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: remove-spring10-001" \
-d '{
"order_discount_ids": ["ad_1kmn0aExample"]
}'
The response is 200 with the repriced order. Only pending discounts can be removed; a discount on a paid order is redeemed and stays.
You can remove manual discounts and discounts from code promotions. A discount from an automatic promotion applies while the order qualifies, so removing it returns 409 ACTION_NOT_ALLOWED with reason not_offered, with param naming its position, such as order_discount_ids[0]. When any ID is refused, nothing on the order changes. To stop an automatic promotion, set it to inactive. Sending the same ID twice returns 400 INVALID_REQUEST with INVALID_VALUE on the repeated ID.
To take back a signup promotion, send its ID in deferred_promotion_ids instead. The response is the order without it, and the promotion no longer attaches to the subscription:
{ "deferred_promotion_ids": ["dp_1kmn0bExample"] }
Keep discounts current until payment#
You don't need to recalculate discounts yourself. Adding or removing items, changing quantities, and adding charges all reprice the order's pending discounts with the same rules as an apply.
A promotion or code you turn off, archive, or let expire, or that reaches its max_uses, leaves unpaid orders the next time they're repriced. If a buyer tries to pay before that, POST /v1/orders/{order_id}/pay removes the discount, charges nothing, and returns 409 VERSION_CONFLICT. Read the order again, show the buyer the new total, and ask them to confirm.
To refresh the order before a final review screen, call reprice. It takes no body:
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/discounts/reprice \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Idempotency-Key: reprice-order-001"
The response is 200 with the repriced order, abridged here:
{
"data": {
"order_id": "ord_1kmn0aExample",
"status": "open",
"discounts": [
{
"order_discount_id": "ad_1kmn0aExample",
"customer_facing_name": "$10 off your order",
"promotion_code": "SPRING10",
"applied_money": {"amount": 1000, "currency": "USD"},
"status": "pending"
}
],
"pricing_amounts": {
"subtotal_money": {"amount": 4000, "currency": "USD"},
"discount_money": {"amount": 1000, "currency": "USD"},
"total_money": {"amount": 3000, "currency": "USD"}
}
}
}
Build common offers#
Send any of these bodies to POST /v1/promotions. Each one is automatic, so it applies to qualifying orders as soon as you create it. An open order picks it up the next time it's repriced. To require a code instead, set "redemption_type": "code" and add codes.
Percent off a category#
Take 20% off every item in the hats category:
{
"name": "Hat launch",
"display_name": "20% off hats",
"redemption_type": "automatic",
"discount_class": "line_item",
"application_method": {
"type": "percent_off",
"percent_off": 20,
"discounted_item_rules": {
"all": [
{"attribute": "line_item.categories", "operator": "eq", "values": ["hats"]}
]
}
}
}
discounted_item_rules chooses the line items that get the discount. Category rules take the category's handle, and the category must already exist, or the request returns 404 RESOURCE_NOT_FOUND with param naming the rule value and details[0].resource_type set to category. Catalog setup shows how products get categories. You can also target line_item.product_id, line_item.variant_id, or line_item.bundle_id.
percent_off is a percent from 1 to 100: send 20 for 20%.
Spend threshold#
Take $10 off orders of $50 or more:
{
"name": "Spend 50 save 10",
"display_name": "$10 off orders of $50 or more",
"redemption_type": "automatic",
"discount_class": "order",
"eligibility_rules": {
"all": [
{"attribute": "order.subtotal", "operator": "gte", "values": [{"amount": 5000, "currency": "USD"}]}
]
},
"application_method": {
"type": "amount_off",
"amount_off_money": {"amount": 1000, "currency": "USD"}
}
}
eligibility_rules decides whether the promotion applies at all. A rule group is an object with either all (every entry must match) or any (one match is enough), holding at least one rule or nested group. To mix the two, nest a group inside another, such as {"all": [rule, {"any": [rule, rule]}]}. Omit the field for no conditions. The rule attributes table lists every attribute and operator.
Flint accepts only USD today, so an amount_off discount and a money threshold are always in USD. Leave currency_options out; the currency reference has the details.
Buy X, get Y#
Buy two tees and get a third free:
{
"name": "Tees 3 for 2",
"display_name": "Buy 2 tees, get 1 free",
"redemption_type": "automatic",
"discount_class": "line_item",
"application_method": {
"type": "buy_x_get_y",
"qualifying_item_rules": {
"all": [
{"attribute": "line_item.categories", "operator": "eq", "values": ["tees"]}
]
},
"buy_min_quantity": 2,
"discounted_item_rules": {
"all": [
{"attribute": "line_item.categories", "operator": "eq", "values": ["tees"]}
]
},
"get_quantity": 1,
"get_percent_off": 100,
"reward_selection": "cheapest",
"max_applications_per_order": 1
}
}
A unit can't count toward the purchase and be the reward, so when both rules match the same items, the cart needs three tees. With only two, the offer doesn't apply, and a code for it returns the buy_item_missing warning.
reward_selectionpicks which matching units are discounted:cheapest,highest_price, orfirst_added.get_percent_offis the discount on the reward units. Use50for "buy two, get one half off."max_applications_per_orderlimits how many times one order earns the reward. Leave it out to reward every complete set of three.
Buy-X-get-Y promotions must use discount_class: "line_item".
Free shipping#
Waive every shipping charge on the order:
{
"name": "Free shipping weekend",
"display_name": "Free shipping",
"redemption_type": "automatic",
"discount_class": "service_charge",
"application_method": {
"type": "percent_off",
"percent_off": 100,
"discounted_item_rules": {
"all": [
{"attribute": "charge.type", "operator": "eq", "values": ["shipping_fee"]}
]
}
}
}
A service_charge promotion discounts the order's charges and must say which ones in discounted_item_rules. The order discount lists them in order_charge_ids. The waived amount lowers pricing_amounts.charge_money rather than adding to discount_money. Add an order.subtotal rule to make it "free shipping over $75."
First order only#
Give a new customer 15% off, once. This one uses a code, so a buyer enters FIRST15:
{
"name": "First order 15",
"display_name": "15% off your first order",
"redemption_type": "code",
"discount_class": "order",
"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"}]
}
The two fields do different jobs, and a first-order offer needs both:
customer.paid_order_countis the eligibility test. It counts the customer's other orders for the same merchant in live mode or the same sandbox. An order counts once when it has a successful settled payment greater than zero, including a partial payment, or when a zero-total order completes. Orders completed with a 100% promotion or gift card count. Later refunds and disputes don't remove an order from the count. The current order, failed or canceled payment attempts, expired unpaid checkouts, unpaid drafts, and unpaid open invoices don't count. Guest purchases count after they are linked to the customer, including throughlink_guest_purchases. An unlinked purchase with the same email doesn't count.max_uses_per_customer: 1is the guarantee. Orders that haven't been paid don't count toward the rule, so two checkouts started together could both pass it. The limit reserves the customer's use atomically when payment starts, so only one of them can pay with the offer.
The count is a rule attribute only; Customer responses have no matching field. A use is released when a payment fails, is canceled, or expires, and a refund doesn't give it back, so a customer who is refunded can't use the offer again. max_uses still applies as a separate limit across all customers.
Flint needs to know who the buyer is. It uses the order's customer, and otherwise the customer named by the merchant or verified by email on the order's checkout session. An email typed at checkout doesn't identify a customer. Without an identified customer, applying this code returns 409 PROMOTION_DECLINED with reason customer_required. A customer who has used it up gets customer_limit_reached. Handle a code that doesn't apply shows how to respond.
Run for a limited time#
Add a schedule to any promotion. Outside it, the promotion keeps status: active but reads available: false, with unavailable_reason not_yet_started before starts_at and expired after ends_at. In either state it doesn't apply to orders.
"schedule": {
"starts_at": "2026-11-27T05:00:00Z",
"ends_at": "2026-12-01T08:00:00Z"
}
Times are RFC 3339 in UTC.
Manage codes and redemptions#
A code promotion can have as many codes as you need: one shared code for a newsletter, or a unique code for each customer. Add a code to an existing promotion:
curl -X POST https://api.withflintpay.com/v1/promotion-codes \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: code-spring-vip-001" \
-d '{
"promotion_id": "promo_1kmn0aExample",
"code": "SPRINGVIP",
"max_uses": 1,
"expires_at": "2026-12-31T23:59:59Z"
}'
The response is 201 with the code:
{
"data": {
"promotion_code_id": "pcode_1kmn0aExample",
"promotion_id": "promo_1kmn0aExample",
"code": "SPRINGVIP",
"customer_id": null,
"status": "active",
"available": true,
"max_uses": 1,
"uses_count": 0,
"version": 1,
"expires_at": "2026-12-31T23:59:59Z",
"created_at": "2026-10-14T22:19:59Z",
"updated_at": "2026-10-14T22:19:59Z"
}
}
A code that already exists in the same sandbox or live mode, in any letter case, returns 409 ALREADY_EXISTS.
- Limit redemptions.
max_useson a code limits that code, andmax_useson the promotion limits all of its codes together. A use counts towarduses_countandmax_usesas soon as the buyer starts paying. A failed or canceled payment releases it, and a refund doesn't give it back. An invoice's order and a partly paid order keep a discount they already carry, souses_countcan exceedmax_uses. Subscription renewals keep their discount without counting a use. - Limit redemptions per customer.
max_uses_per_customeron the promotion limits how many times one customer can use it across all of its codes, its automatic applications, and applications bypromotion_id. See First order only for an example, and the reference for what counts. - Bind a code to one customer. Send
customer_idwhen you create a code. OnPATCH, send a customer ID to bind or rebind the code,nullto remove the binding, or nothing to keep it. Only that customer can redeem the code. A different identified customer getscustomer_mismatch, and an order with no identified customer getscustomer_required. See Give a code to one customer. - Read one code.
GET /v1/promotion-codes/{promotion_code_id}returns the code with itsstatus,available, anduses_count. An archived code, including every code of an archived promotion, is still returned, withstatus: "archived",available: false, andunavailable_reason: "archived". - Turn a code off.
PATCH /v1/promotion-codes/{promotion_code_id}with"status": "inactive"stops new redemptions. Flint removes the code from unpaid orders the next time they're repriced or paid. Set it back toactiveto reuse it. To create a code that is off, send"status": "inactive"on create; the default isactive. - Retire a code.
DELETE /v1/promotion-codes/{promotion_code_id}archives the code for good and frees its string for reuse. The response returns the code withstatus: "archived"andavailable: false, exactly as a followingGETdoes. Repeating theDELETEreturns200with the same code and changes nothing, so a retry is safe. An archived code stays readable by ID and appears in lists only when you filter forstatus=archived. It can't be changed:PATCHreturns409 ACTION_NOT_ALLOWEDwithreason: archivedandcurrent_status: archivedindetails[0]. Creating a code under an archived promotion returns the same error, anddetails[0]names the promotion. Redemption by code ignores it. - Turn a promotion off.
PATCH /v1/promotions/{promotion_id}with"status": "inactive"pauses the promotion and all of its codes: each code keeps its ownstatusand readsavailable: falsewithunavailable_reason: promotion_unavailable. To create a promotion that is off, send"status": "inactive"on create; the default isactive.DELETEarchives it, and its codes are archived with it: they readstatus: "archived"and can't be redeemed. Repeating theDELETEreturns200with the archived promotion. An archived promotion can't be changed:PATCHreturns409 ACTION_NOT_ALLOWEDwithreason: archivedandcurrent_status: archivedindetails[0]. - React to changes. Creating, changing, and archiving promotions and codes send
promotion.*andpromotion_code.*webhook events. Archiving a promotion sends onlypromotion.archived, not an event for each of its codes.
To look up a code a buyer gave you, such as in a support conversation, search by code:
curl "https://api.withflintpay.com/v1/promotion-codes?code=springvip&expand=promotion" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07"
The response is 200 with a list of codes. expand=promotion adds each code's promotion, abridged here:
{
"data": [
{
"promotion_code_id": "pcode_1kmn0aExample",
"promotion_id": "promo_1kmn0aExample",
"code": "SPRINGVIP",
"status": "active",
"available": true,
"max_uses": 1,
"uses_count": 0,
"expires_at": "2026-12-31T23:59:59Z",
"promotion": {
"promotion_id": "promo_1kmn0aExample",
"name": "Spring sale 2026",
"display_name": "$10 off your order",
"status": "active",
"available": true
}
}
]
}
The code filter matches exactly, ignoring case but distinguishing accents. The list includes inactive, expired, and used-up codes, so check each code's available, or pass availability=available to list only codes a buyer can redeem now. Archived codes are left out unless you pass status=archived, which also finds them by code. Use GET /v1/promotion-codes?promotion_id={promotion_id} to list exactly one promotion's codes. A lookup doesn't check whether the code would apply to an order; preview it for that.
Give a code to one customer#
Send customer_id to bind a code to one customer, such as a win-back code for a lapsed buyer. Only that customer can redeem it. If the order's identified customer is a different one, applying the code returns 409 PROMOTION_DECLINED with reason customer_mismatch. If the order has no identified customer, it returns customer_required, so set the order's customer or name the customer on the checkout session first.
curl -X POST https://api.withflintpay.com/v1/promotion-codes \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: code-winback-ada-001" \
-d '{
"promotion_id": "promo_1kmn0aExample",
"code": "ADA-COMEBACK",
"customer_id": "cus_1kmn0aExample",
"max_uses": 1
}'
The response is 201 with the code, which now returns the customer in customer_id. Unbound codes return null. Find every code made for a customer with an exact filter, which leaves out unbound codes:
curl "https://api.withflintpay.com/v1/promotion-codes?customer_id=cus_1kmn0aExample" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07"
PATCH /v1/promotion-codes/{promotion_code_id} changes the binding: send another customer's ID to bind the code to them, or {"customer_id": null} to make the code redeemable by anyone. Leaving customer_id out keeps the binding. A bound code only controls who can redeem it; the promotion's max_uses_per_customer, customer.paid_order_count rules, and max_uses still apply.
Catalog and environment copies skip customer-bound codes entirely, so create the code again for that customer in the target environment. Promotions and unbound codes copy with their per-customer limit and rules.
Edit a promotion safely#
Promotions and codes each return a version that increases with every change. A promotion's version also moves when one of its codes is created, changed, or archived, so a promotion can change between your read and your write. Redemptions change uses_count without moving either version. Changing eligibility_rules or application_method replaces what decides who gets the discount and how much, so those requests require the version you read as expected_version. On other fields and on codes it's optional; send it whenever someone else might edit the same promotion.
Read the promotion right before you edit it, and keep its version with your draft:
curl https://api.withflintpay.com/v1/promotions/promo_1kmn0aExample \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07"
The response, abridged, shows the promotion at version 7:
{
"data": {
"promotion_id": "promo_1kmn0aExample",
"name": "Spend 50 save 10",
"status": "active",
"uses_count": 41,
"version": 7
}
}
Then send your change with that version. This raises the threshold to $60:
curl -X PATCH https://api.withflintpay.com/v1/promotions/promo_1kmn0aExample \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Flint-Version: 2026-09-07" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: promo-threshold-60-v7" \
-d '{
"expected_version": 7,
"eligibility_rules": {
"all": [
{"attribute": "order.subtotal", "operator": "gte", "values": [{"amount": 6000, "currency": "USD"}]}
]
}
}'
The response is the updated promotion with version 8. If the promotion changed after your read, Flint changes nothing and returns 409 VERSION_CONFLICT with the current version, abridged here:
{
"error": {
"type": "conflict_error",
"code": "VERSION_CONFLICT",
"param": "expected_version",
"remediation": { "retry": "after_refresh" },
"details": [
{
"code": "VERSION_CONFLICT",
"param": "expected_version",
"resource_type": "promotion",
"resource_id": "promo_1kmn0aExample",
"current_version": 9
}
]
}
}
Don't resend the same body with the new number. Reconcile the draft first:
- Keep the change you were making.
- Read the promotion again.
- Compare the fields you changed with their current values. If a code change moved the version, your fields are as you left them, and you can send the same change. If someone edited the same fields, decide which value should win.
- Send the reconciled change with the new
versionasexpected_version. The conflict'snext_stepssays whether you can reuse itsIdempotency-Key.
Leaving out expected_version while sending eligibility_rules or application_method, including "eligibility_rules": null, returns 400 INVALID_REQUEST with detail code REQUIRED. DELETE takes the fence as a query parameter, such as DELETE /v1/promotions/promo_1kmn0aExample?expected_version=9. A code's version is separate: PATCH and DELETE on a code check expected_version against the code. The promotions reference lists what moves each version.
Control how offers stack#
When several promotions could apply to one order, Flint decides which ones it keeps:
- Manual discounts always stay. Promotion rules never remove them.
- Flint collects the candidates: the code being applied or the codes sent when creating the order, promotions already on the order, and every automatic promotion the order qualifies for.
- Promotions that share an
exclusivity.groupcompete, and only one from each group continues. - The rest are ranked by the discount each would give on its own, largest first, and admitted in that order. A promotion is skipped when the order already has
max_promotions_per_orderpromotions, or when itscombines_withrules out a discount already admitted.
Two fields on the promotion shape this:
combines_withlists the discount classes the promotion can share an order with. Both promotions must allow each other's class. Leaving it out allows every class, so set it to restrict stacking:{"order": false, "line_item": true, "service_charge": true}means the promotion never shares an order with another order-wide promotion. To keep a promotion from sharing an order with any other promotion discount, set all three classes tofalse. On create, a class you leave out istrue. OnPATCH /v1/promotions/{promotion_id}, only the classes you send change, and the others keep their current value. Sendingnullor{}, ornullfor a class, returns400.exclusivitymakes a set of promotions compete for one slot. Give them the samegroupstring, 1 to 100 characters, matched exactly and case-sensitively. The promotion with the highestprioritywins, andprioritydefaults to0. Equal priorities go to the larger discount, then the earliercreated_at, then the lowerpromotion_id.
For example, give a welcome offer this exclusivity, and leave the other promotions in the welcome-offers group at a lower priority. Only one of them applies to an order, and the welcome offer wins whenever it qualifies:
"exclusivity": {
"group": "welcome-offers",
"priority": 10
}
When a promotion loses its group, its decline reason is superseded_by_higher_priority if the winner's priority is higher, and superseded_by_better_offer otherwise.
Turn promotions on or off#
Your account settings decide whether promotions apply at all. Send the promotions object to PATCH /v1/settings, which needs the settings.write scope:
{
"promotions": {
"automatic_enabled": true,
"codes_enabled": true,
"max_promotions_per_order": 3
}
}
Both switches are on until you turn them off. max_promotions_per_order is 2 by default and accepts 1 to 10. Manual discounts don't count toward it. When you lower it, open orders keep their most valuable promotions up to the new limit the next time they change or are repriced.
When code entry is unset on the session, payment link, and checkout.promotion_codes_enabled, hosted checkout shows the field only while the merchant has an active code promotion whose schedule includes now in this environment. CheckoutSession.can_apply_promotion_code reports this offer on every read. Draft, future, ended, and automatic promotions do not count. An explicit true offers entry without a promotion; false refuses codes. With null, a valid code still applies even if it became active after the last read.
A checkout session or payment link can turn automatic promotions or codes off for its own buyers with promotion_config. For example, "promotion_config": {"codes_enabled": false} on POST /v1/checkout-sessions hides the code field on that checkout. It can't turn on something your account settings turned off, which returns 409, and it can't change max_promotions_per_order. promotion_config covers changes the buyer makes in that checkout. Changes you make with your API key follow your account settings, and the open checkout session stays open and reprices.
Discount a subscription#
A promotion applied to a subscription's signup checkout can also discount its renewals. application_method.recurrence decides how many charged cycles it covers, from only the signup order to every renewal. Subscription billing covers the options.
To discount an existing subscription, call POST /v1/subscriptions/{subscription_id}/promotions with promotion: {"promotion_code": "RETENTION20"} or promotion: {"promotion_id": "promo_1kmn0aExample"}. Both this route and POST /v1/subscriptions/{subscription_id}/promotions/remove require commerce.subscriptions.write, accept an optional Idempotency-Key, and return the updated subscription with status 200.
Use first_cycle to schedule the discount and replace_promotion_id to replace an attached promotion from that cycle forward. Remove up to 5 promotions together by sending their IDs in promotion_ids to the remove route. Paid orders and the unpaid past_due order keep their prices. See Discount a subscription for timing, replacement, and reattachment rules.
To estimate a promotion before applying it, send mode: "promotion_apply", subscription_id, and promotion to POST /v1/subscription-previews. This merchant API request requires commerce.subscriptions.read and no Idempotency-Key. It returns the proposed attachment and an estimate for its first eligible cycle without saving changes. Eligibility refusals return HTTP errors. See Preview a promotion.
The subscription's promotions array lists the promotions eligible to discount its next charge. scheduled_promotions lists those starting later. Both include first_cycle; remaining_cycles is the number of discounted cycles left, or null for a forever promotion that no replacement limits. The next-charge preview shows the discount amounts.
Attach promotions when you create or import#
POST /v1/subscriptions accepts up to five promotions. Each entry has a required promotion containing exactly one of promotion_id or promotion_code, and an optional first_cycle. Sending a promotion ID also works for a promotion that requires a code. Duplicate promotions return 400 INVALID_REQUEST with detail code INVALID_VALUE. An offer's own promotion attaches automatically; listing it again returns 409 PROMOTION_DECLINED with reason already_applied.
{
"promotions": [
{
"promotion": {"promotion_code": "WELCOME20"},
"first_cycle": 1
}
]
}
first_cycle defaults to 1. For an import, it defaults to billing_start.completed_cycles + 1 and cannot be earlier. Only imports accept consumed_cycles, the number of discounted cycles already used on the previous system. It defaults to 0, must be less than period_count for a repeating promotion, and must be 0 for once or forever. For example, importing a three-cycle promotion with consumed_cycles: 2 leaves one discounted cycle. Sending consumed_cycles, even 0, for another billing start returns 400 INVALID_REQUEST with detail code NOT_ALLOWED.
Flint freezes the promotion's current terms at attachment and checks whether they qualify for the order at first_cycle. Each attachment counts one use toward the promotion's max_uses and, when sent by code, the code's limit. Later renewals and replays count no additional uses. Paid cycles consume the discounted-cycle allowance only when the order carries the discount.
Send the same input to POST /v1/subscription-previews with mode: "create". Promotion refusals appear in errors, with a subscription.promotions[i] parameter. Previewing attaches nothing and counts no uses.
Signup promotions on a subscription order#
When a buyer accepts a promotion that belongs to the subscription rather than to this order, such as a signup offer whose discount starts on the first charged cycle, the order lists it in deferred_promotions instead of discounts. The array is on every order and every buyer order, and is empty when there are none.
{
"deferred_promotions": [
{
"deferred_promotion_id": "dp_1kmn0bExample",
"promotion_id": "promo_1kmn0cExample",
"promotion_code": "TRIAL20",
"customer_facing_name": "20% off your first month"
}
]
}
promotion_codeis the code the buyer entered, ornullwhen the promotion was applied bypromotion_id.customer_facing_nameis the name as it was when the order accepted the promotion.- A deferred promotion doesn't discount this order. It isn't in
discountsand doesn't changetotal_money,discount_money, or any other amount on the order. - When Flint creates the subscription, the promotion attaches to it, and its discount first applies to the first charged cycle. Subscription billing covers how a promotion's
recurrencecontinues from there.
Remove one with deferred_promotion_ids on .../discounts/remove. Until the order is paid, a buyer can remove a signup promotion they applied with a code in hosted checkout, and entering the code again accepts it again. If a code is valid but another accepted promotion keeps it from applying, the apply response carries the same promotion_declined warning as for any other skipped code.
Next steps#
- Promotions API reference: every field, rule attribute, and decline reason.
- Checkout sessions: hosted checkout, where buyers enter codes themselves.
- Tips and charges: the shipping and service charges a
service_chargepromotion discounts. - Catalog setup: categories and products for item-targeted offers.
- Error handling: the error envelope and how to branch on codes.
Stripe Checkout takes one coupon or promotion code per session. Stripe Checkout multiple coupons compares merging codes into one coupon with stacking rules.
Promotions with price lists#
Promotions discount the negotiated net unit price plus modifiers. Price lists do not count toward max_promotions_per_order; normal promotion combination rules still apply. Use customer.segment rules when a promotion should exclude wholesale buyers. See wholesale pricing.