Promotions
A promotion is a reusable discount rule, such as 20% off hats, $10 off orders of $50 or more, or buy two tees and get one free. Flint applies it to every order that qualifies, or only when a buyer enters one of its codes. The promotion holds the rule. Its promotion codes are separate resources, so one promotion can have many codes, each with its own limit and expiry, or none at all.
A promotion never changes an order by itself. It applies when an order is priced: automatically when the order qualifies, or when you apply its code or ID to the order. Managing promotions and codes needs commerce.promotions.write, reading them needs commerce.promotions.read, and applying them to orders needs commerce.orders.write. The Promotions guide walks through creating, applying, previewing, and removing them.
How a promotion is built#
Each part of a promotion is its own field, and most have a default:
- The discount.
application_methodispercent_off,amount_off, orbuy_x_get_y. It's required, including itstype. - The layer.
discount_classisorder(the default),line_item, orservice_charge. - Who qualifies.
eligibility_rulesare the conditions an order must meet. Leave them out and every order qualifies. - What gets discounted.
application_method.discounted_item_ruleschoose the items or charges; see targeting. - How a buyer gets it.
redemption_typeisautomaticorcode. It defaults tocodewhen you sendcodes, and toautomaticotherwise. - What it shares an order with.
combines_withandexclusivity. By default it combines with every class and belongs to no group. - When and how often.
schedule,max_uses, andmax_uses_per_customer. By default it applies at any time, without a limit.
name is your internal label and is required. display_name is what buyers see at checkout and on the order, and defaults to name. A promotion is created active unless you send status: inactive.
Times such as schedule.starts_at, schedule.ends_at, and a code's expires_at are absolute RFC 3339 timestamps in UTC. schedule.timezone and a code's timezone record the IANA zone they were entered in, for display only.
This code promotion takes 20% off hats once the hats in the cart reach $50, for one week:
curl -X POST https://api.withflintpay.com/v1/promotions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: promo-hat-week-001" \
-d '{
"name": "Hat week 2026",
"display_name": "20% off hats over $50",
"redemption_type": "code",
"discount_class": "line_item",
"eligibility_rules": {
"all": [
{"attribute": "line_item.categories", "operator": "eq", "values": ["hats"]},
{"attribute": "matched_items.subtotal", "operator": "gte", "values": [{"amount": 5000, "currency": "USD"}]}
]
},
"application_method": {"type": "percent_off", "percent_off": 20},
"schedule": {"starts_at": "2026-11-02T08:00:00Z", "ends_at": "2026-11-09T08:00:00Z"},
"codes": [{"code": "HATS20", "max_uses": 1000}]
}'
{
"data": {
"promotion_id": "promo_1kmn0aExample",
"name": "Hat week 2026",
"display_name": "20% off hats over $50",
"status": "active",
"available": false,
"unavailable_reason": "not_yet_started",
"redemption_type": "code",
"discount_class": "line_item",
"application_method": {"type": "percent_off", "percent_off": 20, "allocation": "each"},
"combines_with": {"order": true, "line_item": true, "service_charge": true},
"codes_summary": {"total_count": 1, "active_count": 1, "newest_active_code": "HATS20"},
"codes": [
{
"promotion_code_id": "pcode_1kmn0aExample",
"promotion_id": "promo_1kmn0aExample",
"code": "HATS20",
"status": "active",
"available": false,
"unavailable_reason": "promotion_unavailable",
"max_uses": 1000,
"uses_count": 0,
"version": 1
}
],
"uses_count": 0,
"version": 1
}
}
The response is abridged. The promotion is active but not yet available, because its schedule starts later, and its code reports promotion_unavailable for the same reason. Both become available on starts_at with no change on your side. The eligibility rules match only line items, so the hats they match are also the items discounted, and no discounted_item_rules are needed. The hats category must already exist, or the request returns 404 RESOURCE_NOT_FOUND.
Apply promotions to orders#
Automatic promotions need no call: Flint adds them to every order that qualifies. Codes and promotion IDs go through the order:
- POST
/v1/orders/{order_id}/discountsRequired API key scope: commerce.orders.writecommerce.orders.writeReference for POST /v1/orders/{order_id}/discountsApplies one promotion by
promotion_codeorpromotion_id, or one manual discount. You can also send codes indiscountswhen you create the order. - POST
/v1/discount-previewsRequired API key scopes: commerce.orders.read or commerce.orders.writecommerce.orders.readorcommerce.orders.writeReference for POST /v1/discount-previewsShows what a code would take off an order, and how close the order is to an automatic offer, without changing the order.
- POST
/v1/orders/{order_id}/discounts/removeRequired API key scope: commerce.orders.writecommerce.orders.writeReference for POST /v1/orders/{order_id}/discounts/removeRemoves pending code and manual discounts by
order_discount_ids, and signup promotions the order accepted for its subscription bydeferred_promotion_ids. Send at least one list. A discount from an automatic promotion stays while the order qualifies. - POST
/v1/orders/{order_id}/discounts/repriceRequired API key scope: commerce.orders.writecommerce.orders.writeReference for POST /v1/orders/{order_id}/discounts/repriceRecalculates pending discounts, for example before a final review screen. Order changes already reprice them.
Use promotion_code for a code a buyer entered. Use promotion_id from your server when you already know the promotion: a code promotion applied this way needs no code and counts only toward the promotion's max_uses. Account promotion settings still apply: a code-type promotion requires account codes to be enabled even when applied by ID. Checkout credentials must use promotion_code. A promotion's rules choose the line items it discounts, so a promotion discount takes no order_line_item_ids.
Eligibility, targeting, and class#
Three fields decide who qualifies, what gets discounted, and at which layer:
eligibility_rulesis the gate: conditions the order, customer, or items must meet before the promotion applies at all.discounted_item_rules, insideapplication_method, is the target: the line items or charges that receive the discount.discount_classis the layer:orderdiscounts the whole order,line_itemdiscounts matching items, andservice_chargediscounts charges such as shipping.
discounted_item_rules is required for service_charge and buy_x_get_y promotions. A line_item promotion can leave it out only when its eligibility_rules use line-item conditions alone (line_item.* and matched_items.subtotal); the items those rules match are then the target. Gate on anything else, such as order.subtotal or a customer, and you also need discounted_item_rules. Leaving it out returns 400 INVALID_REQUEST with detail code REQUIRED on application_method.discounted_item_rules, including on an update that changes only eligibility_rules.
buy_x_get_y promotions must use the line_item class. Their qualifying_item_rules choose the units that count toward buy_min_quantity, and a unit can't count toward the purchase and be the reward at once.
Allocation#
When several items or charges match, allocation decides how the effect spreads across them. It defaults to each for line_item and service_charge promotions and across for order promotions.
allocation | amount_off of $10 on three matching items | percent_off |
|---|---|---|
each | $10 off each item, $30 in total, each capped at the item's price | Taken from each item |
across | $10 once, spread over the three items | Taken from their combined subtotal |
For percent_off, both give the same total and differ only in how the discount is attributed to line items. max_discounted_quantity limits a percent_off promotion to that many matching units and requires each. Flint discounts the first matching units in the order they were added to the order, not the cheapest.
Rules#
eligibility_rules, discounted_item_rules, and qualifying_item_rules all take the same rule group.
Rule groups#
A rule group is an object with exactly one key: all (every entry must match) or any (at least one must match). Each holds at least one entry, and an entry is a rule or a nested group. Nest groups to mix the two, such as {"all": [rule, {"any": [rule, rule]}]}.
{
"all": [
{"attribute": "line_item.categories", "operator": "in", "values": ["hats", "shirts"]},
{"attribute": "customer.segment", "operator": "eq", "values": ["wholesale"]},
{"attribute": "order.subtotal", "operator": "gte", "values": [{"amount": 5000, "currency": "USD"}]}
]
}
For no rules, omit the field, or send null on an update where the field can be cleared. Bare arrays, empty groups, an object with both all and any, and a rules key return 400 INVALID_REQUEST with detail code INVALID_VALUE and param naming the path.
Flint normalizes groups on write without changing what they match: responses list a group's rules before its nested groups, and under any a nested group with one rule reads back as that rule. Under all, nested groups keep their boundaries, because matched_items.subtotal counts only the items matched by the line_item.* rules in its own all group and the groups nested in it. Writing back a group you read gives the same group.
Rule attributes#
A rule tests one attribute with an operator and values. The attribute fixes the value type and the operators it accepts. Flint checks every rule when you create or update the promotion, so an unknown attribute, a disallowed operator, or a value of the wrong type returns 400 INVALID_REQUEST, and the message lists the operators the attribute allows. The same matrix is machine-readable in the x-flint-rule-attributes extension on the PromotionRule schema in the OpenAPI spec.
| Attribute | Value | Operators | Matches |
|---|---|---|---|
order.subtotal | money | gt, gte, lt, lte | The order's merchandise subtotal |
order.merchandise_subtotal_before_discounts | money | gt, gte, lt, lte | The same value as order.subtotal |
order.merchandise_subtotal_after_line_item_discounts | money | gt, gte, lt, lte | The subtotal after line-item discounts |
matched_items.subtotal | money | gt, gte, lt, lte | The subtotal of the items matched in the same all group |
order.currency | string | eq, ne, in, contains, is_defined | The order's currency, such as USD |
customer.segment | string | eq, in, is_defined | The customer's segment, a label you assign |
customer.is_merchant_verified | boolean | eq | The customer's is_merchant_verified flag, which you set |
customer.paid_order_count | number | eq, ne, gt, gte, lt, lte, in, is_defined | The customer's other paid or completed zero-total orders in this merchant and environment |
metadata.<key> | string | eq, ne, in, contains, is_defined | A key in the customer's metadata, such as metadata.channel |
line_item.product_id | string | eq, ne, in, contains, is_defined | Catalog product ID |
line_item.variant_id | string | eq, ne, in, contains, is_defined | Catalog variant ID |
line_item.bundle_id | string | eq, ne, in, contains, is_defined | Catalog bundle ID |
line_item.categories | category handle | eq, ne, in, is_defined | The item's categories; ne matches when none of them match |
line_item.quantity | number | eq, ne, gt, gte, lt, lte, in, is_defined | The item's quantity |
charge.type | string | eq, ne, in, contains, is_defined | The charge type, such as shipping_fee or delivery_fee |
delivery_choice.type | string | eq, ne, in, contains, is_defined | shipment, pickup, or local_delivery |
delivery_choice.method_id | string | eq, ne, in, contains, is_defined | The selected delivery method ID |
delivery_choice.raw_amount | money | gt, gte, lt, lte | The delivery price before delivery discounts and tax |
delivery_choice_group.id | string | eq, ne, in, contains, is_defined | The choice group of the selected method |
choice_group.merchandise_subtotal_before_discounts | money | gt, gte, lt, lte | The value of the items in the selected delivery choice's group |
choice_group.merchandise_subtotal_after_line_item_discounts | money | gt, gte, lt, lte | The same value after line-item discounts |
How values and operators work:
valuesis always an array. Onlyintakes more than one value.is_definedtakes novaluesand tests only whether the attribute is present.- String comparisons ignore case.
containsis a substring match on one value; for "one of these values", usein. - A money value needs its
currency, and Flint accepts only USD today; see currency. - Category rules take a category handle, and the category must exist, or the request returns
404 RESOURCE_NOT_FOUND. - Customer segment, verification, and
metadata.<key>rules don't match without an identified customer or when the required customer value is missing.
Customer paid order count#
customer.paid_order_count 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 through link_guest_purchases. An unlinked purchase with the same email doesn't count.
Rules use the order's customer, falling back to the customer named by the merchant or verified by email in the checkout session. Entering an email alone doesn't identify a customer. Applying a promotion that uses this attribute without an identified customer returns 409 PROMOTION_DECLINED with reason customer_required.
The count is available only as a rule attribute. Customer responses have no matching field.
Use {"attribute": "customer.paid_order_count", "operator": "eq", "values": [0]} to require no other paid or completed zero-total orders. Pair it with max_uses_per_customer: 1 for a first-order offer; see Per-customer limits.
Currency#
Flint accepts only USD today, so amount_off_money and every money threshold in a rule, such as order.subtotal, are in USD. Leave currency_options out: it keys alternative amounts by currency code, and a currency Flint doesn't accept fails like any other unsupported currency. Money & currency has the rules.
Codes#
A promotion with redemption_type: code applies only through one of its codes or its ID. Codes are separate resources under /v1/promotion-codes, each with its own status, max_uses, expires_at, and uses_count, so one campaign can have a shared newsletter code and a single-use code for each customer.
- A code promotion needs at least one code in
codeswhen you create it, and takes at most 100 per request. The create response returns them incodes, in request order, with eachpromotion_code_id; no other promotion response includescodes. Add more withPOST /v1/promotion-codes, withpromotion_idin the body. - Codes are unique within live mode or a sandbox, ignoring case but distinguishing accents, and keep the spelling you created.
CAFÉandcafématch the same code;CAFEis a separate code. A code that already exists returns409 ALREADY_EXISTS, and leading or trailing spaces are rejected. - Only code promotions take codes. Sending
codeswithredemption_type: automatic, or creating a code under an automatic promotion, returns400 INVALID_REQUEST. - A code's
expires_atmust be in the future when you set it. GET /v1/promotion-codes?code=finds a code by the same matching rule, andGET /v1/promotion-codes?promotion_id={promotion_id}lists exactly one promotion's codes.
Customer-bound codes#
A code's customer_id binds it to one customer, so a unique code can be sent to the person it was made for. Leave customer_id out when you create the code for a code anyone can redeem. Responses return customer_id as null for an unbound code.
- Only the bound customer can redeem the code. Applied to an order whose identified customer is a different one, it returns
409 PROMOTION_DECLINEDwith reasoncustomer_mismatch. With no identified customer, it returnscustomer_required. See Per-customer limits for how Flint identifies the customer. - The binding applies to that code only. The promotion's other codes, its automatic applications, and applying it by
promotion_idaren't bound. PATCHkeeps the binding when you omitcustomer_id, binds the code to another customer when you send that customer's ID, and removes the binding when you sendnull.GET /v1/promotion-codes?customer_id={customer_id}lists the codes bound to that customer. The filter is an exact match, so unbound codes aren't in the result. It combines with the other filters, such aspromotion_id.- Catalog and environment copies skip customer-bound codes. Promotions and unbound codes copy with their
max_uses_per_customerand rules. Create the code for that customer again in the target environment.
Status#
status is the switch you control. A promotion and each of its codes start active unless you create them inactive. Switch one off or on by sending status with PATCH, and archive it with DELETE:
- active moves to inactive on switch off
- inactive moves to active on switch on
- active moves to archived on DELETE
- inactive moves to archived on DELETE
status on promotionactiveSwitched on. It applies whenever it's alsoavailable.inactiveSwitched off. It stays editable, and settingstatusback toactiveresumes it.archivedFinalArchived withDELETE, along with its codes. It stays readable but can't be changed or applied again.
Availability#
Whether a promotion can apply right now is a separate question, answered by available and, when it's false, unavailable_reason:
{"status": "active", "available": false, "unavailable_reason": "not_yet_started"}
A promotion is available when it is active, inside its schedule, under its max_uses, and, for a code promotion, has at least one code a buyer can redeem. Otherwise unavailable_reason is the first of these that applies:
unavailable_reason on promotioninactiveYou setstatustoinactive. Set it back toactiveto resume.archivedThe promotion was archived withDELETE. It can't be changed or applied again.not_yet_startedschedule.starts_atis in the future.expiredschedule.ends_athas passed.exhausteduses_counthas reachedmax_uses.no_active_codesA code promotion has no code a buyer can redeem. Add a code or reactivate one.
A code has the same pair of fields. Its own state comes first, and promotion_unavailable means the code is fine but its promotion isn't:
unavailable_reason on promotion codearchivedThe code was archived withDELETE, on its own or with its promotion.inactiveYou set the code'sstatustoinactive.expiredThe code'sexpires_athas passed.exhaustedThe code'suses_counthas reached itsmax_uses.promotion_unavailableThe code is usable, but its promotion isn't. Read the promotion'sunavailable_reason.
A schedule boundary or an expiry changes available when the time passes. It doesn't change version or send a webhook. New reasons may be added, so keep a fallback for one you don't recognize.
A code promotion also returns codes_summary, so a list can show how buyers redeem each promotion without reading its codes. total_count counts codes that aren't archived, active_count counts codes a buyer can redeem now, and newest_active_code is omitted when active_count is 0.
On both lists, status and availability filter on these fields. Archived promotions and codes are left out unless status includes archived. For example, GET /v1/promotions?status=active&availability=not_yet_started,expired,exhausted,no_active_codes lists promotions that are switched on but can't apply.
Archiving#
DELETE /v1/promotions/{promotion_id} archives a promotion, and its codes are archived with it. Each code it archived sends promotion_code.archived shortly after promotion.archived. DELETE on a code archives only that code and frees its string for reuse. An archived promotion or code:
- stays readable by ID with
status: archived, andDELETEreturns it exactly as a followingGETdoes; - can't be applied, and leaves unpaid orders the next time they change or are repriced;
- can't be changed:
PATCH, or creating a code under an archived promotion, returns409 ACTION_NOT_ALLOWEDwithreason: archived.
Repeating a DELETE returns 200 with the same body and changes nothing, so retries are safe.
Usage limits#
max_uses on a promotion limits redemptions across all of its codes and its automatic applications. max_uses on a code limits that code. Both must be positive; leave them out for no limit.
A use counts as soon as a buyer starts paying an order that carries the discount. A failed or canceled payment releases it, and a refund doesn't give it back. Flint checks the limit only when payment starts on an unpaid order, so an invoice's order or a partly paid order keeps a discount it already carries and counts the use, and uses_count can then exceed max_uses.
A subscription uses a promotion once, at signup. Renewals keep their discount as the promotion's recurrence allows and don't count toward max_uses, so reaching the limit stops new signups but never a renewal. Subscription billing covers recurrence.
Per-customer limits#
max_uses_per_customer limits how many times one customer can use the promotion. It's a positive integer, or null for no per-customer limit. It works alongside max_uses, so an order needs room under both.
- What counts. A customer's uses are their reserved and redeemed uses of the promotion across every code, automatic applications, and applications by
promotion_id, in the same merchant and environment (live mode or the same sandbox). - When it's enforced. Flint checks and reserves the use atomically when payment starts, so two checkouts for the same customer can't both take the last use. A failed, canceled, or expired payment releases the use, and a refund doesn't give it back.
- Who the customer is. Flint uses the order's customer. Without one, it falls back to the customer named by the merchant or verified by email in the order's checkout session. An email typed at checkout doesn't identify a customer. With no identified customer, a promotion that has
max_uses_per_customeror acustomer.paid_order_countrule, or a code bound to a customer, returns409 PROMOTION_DECLINEDwith reasoncustomer_required. An identified customer other than a bound code's customer getscustomer_mismatch. - When it's reached. The customer gets
409 PROMOTION_DECLINEDwith reasoncustomer_limit_reached. Other customers aren't affected.
For a first-order offer, combine a customer.paid_order_count rule of eq 0 with max_uses_per_customer: 1. The rule counts only paid or completed zero-total orders, so by itself it can't stop two checkouts started before either pays; the limit does. See Customer paid order count for exactly which orders count.
Stacking and conflicts#
Every time an order is priced, Flint decides which promotions it keeps:
- Manual discounts stay. Promotion rules never remove them, and they don't count toward the promotion limit or
combines_with. - Promotions from a subscription's frozen terms come next, outside exclusivity,
combines_with, and the limit. - The candidates are the code or ID being applied, the codes sent when creating the order, promotions already on the order, and every automatic promotion the order qualifies for.
- Within each
exclusivity.group, only one candidate continues. - The rest are ranked by the discount each would give alone, largest first, with ties to the earlier
created_atand then the lowerpromotion_id. Each is admitted unless the order has reachedmax_promotions_per_order, or it and a discount already admitted don't both allow each other'sdiscount_class. - Admitted discounts are priced line-item discounts first, then order discounts, then service-charge discounts. A percent discount is taken from what's left on its targets after the discounts priced before it. A promotion whose discount comes to zero is dropped, and selection runs again.
Selection is greedy rather than a search for the largest total, so one large promotion that doesn't combine can keep out smaller ones that would add up to more.
combines_with lists the classes a promotion can share an order with, and both promotions must allow each other's class. Leaving it out allows every class, so set it to restrict stacking. To keep a promotion from sharing an order with any other promotion discount, set order, line_item, and service_charge all to false.
exclusivity makes promotions compete for one place. Give them the same group, 1 to 100 characters, matched exactly and with case. The highest priority wins, with equal priorities going to the larger discount, then the earlier created_at, then the lower promotion_id. priority defaults to 0.
Your account settings can turn off automatic promotions or codes, and set max_promotions_per_order, from 1 to 10 with a default of 2. A checkout session's or payment link's promotion_config can turn either off for its own buyers.
Pending discounts stay live until the order is paid. Every order change reprices them with these rules: a promotion that no longer qualifies or now loses is removed, and a newly qualifying automatic promotion is added. A promotion that became unavailable, such as one you set to inactive or one past its max_uses, leaves unpaid orders the same way. If the buyer pays first, POST /v1/orders/{order_id}/pay removes it, charges nothing, and returns 409 VERSION_CONFLICT, so read the order and show the new total. Once the order is paid in full, its discounts are redeemed and don't change. Keep discounts current until payment shows the reprice call.
Decline reasons#
When a promotion doesn't apply, Flint returns a machine-readable reason. The values are the same everywhere; where the reason appears depends on the outcome:
| Outcome | Where to read the reason |
|---|---|
| The code or promotion can't be applied | error.details[0].reason, with error.code: PROMOTION_DECLINED |
| The code is valid but lost to other offers | meta.warnings[].reason on a promotion_declined warning |
| Applying it removed promotions already on the order | meta.warnings[].reason on each promotion_removed warning |
| A discount preview | promotion_decline_reason on each candidate |
PROMOTION_DECLINED errors return 409. A promotion that is accepted but cannot apply can instead return a promotion_declined warning in a successful response. For example, 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. A code with invalid characters or length returns 400 INVALID_REQUEST with detail INVALID_VALUE at the code's parameter. Handle a code that doesn't apply shows each response and what to tell the buyer. Branch your buyer-facing copy on the reason, not on the message text.
promotion_decline_reason on promotion candidatenot_eligibleThe order doesn't meet the eligibility rules. A reason your integration doesn't recognize also means this.minimum_not_metA spend minimum isn't reached. Errors addrequired_money,current_money, andgap_money; preview candidates addthreshold_money,current_money, andgap_money.expiredThe promotion'sschedule.ends_ator the code'sexpires_athas passed.not_yet_startedThe promotion'sschedule.starts_atis in the future.exhaustedThe promotion or code has reached itsmax_uses.customer_limit_reachedThe customer has used the promotionmax_uses_per_customertimes.customer_requiredThe order has no identified customer, and the promotion has amax_uses_per_customerlimit or acustomer.paid_order_countrule, or the code is bound to a customer.customer_mismatchThe order's identified customer isn't the customer the code is bound to.code_requiredThe promotion needs a code, and none was given.code_invalidNo code matches the string entered.inactiveThe promotion or code is inactive or archived.automatic_disabledAutomatic promotions are turned off in your settings or for this checkout.codes_disabledPromotion codes are turned off in your settings or for this checkout.already_appliedThe promotion is already on the order.recurrence_completedThe removed promotion has no discounted cycles remaining on this subscription. Reattaching it does not reset its allowance.not_combinableItscombines_withand another discount's don't allow each other's class.superseded_by_better_offerA promotion in the same exclusivity group with equal priority and a larger discount won.superseded_by_higher_priorityA promotion in the same exclusivity group with a higherexclusivity.prioritywon.supersededAnother promotion replaced this one. Prefer the two more specific reasons above when you get them.max_promotions_reachedThe order already hasmax_promotions_per_orderpromotions.no_discountable_balanceNothing is left on the order to discount.buy_item_missingThe cart lacks enough qualifying units or separate reward units for a buy-X-get-Y promotion. A unit cannot count toward both quantities.currency_mismatchThe order's currency has no discount amount or threshold.unknown_typeFlint can't evaluate the promotion's effect or rules.
Updating a promotion#
PATCH /v1/promotions/{promotion_id} changes only what you send, and application_method, schedule, exclusivity, and combines_with work the same way one level down. {"schedule": {"ends_at": "2026-12-31T23:59:59Z"}} moves the end and keeps starts_at. An empty object for any of them returns 400 INVALID_REQUEST.
- Rule groups,
recurrence,amount_off_money, andcurrency_optionsare replaced whole when you send them. - To change the effect, send
application_method.typewith the new effect's fields, as on create.allocation,calculation_basis,recurrence, anddiscounted_item_ruleskeep their values unless you send them. Sending another effect's field withouttype, such asamount_off_moneyon apercent_offpromotion, returns400 INVALID_REQUEST. nullclears an optional field, such asmax_uses,max_uses_per_customer,eligibility_rules,scheduleor one of its fields,exclusivity, orapplication_method.discounted_item_rules.nullon a required field returns400 INVALID_REQUEST.exclusivity.prioritycan't benull; send0to reset it.- While the promotion's
uses_count, or any of its codes'uses_count, is above0, itsdiscount_classand effect type are fixed. Changing them returns409 ACTION_NOT_ALLOWEDwith reasonfield_locked; create a new promotion instead.
Flint validates the promotion that results, so a change that leaves schedule.ends_at before schedule.starts_at is rejected even when you sent only one of them. A change applies to orders priced from then on; discounts on paid orders don't change.
Versions#
Every promotion and code returns version, which starts at 1 and increases with each committed change:
- A code's
versionincreases when you update or archive it. - A promotion's
versionincreases when you update or archive it, and when creating, updating, or archiving one of its codes changes itscodes_summary. That change also sendspromotion.updated. - Redemptions, released uses, and time passing don't change either one:
uses_count,available,unavailable_reason,codes_summary.active_count, andcodes_summary.newest_active_codechange without a newversion.
Send the version you read as expected_version to refuse a write if the resource changed since:
| Request | expected_version |
|---|---|
PATCH a promotion with application_method or eligibility_rules, including null | Required |
PATCH a promotion with other fields | Optional |
PATCH a code | Optional, checked against the code |
DELETE a promotion or code | Optional, as a query parameter |
Leaving out a required value returns 400 INVALID_REQUEST with detail code REQUIRED. A stale value returns 409 VERSION_CONFLICT with details[0].current_version, and nothing changes, even when the resource is already archived.
A code change can move a promotion's version between your read and your write; redemptions don't. Read it just before a rule change. On a conflict, read it again, reapply your change, and send it with the new version and a new Idempotency-Key. Edit a promotion safely walks through it.
Errors#
- StatusHTTP 400CodeINVALID_
REQUEST What to doA rule, effect, or field is invalid, andparamnames it. A non-positive or non-integermax_uses_per_customer, an emptycustomer_idfilter, or a code binding to a customer outside the merchant and environment is rejected. Other cases include: an unknown attribute or operator, an empty or malformed rule group, missingdiscounted_item_rules, a code promotion withoutcodes,codeson an automatic promotion, more than 100codes, or a missingexpected_version(detailREQUIRED). - StatusHTTP 404What to doThe promotion or code doesn't exist in this mode, or a category rule names a category handle that doesn't exist.
- StatusHTTP 409CodeALREADY_
EXISTS What to doAnother code in this mode has the same string, ignoring case but distinguishing accents. Choose another, or archive the old code first. - StatusHTTP 409What to do
reason: archivedwhen the promotion or code is archived.reason: field_lockedwhen an update changesdiscount_classor the effect type after a use has counted; create a new promotion instead. - StatusHTTP 409CodeRESOURCE_
IN_ USE What to doAn update changesapplication_method.recurrence.typewhile active subscription offers use the promotion; those offers requireforeverrecurrence. Remove the promotion from them or make them inactive first. - StatusHTTP 409What to do
expected_versiondoesn't match. Read the resource again and reapply your change.
Webhooks#
- promotion.
created A promotion was created. Each code created with it sendspromotion_code.created. - promotion.
updated You changed the promotion, including itsstatus, or a code change moved itscodes_summary. - promotion.
archived The promotion and its codes were archived. Each code it archived sendspromotion_code.archivedshortly after. - promotion_
code. created A code was created, with its promotion or on its own. - promotion_
code. updated You changed the code, including itsstatus. - promotion_
code. archived The code was archived, on its own or with its promotion.
Redemptions and schedule or expiry boundaries change uses_count, available, unavailable_reason, and codes_summary.active_count without an event. Read the promotion when you need them current. The catalog events cover payloads and ordering.
Related guides#
PromotionsCreate codes and automatic offers, apply and preview them on orders, and handle declines.Checkout sessionsHosted checkout, where buyers enter codes themselves.Subscription discountsHow a promotion's recurrence discounts renewals.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.
The Promotion object#
Promotion evaluation order: manual discounts stay, do not count toward the cap, and are ignored by combines_with. Frozen subscription-term promotions are admitted first and are exempt from exclusivity, combines_with, and the cap. Candidates include codes being applied, existing promotion discounts, and qualifying automatic promotions. Each exclusivity group keeps its highest-priority member, then the larger standalone discount, earlier created_at, and lower promotion_id. Remaining candidates rank by standalone discount, then earlier created_at and lower promotion_id; each is admitted unless max_promotions_per_order is reached or both promotions do not allow each other's discount class. Admitted promotions price line item first, then order, then service charge. A zero-value promotion is dropped and selection runs again.
Returned by GET /v1/promotions/{promotion_id} and carried by the endpoints below.
Attributes
application_methodone ofRequiredDiscount effect and how it applies to eligible items or charges.
One of these shapes
The `percent_off` variant of `PromotionApplicationMethod`.
allocationenumHow the effect is applied across the matched items or charges. each applies the effect to every matched item independently: a fixed amount_off is charged per item (10 USD off 3 items discounts 30 USD, each capped at the item price), and a percent_off is taken from each item. across applies the effect once to the matched set as a whole: a fixed amount_off is the whole amount one time (10 USD off the group total, not prorated per item), and a percent_off is taken from the combined subtotal. For percent_off the two produce the same total and differ only in how the discount is attributed to individual line items; for amount_off they differ by the number of matched items, so set it deliberately. Defaults to each for line_item and service_charge promotions and across for order promotions. max_discounted_quantity requires each.
eachacross
calculation_basisenumWhat a merchandise discount is calculated from. Omitted means `subtotal_pre_tax`. Not used by service_charge promotions; sending it there returns `400 INVALID_REQUEST`.
subtotal_pre_taxsubtotal_post_tax
discounted_item_rulesone ofWhich line items receive the discount. Required for service_charge promotions, and for line_item promotions whose eligibility_rules include any non-line-item condition (for example order.subtotal or a customer condition). It is optional only when eligibility_rules consist entirely of line_item.* conditions (plus matched_items.subtotal), in which case the matched items are used as the target. Omitting it otherwise returns `400 INVALID_REQUEST` with `param` naming this field.
max_discounted_quantityintegerMaximum number of matched units that receive the discount. Only valid when type is percent_off, and requires allocation each. Sending it with amount_off or buy_x_get_y returns `400 INVALID_REQUEST` naming this field. Whole-number quantity; fractional quantities are not supported. Flint discounts the first matched units in line-item order (the order items were added), not the cheapest.
percent_offnumberRequiredPercentage to discount, from 1 to 100.
recurrenceone ofOptional recurrence for subscription payments: once applies to the first charged payment, repeating applies for period_count charged payments, and forever applies to every payment. One-time orders apply the promotion once.
typeenumRequiredSelects the percent_off discount effect and its allowed fields.
percent_off
availablebooleanRequiredWhether the promotion can apply right now: it is active, inside its schedule, under its max_uses, and, when code-gated, has at least one redeemable code.
codesarray of objectThe codes this request created, in request order. Present only on the `POST /v1/promotions` response, where it is `[]` for a promotion created without codes. Read codes later with `GET /v1/promotion-codes?promotion_id=`.
availablebooleanRequiredWhether a buyer can redeem the code right now: the code is active, not expired, and under its max_uses, and its promotion is available.
codestringRequiredCode a buyer enters to redeem the promotion.
created_atstringRequiredWhen the promotion code was created, as an RFC3339 timestamp.
customer_idstring or nullRequiredOnly this identified customer can redeem the code. The customer must belong to the same merchant and environment. A checkout may use its merchant-named or email-verified customer; a typed email does not identify a customer. Null when the code is unbound.
expires_atstringWhen the code stops being redeemable, as an absolute RFC3339 timestamp. Omitted when the code does not expire.
max_usesintegerMaximum number of times this code can be redeemed. Omitted when the code has no redemption limit.
merchant_idstringRequiredIdentifier of the merchant that owns the promotion code.
metadatamap of stringKey-value data you attach to the promotion code.
promotionobjectThe promotion this code belongs to. Present only when the list request asked for expand=promotion.
promotion_code_idstringRequiredUnique identifier for the promotion code.
promotion_idstringRequiredIdentifier of the promotion this code redeems.
statusenumRequiredLifecycle status: active, inactive, or archived. Set active or inactive with PATCH; DELETE sets archived. An active code can still be unavailable: read available.
activeinactivearchived
timezonestringIANA zone the code's times were entered in, used for display. expires_at is an absolute timestamp, so this does not change when the code expires.
unavailable_reasonenumWhy available is false. Present only when available is false. The code's own state is reported first; promotion_unavailable means the code is usable but its promotion is not.
archivedinactiveexpiredexhaustedpromotion_unavailable
updated_atstringRequiredWhen the promotion code was last updated, as an RFC3339 timestamp.
uses_countintegerRequiredNumber of times this code has been redeemed.
versionintegerRequiredPersisted owned-state version. Clock-based availability and expanded resources do not advance this counter.
codes_summaryobjectRead-only rollup of this promotion's codes. Present only on code-gated promotions; automatic promotions omit it.
active_countintegerRequiredNumber of codes a buyer can redeem now: active, not expired, and under their max_uses. When it is 0, a code-gated promotion is unavailable with unavailable_reason no_active_codes.
newest_active_codestringMost recently created redeemable code. Omitted when active_count is zero.
total_countintegerRequiredNumber of codes on the promotion, excluding archived codes.
combines_withobjectRequiredWhich promotion discount classes this promotion may share an order with. Both promotions must allow each other's class. Manual discounts are ignored. See Promotion for the evaluation order.
line_itembooleanRequiredAllow line item promotions, subject to the evaluation order on Promotion.
orderbooleanRequiredAllow order promotions, subject to the evaluation order on Promotion.
service_chargebooleanRequiredAllow service charge promotions, subject to the evaluation order on Promotion.
created_atstringWhen the promotion was created, as an RFC3339 timestamp.
descriptionstringOptional description of the promotion for your own records.
discount_classenumRequiredWhether the promotion discounts the order, individual line items, or service charges.
orderline_itemservice_charge
display_namestringRequiredBuyer-facing promotion name shown in checkout and order discount surfaces.
eligibility_rulesone ofConditions an order must satisfy for the promotion to apply. Omitted when the promotion has no eligibility conditions.
One of these shapes
allarray of one ofRequiredRules and nested groups that must all match.
exclusivityobjectOptional group and priority used to choose one promotion from competing promotions in the same group. See Promotion for the evaluation order.
groupstringRequiredExact, case-sensitive group name, 1 to 100 characters after trimming.
priorityintegerRequiredHigher priority wins. Equal priorities favor the larger standalone discount, then the earlier created_at, then the lower promotion_id.
external_reference_idstringCaller-owned identifier for this resource in an external system.
max_usesintegerMaximum number of redemptions across all codes and automatic applications. Omitted when there is no redemption limit.
max_uses_per_customerinteger or nullRequiredMaximum reserved and redeemed uses per identified customer across every code and automatic or ID-based application. Checked atomically when payment starts. Failed, canceled, or expired attempts release their reservation; refunds do not restore uses. Counts only within the same merchant and environment; live and test mode are separate. Without an identified customer, returns 409 PROMOTION_DECLINED with reason customer_required. Null when there is no per-customer limit.
merchant_idstringIdentifier of the merchant that owns the promotion.
metadatamap of stringKey-value data you attach to the promotion.
namestringRequiredInternal promotion name for dashboards, searching, and reporting.
promotion_idstringRequiredUnique identifier for the promotion.
redemption_typeenumRequiredWhether the promotion applies automatically when its rules match or requires a promotion code.
automaticcode
scheduleobjectOptional start and end times that limit when the promotion can apply.
ends_atstringTime after which the promotion can no longer apply, as an absolute RFC3339 timestamp. Omitted when it has no end time.
starts_atstringEarliest time the promotion can apply, as an absolute RFC3339 timestamp. Omitted when it has no start time.
timezonestringIANA zone the schedule was entered in, used for display. starts_at and ends_at are absolute timestamps, so this does not change when the promotion starts or ends.
statusenumRequiredLifecycle status. Set active or inactive with PATCH; DELETE sets archived. An active promotion can still be unavailable: read available.
activeinactivearchived
unavailable_reasonenumWhy available is false. Present only when available is false.
inactivearchivednot_yet_startedexpiredexhaustedno_active_codes
updated_atstringWhen the promotion was last updated, as an RFC3339 timestamp.
uses_countintegerRequiredNumber of times the promotion has been redeemed.
versionintegerRequiredPersisted owned-state version. Clock-based availability and expanded resources do not advance this counter.
{
"application_method": {
"allocation": "across",
"calculation_basis": "subtotal_pre_tax",
"discounted_item_rules": {
"all": [
{
"attribute": "line_item.categories",
"operator": "eq",
"values": [
"tickets"
]
}
]
},
"percent_off": 20,
"type": "percent_off"
},
"available": true,
"codes_summary": {
"active_count": 2,
"newest_active_code": "SPRING20",
"total_count": 3
},
"combines_with": {
"line_item": false,
"order": true,
"service_charge": true
},
"created_at": "2026-03-17T14:30:00Z",
"discount_class": "line_item",
"display_name": "20% off spring tickets",
"max_uses": 500,
"max_uses_per_customer": null,
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"metadata": {
"campaign": "spring_launch"
},
"name": "Spring ticket launch Q2",
"promotion_id": "promo_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"redemption_type": "code",
"schedule": {
"ends_at": "2026-04-01T00:00:00Z"
},
"status": "active",
"updated_at": "2026-03-17T14:30:00Z",
"uses_count": 24,
"version": 1
}The Promotion code object#
A code a buyer enters to claim a promotion.
Returned by GET /v1/promotion-codes/{promotion_code_id} and carried by the endpoints below.
Attributes
availablebooleanRequiredWhether a buyer can redeem the code right now: the code is active, not expired, and under its max_uses, and its promotion is available.
codestringRequiredCode a buyer enters to redeem the promotion.
created_atstringRequiredWhen the promotion code was created, as an RFC3339 timestamp.
customer_idstring or nullRequiredOnly this identified customer can redeem the code. The customer must belong to the same merchant and environment. A checkout may use its merchant-named or email-verified customer; a typed email does not identify a customer. Null when the code is unbound.
expires_atstringWhen the code stops being redeemable, as an absolute RFC3339 timestamp. Omitted when the code does not expire.
max_usesintegerMaximum number of times this code can be redeemed. Omitted when the code has no redemption limit.
merchant_idstringRequiredIdentifier of the merchant that owns the promotion code.
metadatamap of stringKey-value data you attach to the promotion code.
promotionobjectThe promotion this code belongs to. Present only when the list request asked for expand=promotion.
application_methodone ofRequiredDiscount effect and how it applies to eligible items or charges.
availablebooleanRequiredWhether the promotion can apply right now: it is active, inside its schedule, under its max_uses, and, when code-gated, has at least one redeemable code.
codesarray of objectThe codes this request created, in request order. Present only on the `POST /v1/promotions` response, where it is `[]` for a promotion created without codes. Read codes later with `GET /v1/promotion-codes?promotion_id=`.
codes_summaryobjectRead-only rollup of this promotion's codes. Present only on code-gated promotions; automatic promotions omit it.
combines_withobjectRequiredWhich promotion discount classes this promotion may share an order with. Both promotions must allow each other's class. Manual discounts are ignored. See Promotion for the evaluation order.
created_atstringWhen the promotion was created, as an RFC3339 timestamp.
descriptionstringOptional description of the promotion for your own records.
discount_classenumRequiredWhether the promotion discounts the order, individual line items, or service charges.
orderline_itemservice_charge
display_namestringRequiredBuyer-facing promotion name shown in checkout and order discount surfaces.
eligibility_rulesone ofConditions an order must satisfy for the promotion to apply. Omitted when the promotion has no eligibility conditions.
exclusivityobjectOptional group and priority used to choose one promotion from competing promotions in the same group. See Promotion for the evaluation order.
external_reference_idstringCaller-owned identifier for this resource in an external system.
max_usesintegerMaximum number of redemptions across all codes and automatic applications. Omitted when there is no redemption limit.
max_uses_per_customerinteger or nullRequiredMaximum reserved and redeemed uses per identified customer across every code and automatic or ID-based application. Checked atomically when payment starts. Failed, canceled, or expired attempts release their reservation; refunds do not restore uses. Counts only within the same merchant and environment; live and test mode are separate. Without an identified customer, returns 409 PROMOTION_DECLINED with reason customer_required. Null when there is no per-customer limit.
merchant_idstringIdentifier of the merchant that owns the promotion.
metadatamap of stringKey-value data you attach to the promotion.
namestringRequiredInternal promotion name for dashboards, searching, and reporting.
promotion_idstringRequiredUnique identifier for the promotion.
redemption_typeenumRequiredWhether the promotion applies automatically when its rules match or requires a promotion code.
automaticcode
scheduleobjectOptional start and end times that limit when the promotion can apply.
statusenumRequiredLifecycle status. Set active or inactive with PATCH; DELETE sets archived. An active promotion can still be unavailable: read available.
activeinactivearchived
unavailable_reasonenumWhy available is false. Present only when available is false.
inactivearchivednot_yet_startedexpiredexhaustedno_active_codes
updated_atstringWhen the promotion was last updated, as an RFC3339 timestamp.
uses_countintegerRequiredNumber of times the promotion has been redeemed.
versionintegerRequiredPersisted owned-state version. Clock-based availability and expanded resources do not advance this counter.
promotion_code_idstringRequiredUnique identifier for the promotion code.
promotion_idstringRequiredIdentifier of the promotion this code redeems.
statusenumRequiredLifecycle status: active, inactive, or archived. Set active or inactive with PATCH; DELETE sets archived. An active code can still be unavailable: read available.
activeinactivearchived
timezonestringIANA zone the code's times were entered in, used for display. expires_at is an absolute timestamp, so this does not change when the code expires.
unavailable_reasonenumWhy available is false. Present only when available is false. The code's own state is reported first; promotion_unavailable means the code is usable but its promotion is not.
archivedinactiveexpiredexhaustedpromotion_unavailable
updated_atstringRequiredWhen the promotion code was last updated, as an RFC3339 timestamp.
uses_countintegerRequiredNumber of times this code has been redeemed.
versionintegerRequiredPersisted owned-state version. Clock-based availability and expanded resources do not advance this counter.
{
"available": true,
"code": "SPRING20",
"created_at": "2026-03-17T14:30:00Z",
"customer_id": null,
"expires_at": "2026-04-01T00:00:00Z",
"max_uses": 500,
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"metadata": {
"campaign": "spring_launch"
},
"promotion_code_id": "pcode_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"promotion_id": "promo_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"status": "active",
"updated_at": "2026-03-17T14:30:00Z",
"uses_count": 24,
"version": 1
}List promotion codes#
/v1/promotion-codesRequires scope commerce.promotions.read or commerce.promotions.write
Rate limit: read
Returns a paginated list of promotion codes in every status, ordered by created_at descending, then promotion_code_id descending. Archived codes are excluded unless status=archived. Default order: created_at descending, then promotion_code_id descending.
Query parameters
promotion_idstringExact match on the parent promotion ID.
customer_idstringExact match on the customer bound to the code. Unbound codes are excluded.
codestringExact match that ignores case but distinguishes accents: CAFÉ matches café, but not CAFE. This is the same rule that makes promotion codes unique. Codes preserve their original spelling. Leading and trailing whitespace are rejected, not trimmed.
statusarray of enumFilter by status. Omitted, the list leaves out archived rows; name archived to include them. Values are trimmed and deduplicated in first-seen order; empty or unknown entries are rejected. Values within this filter are ORed; separate filters are ANDed.
activeinactivearchived
availabilityarray of enumFilter by whether a code can be redeemed now or why it cannot. available matches available: true; every other value matches unavailable_reason. Values are ORed and ANDed with status. Values are trimmed and deduplicated in first-seen order; empty or unknown entries are rejected. Values within this filter are ORed; separate filters are ANDed.
availableinactiveexpiredexhaustedpromotion_unavailable
page_sizeintegerMaximum number of results to return, from 1 to 100. Defaults to 20.
page_tokenstringOpaque, signed next_page_token from the previous response, bound to the list and caller. Omit on the first request. You may change `page_size` between pages. Reuse it with the same endpoint, filters, sort, and request context. Do not parse or construct tokens. An altered, invalid, expired, or mismatched token returns a validation error.
sort_byenumField to sort by. Defaults to created_at; ties are broken by promotion_code_id.
created_atupdated_at
sort_directionenumSort direction. Defaults to desc.
ascdesc
created_afterstringInclusive lower bound on created_at.
created_beforestringExclusive upper bound on created_at.
updated_afterstringInclusive lower bound on updated_at.
updated_beforestringExclusive upper bound on updated_at.
expandarray of enumInclude related objects in the response. Supported expansions: promotion. Expand each code's parent promotion. Expansion requires commerce.promotions.read. Limits: at most 10 unique expand paths per request.
promotion
Response · 200
A page of promotion codes.
dataarray of objectRequiredPromotion codes returned in the requested sort order.
availablebooleanRequiredWhether a buyer can redeem the code right now: the code is active, not expired, and under its max_uses, and its promotion is available.
codestringRequiredCode a buyer enters to redeem the promotion.
created_atstringRequiredWhen the promotion code was created, as an RFC3339 timestamp.
customer_idstring or nullRequiredOnly this identified customer can redeem the code. The customer must belong to the same merchant and environment. A checkout may use its merchant-named or email-verified customer; a typed email does not identify a customer. Null when the code is unbound.
expires_atstringWhen the code stops being redeemable, as an absolute RFC3339 timestamp. Omitted when the code does not expire.
max_usesintegerMaximum number of times this code can be redeemed. Omitted when the code has no redemption limit.
merchant_idstringRequiredIdentifier of the merchant that owns the promotion code.
metadatamap of stringKey-value data you attach to the promotion code.
promotionobjectThe promotion this code belongs to. Present only when the list request asked for expand=promotion.
promotion_code_idstringRequiredUnique identifier for the promotion code.
promotion_idstringRequiredIdentifier of the promotion this code redeems.
statusenumRequiredLifecycle status: active, inactive, or archived. Set active or inactive with PATCH; DELETE sets archived. An active code can still be unavailable: read available.
activeinactivearchived
timezonestringIANA zone the code's times were entered in, used for display. expires_at is an absolute timestamp, so this does not change when the code expires.
unavailable_reasonenumWhy available is false. Present only when available is false. The code's own state is reported first; promotion_unavailable means the code is usable but its promotion is not.
archivedinactiveexpiredexhaustedpromotion_unavailable
updated_atstringRequiredWhen the promotion code was last updated, as an RFC3339 timestamp.
uses_countintegerRequiredNumber of times this code has been redeemed.
versionintegerRequiredPersisted owned-state version. Clock-based availability and expanded resources do not advance this counter.
metaobjectAdditional information about this response.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
next_page_tokenstringToken for the next page. Omitted when there are no more results.
request_idstringRequiredIdentifier of this API request, useful when contacting support.
curl https://api.withflintpay.com/v1/promotion-codes \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"A page of promotion codes.
{
"data": [
{
"available": true,
"code": "SPRING20",
"created_at": "2026-03-17T14:30:00Z",
"customer_id": null,
"expires_at": "2026-04-01T00:00:00Z",
"max_uses": 500,
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"metadata": {
"campaign": "spring_launch"
},
"promotion_code_id": "pcode_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"promotion_id": "promo_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"status": "active",
"updated_at": "2026-03-17T14:30:00Z",
"uses_count": 24,
"version": 1
}
],
"meta": {
"api_version": "2026-09-07"
},
"next_page_token": "example",
"request_id": "req_01KWM6CVCQK5KV7AZ162AJW2PW"
}Create promotion code#
/v1/promotion-codesIdempotentRequires scope commerce.promotions.write
Rate limit: write
Creates a code for a promotion whose `redemption_type` is code; adding a code to an automatic promotion fails with `INVALID_REQUEST`. A code that another resource already uses fails with `ALREADY_EXISTS`. Fails with `ACTION_NOT_ALLOWED` and reason `archived` when the resource, or the parent it belongs to, is archived. The error names the archived resource and its `current_status`.
Request body
codestringRequiredCode a buyer enters to redeem the promotion.
customer_idstring or nullOnly this identified customer can redeem the code. The customer must belong to the same merchant and environment. A checkout may use its merchant-named or email-verified customer; a typed email does not identify a customer. Omit or send null to create an unbound code.
expires_atstringWhen the code stops being redeemable, as an absolute RFC3339 timestamp. Omit for no expiry.
max_usesintegerMaximum number of times this code can be redeemed. Omit for no redemption limit.
metadatamap of stringKey-value data you attach to the promotion code.
promotion_idstringRequiredFlint promotion ID that owns this code.
statusenumLifecycle status. Defaults to active; send inactive to create a code that cannot be redeemed.
activeinactive
timezonestringIANA zone the code's times were entered in, used for display. expires_at is an absolute timestamp, so this does not change when the code expires.
Response · 201
The created promotion code.
dataobjectRequiredThe requested promotion code.
availablebooleanRequiredWhether a buyer can redeem the code right now: the code is active, not expired, and under its max_uses, and its promotion is available.
codestringRequiredCode a buyer enters to redeem the promotion.
created_atstringRequiredWhen the promotion code was created, as an RFC3339 timestamp.
customer_idstring or nullRequiredOnly this identified customer can redeem the code. The customer must belong to the same merchant and environment. A checkout may use its merchant-named or email-verified customer; a typed email does not identify a customer. Null when the code is unbound.
expires_atstringWhen the code stops being redeemable, as an absolute RFC3339 timestamp. Omitted when the code does not expire.
max_usesintegerMaximum number of times this code can be redeemed. Omitted when the code has no redemption limit.
merchant_idstringRequiredIdentifier of the merchant that owns the promotion code.
metadatamap of stringKey-value data you attach to the promotion code.
promotionobjectThe promotion this code belongs to. Present only when the list request asked for expand=promotion.
promotion_code_idstringRequiredUnique identifier for the promotion code.
promotion_idstringRequiredIdentifier of the promotion this code redeems.
statusenumRequiredLifecycle status: active, inactive, or archived. Set active or inactive with PATCH; DELETE sets archived. An active code can still be unavailable: read available.
activeinactivearchived
timezonestringIANA zone the code's times were entered in, used for display. expires_at is an absolute timestamp, so this does not change when the code expires.
unavailable_reasonenumWhy available is false. Present only when available is false. The code's own state is reported first; promotion_unavailable means the code is usable but its promotion is not.
archivedinactiveexpiredexhaustedpromotion_unavailable
updated_atstringRequiredWhen the promotion code was last updated, as an RFC3339 timestamp.
uses_countintegerRequiredNumber of times this code has been redeemed.
versionintegerRequiredPersisted owned-state version. Clock-based availability and expanded resources do not advance this counter.
metaobjectAdditional information about this response.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
request_idstringRequiredIdentifier of this API request, useful when contacting support.
curl -X POST https://api.withflintpay.com/v1/promotion-codes \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: a-unique-key" \
-d '{
"code": "VIP20",
"expires_at": "2026-04-01T00:00:00Z",
"max_uses": 100,
"metadata": {
"audience": "vip"
},
"promotion_id": "promo_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J"
}'Get promotion code#
/v1/promotion-codes/{promotion_code_id}Requires scope commerce.promotions.read or commerce.promotions.write
Rate limit: read
Returns a single promotion code by code ID. Archived codes remain readable, including codes of an archived promotion. Fails with `RESOURCE_NOT_FOUND` when the code does not exist or belongs to another merchant or environment.
Path parameters
promotion_code_idstringRequiredFlint promotion code ID. Must be a valid ID with prefix pcode_. Malformed IDs return 400 INVALID_REQUEST with detail INVALID_VALUE; well-formed IDs that do not exist return 404 RESOURCE_NOT_FOUND.
curl https://api.withflintpay.com/v1/promotion-codes/pcode_01KEZF7C00JCC7QXWC262EF05T \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"The requested promotion code.
{
"data": {
"available": true,
"code": "SPRING20",
"created_at": "2026-03-17T14:30:00Z",
"customer_id": null,
"expires_at": "2026-04-01T00:00:00Z",
"max_uses": 500,
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"metadata": {
"campaign": "spring_launch"
},
"promotion_code_id": "pcode_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"promotion_id": "promo_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"status": "active",
"updated_at": "2026-03-17T14:30:00Z",
"uses_count": 24,
"version": 1
},
"meta": {
"api_version": "2026-09-07"
},
"request_id": "req_01KWM6V8R871Z8M5H2JDE1QR9J"
}Update promotion code#
/v1/promotion-codes/{promotion_code_id}IdempotentRequires scope commerce.promotions.write
Rate limit: write
Applies a sparse update to a promotion code. Fails with `ACTION_NOT_ALLOWED` and reason `archived` when the resource, or the parent it belongs to, is archived. The error names the archived resource and its `current_status`.
Path parameters
promotion_code_idstringRequiredFlint promotion code ID. Must be a valid ID with prefix pcode_. Malformed IDs return 400 INVALID_REQUEST with detail INVALID_VALUE; well-formed IDs that do not exist return 404 RESOURCE_NOT_FOUND.
Request body
customer_idstring or nullOnly this identified customer can redeem the code. The customer must belong to the same merchant and environment. A checkout may use its merchant-named or email-verified customer; a typed email does not identify a customer. Omit to preserve the binding; send a customer ID to bind or rebind the code, or null to remove the binding.
expected_versionintegerPromotion code version last read by the caller. Optional for updates.
expires_atstring or nullAbsolute RFC3339 expiry timestamp. Omission keeps the stored value; null clears it.
max_usesinteger or nullMaximum number of times this code can be redeemed. Send null to remove the redemption limit.
metadatamap of string or nullCaller-owned metadata. Omit this field to leave metadata unchanged. Send an object to merge by key, set a key to null to remove it, or set metadata to null to clear all caller-owned metadata. An empty object makes no change. Values can't be empty strings. Keys starting with flint_ are reserved for Flint, are not returned, and cannot be written through the public API.
statusenumLifecycle status: active or inactive.
activeinactive
timezonestring or nullIANA zone the code's times were entered in, used for display. expires_at is an absolute timestamp, so this does not change when the code expires. Send null to clear it.
curl -X PATCH https://api.withflintpay.com/v1/promotion-codes/pcode_01KEZF7C00JCC7QXWC262EF05T \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: a-unique-key" \
-d '{
"expected_version": 1,
"max_uses": 50,
"status": "inactive"
}'Archive promotion code#
/v1/promotion-codes/{promotion_code_id}IdempotentRequires scope commerce.promotions.write
Rate limit: write
Archives a promotion code. The code remains readable with status archived. Returns the archived resource as a read does. Deleting an already archived resource returns it again without changing its version or `updated_at`, sending a webhook, or checking references.
Path parameters
promotion_code_idstringRequiredFlint promotion code ID. Must be a valid ID with prefix pcode_. Malformed IDs return 400 INVALID_REQUEST with detail INVALID_VALUE; well-formed IDs that do not exist return 404 RESOURCE_NOT_FOUND.
Query parameters
expected_versionintegerOptional resource version last read by the caller.
curl -X DELETE https://api.withflintpay.com/v1/promotion-codes/pcode_01KEZF7C00JCC7QXWC262EF05T \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"List promotions#
/v1/promotionsRequires scope commerce.promotions.read or commerce.promotions.write
Rate limit: read
Returns a paginated list of promotions for the authenticated merchant. Default order: created_at descending, then promotion_id descending.
Query parameters
page_sizeintegerMaximum number of results to return, from 1 to 100. Defaults to 20.
page_tokenstringOpaque, signed next_page_token from the previous response, bound to the list and caller. Omit on the first request. You may change `page_size` between pages. Reuse it with the same endpoint, filters, sort, and request context. Do not parse or construct tokens. An altered, invalid, expired, or mismatched token returns a validation error.
statusarray of enumFilter by status. Omitted, the list leaves out archived rows; name archived to include them. Values are trimmed and deduplicated in first-seen order; empty or unknown entries are rejected. Values within this filter are ORed; separate filters are ANDed.
activeinactivearchived
availabilityarray of enumFilter by whether a promotion can apply now or why it cannot. available matches available: true; every other value matches unavailable_reason. This filter is ANDed with status. Archived promotions still require status=archived. Values are trimmed and deduplicated in first-seen order; empty or unknown entries are rejected. Values within this filter are ORed; separate filters are ANDed.
availableinactivearchivednot_yet_startedexpiredexhaustedno_active_codes
external_reference_idstringExact-match filter on the caller-owned external reference ID.
querystringSearch across promotion ID, external reference ID, name, display name, description, and promotion codes. Text fields match any part of the value, and %, _ and \ are ordinary characters, not wildcards. IDs match from the start and need the type prefix, such as promo_01.
product_idstringFilter to promotions with an explicit product target rule. Universal promotions are not included by catalog target filters.
variant_idstringFilter to promotions with an explicit variant target rule. Universal promotions are not included by catalog target filters.
bundle_idstringFilter to promotions with an explicit bundle target rule. Universal promotions are not included by catalog target filters.
category_handlestringFilter to promotions with an explicit category target rule. Universal promotions are not included by catalog target filters.
redemption_typearray of enumFilter by promotion redemption type. Values are trimmed and deduplicated in first-seen order; empty or unknown entries are rejected. Values within this filter are ORed; separate filters are ANDed.
automaticcode
discount_classarray of enumFilter by promotion discount class. Values are trimmed and deduplicated in first-seen order; empty or unknown entries are rejected. Values within this filter are ORed; separate filters are ANDed.
orderline_itemservice_charge
sort_byenumField to sort by. Defaults to created_at; ties are broken by promotion_id.
namecreated_atupdated_at
sort_directionenumSort direction. Defaults to desc.
ascdesc
created_afterstringInclusive lower bound on created_at.
created_beforestringExclusive upper bound on created_at.
updated_afterstringInclusive lower bound on updated_at.
updated_beforestringExclusive upper bound on updated_at.
Response · 200
A page of promotions.
dataarray of objectRequiredPromotions returned in the requested sort order.
application_methodone ofRequiredDiscount effect and how it applies to eligible items or charges.
availablebooleanRequiredWhether the promotion can apply right now: it is active, inside its schedule, under its max_uses, and, when code-gated, has at least one redeemable code.
codesarray of objectThe codes this request created, in request order. Present only on the `POST /v1/promotions` response, where it is `[]` for a promotion created without codes. Read codes later with `GET /v1/promotion-codes?promotion_id=`.
codes_summaryobjectRead-only rollup of this promotion's codes. Present only on code-gated promotions; automatic promotions omit it.
combines_withobjectRequiredWhich promotion discount classes this promotion may share an order with. Both promotions must allow each other's class. Manual discounts are ignored. See Promotion for the evaluation order.
created_atstringWhen the promotion was created, as an RFC3339 timestamp.
descriptionstringOptional description of the promotion for your own records.
discount_classenumRequiredWhether the promotion discounts the order, individual line items, or service charges.
orderline_itemservice_charge
display_namestringRequiredBuyer-facing promotion name shown in checkout and order discount surfaces.
eligibility_rulesone ofConditions an order must satisfy for the promotion to apply. Omitted when the promotion has no eligibility conditions.
exclusivityobjectOptional group and priority used to choose one promotion from competing promotions in the same group. See Promotion for the evaluation order.
external_reference_idstringCaller-owned identifier for this resource in an external system.
max_usesintegerMaximum number of redemptions across all codes and automatic applications. Omitted when there is no redemption limit.
max_uses_per_customerinteger or nullRequiredMaximum reserved and redeemed uses per identified customer across every code and automatic or ID-based application. Checked atomically when payment starts. Failed, canceled, or expired attempts release their reservation; refunds do not restore uses. Counts only within the same merchant and environment; live and test mode are separate. Without an identified customer, returns 409 PROMOTION_DECLINED with reason customer_required. Null when there is no per-customer limit.
merchant_idstringIdentifier of the merchant that owns the promotion.
metadatamap of stringKey-value data you attach to the promotion.
namestringRequiredInternal promotion name for dashboards, searching, and reporting.
promotion_idstringRequiredUnique identifier for the promotion.
redemption_typeenumRequiredWhether the promotion applies automatically when its rules match or requires a promotion code.
automaticcode
scheduleobjectOptional start and end times that limit when the promotion can apply.
statusenumRequiredLifecycle status. Set active or inactive with PATCH; DELETE sets archived. An active promotion can still be unavailable: read available.
activeinactivearchived
unavailable_reasonenumWhy available is false. Present only when available is false.
inactivearchivednot_yet_startedexpiredexhaustedno_active_codes
updated_atstringWhen the promotion was last updated, as an RFC3339 timestamp.
uses_countintegerRequiredNumber of times the promotion has been redeemed.
versionintegerRequiredPersisted owned-state version. Clock-based availability and expanded resources do not advance this counter.
metaobjectAdditional information about this response.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
next_page_tokenstringToken for the next page. Omitted when there are no more results.
request_idstringRequiredIdentifier of this API request, useful when contacting support.
curl https://api.withflintpay.com/v1/promotions \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"A page of promotions.
{
"data": [
{
"application_method": {
"allocation": "across",
"calculation_basis": "subtotal_pre_tax",
"discounted_item_rules": {
"all": [
{
"attribute": "line_item.categories",
"operator": "eq",
"values": [
"tickets"
]
}
]
},
"percent_off": 20,
"type": "percent_off"
},
"available": true,
"codes_summary": {
"active_count": 2,
"newest_active_code": "SPRING20",
"total_count": 3
},
"combines_with": {
"line_item": false,
"order": true,
"service_charge": true
},
"created_at": "2026-03-17T14:30:00Z",
"discount_class": "line_item",
"display_name": "20% off spring tickets",
"max_uses": 500,
"max_uses_per_customer": null,
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"metadata": {
"campaign": "spring_launch"
},
"name": "Spring ticket launch Q2",
"promotion_id": "promo_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"redemption_type": "code",
"schedule": {
"ends_at": "2026-04-01T00:00:00Z"
},
"status": "active",
"updated_at": "2026-03-17T14:30:00Z",
"uses_count": 24,
"version": 1
}
],
"meta": {
"api_version": "2026-09-07"
},
"next_page_token": "example",
"request_id": "req_01KWM6526KCS4S4PDT7VJWP7XJ"
}Create promotion#
/v1/promotionsIdempotentRequires scope commerce.promotions.write
Rate limit: write
Creates a promotion: a discount that applies to qualifying orders automatically or when the buyer enters a promotion code. Send `name` and `application_method`; `redemption_type` chooses between automatic and code-gated, and a code-gated promotion can create up to 100 `codes` with it. Eligibility rules, a schedule, a redemption limit, and exclusivity are optional. The promotion is active unless you send `status: inactive`. A code that another resource already uses fails with `ALREADY_EXISTS`.
Request body
application_methodone ofRequiredDiscount effect and how it applies to eligible items or charges.
Send exactly one of these
The `percent_off` variant of `PromotionApplicationMethodInput`.
allocationenumHow the effect is applied across the matched items or charges. each applies the effect to every matched item independently: a fixed amount_off is charged per item (10 USD off 3 items discounts 30 USD, each capped at the item price), and a percent_off is taken from each item. across applies the effect once to the matched set as a whole: a fixed amount_off is the whole amount one time (10 USD off the group total, not prorated per item), and a percent_off is taken from the combined subtotal. For percent_off the two produce the same total and differ only in how the discount is attributed to individual line items; for amount_off they differ by the number of matched items, so set it deliberately. Defaults to each for line_item and service_charge promotions and across for order promotions. max_discounted_quantity requires each.
eachacross
calculation_basisenumWhat a merchandise discount is calculated from. Omitted means `subtotal_pre_tax`. Not used by service_charge promotions; sending it there returns `400 INVALID_REQUEST`.
subtotal_pre_taxsubtotal_post_tax
discounted_item_rulesone ofWhich line items receive the discount. Required for service_charge promotions, and for line_item promotions whose eligibility_rules include any non-line-item condition (for example order.subtotal or a customer condition). It is optional only when eligibility_rules consist entirely of line_item.* conditions (plus matched_items.subtotal), in which case the matched items are used as the target. Omitting it otherwise returns `400 INVALID_REQUEST` with `param` naming this field.
max_discounted_quantityintegerMaximum number of matched units that receive the discount. Only valid when type is percent_off, and requires allocation each. Sending it with amount_off or buy_x_get_y returns `400 INVALID_REQUEST` naming this field. Whole-number quantity; fractional quantities are not supported. Flint discounts the first matched units in line-item order (the order items were added), not the cheapest.
percent_offnumberRequiredPercentage to discount, from 1 to 100.
recurrenceone ofOptional recurrence for subscription payments: once applies to the first charged payment, repeating applies for period_count charged payments, and forever applies to every payment. One-time orders apply the promotion once.
typeenumRequiredSelects the percent_off discount effect and its allowed fields.
percent_off
codesarray of objectCodes to create with a code-gated promotion, at most 100. The create response returns them in `codes`. Add more later with `POST /v1/promotion-codes`, and manage each code through the `/v1/promotion-codes/{promotion_code_id}` routes.
codestringRequiredCode a buyer enters to redeem the promotion.
customer_idstring or nullOnly this identified customer can redeem the code. The customer must belong to the same merchant and environment. A checkout may use its merchant-named or email-verified customer; a typed email does not identify a customer. Omit or send null to create an unbound code.
expires_atstringWhen the code stops being redeemable, as an absolute RFC3339 timestamp. Omit for no expiry.
max_usesintegerMaximum number of times this code can be redeemed. Omit for no redemption limit.
metadatamap of stringKey-value data you attach to the promotion code.
statusenumLifecycle status. Defaults to active; send inactive to create a code that cannot be redeemed.
activeinactive
timezonestringIANA zone the code's times were entered in, used for display. expires_at is an absolute timestamp, so this does not change when the code expires.
combines_withobjectWhich discount classes this promotion can combine with. Omitted classes default to true.
line_itembooleanAllow line item promotions, subject to the evaluation order on Promotion.
orderbooleanAllow order promotions, subject to the evaluation order on Promotion.
service_chargebooleanAllow service charge promotions, subject to the evaluation order on Promotion.
descriptionstringOptional description of the promotion for your own records.
discount_classenumDefaults to order when omitted.
orderline_itemservice_charge
display_namestringBuyer-facing promotion name shown in checkout and order discount surfaces. Defaults to name when omitted.
eligibility_rulesone ofConditions an order must satisfy for the promotion to apply. Omit to create a promotion with no eligibility conditions.
Send exactly one of these
allarray of one ofRequiredRules and nested groups that must all match.
exclusivityobjectOptional group and priority used to choose one promotion from competing promotions in the same group. See Promotion for the evaluation order.
groupstringRequiredExact, case-sensitive group name, 1 to 100 characters after trimming.
priorityintegerHigher priority wins. Equal priorities favor the larger standalone discount, then the earlier created_at, then the lower promotion_id.
external_reference_idstringCaller-owned identifier for this resource in an external system.
max_usesintegerMaximum number of redemptions across all codes and automatic applications. Omit for no redemption limit.
max_uses_per_customerinteger or nullMaximum reserved and redeemed uses per identified customer across every code and automatic or ID-based application. Checked atomically when payment starts. Failed, canceled, or expired attempts release their reservation; refunds do not restore uses. Counts only within the same merchant and environment; live and test mode are separate. Without an identified customer, returns 409 PROMOTION_DECLINED with reason customer_required. Omit or send null for no per-customer limit.
metadatamap of stringCaller-owned metadata. Values can't be empty strings. Keys starting with flint_ are reserved for Flint, are not returned, and cannot be written through the public API.
namestringRequiredInternal promotion name for dashboards, searching, and reporting. This is not intended for buyer-facing checkout or receipt copy. Surrounding whitespace is trimmed before length validation. A supplied value cannot be blank; use null where clearing is supported.
redemption_typeenumWhether the promotion applies automatically when its rules match or requires a promotion code.
automaticcode
scheduleobjectOptional start and end times that limit when the promotion can apply.
ends_atstringTime after which the promotion can no longer apply, as an absolute RFC3339 timestamp. Omitted when it has no end time.
starts_atstringEarliest time the promotion can apply, as an absolute RFC3339 timestamp. Omitted when it has no start time.
timezonestringIANA zone the schedule was entered in, used for display. starts_at and ends_at are absolute timestamps, so this does not change when the promotion starts or ends.
statusenumLifecycle status. Defaults to active; send inactive to create a promotion that is switched off.
activeinactive
Response · 201
The created promotion.
dataobjectRequiredThe requested promotion.
application_methodone ofRequiredDiscount effect and how it applies to eligible items or charges.
availablebooleanRequiredWhether the promotion can apply right now: it is active, inside its schedule, under its max_uses, and, when code-gated, has at least one redeemable code.
codesarray of objectThe codes this request created, in request order. Present only on the `POST /v1/promotions` response, where it is `[]` for a promotion created without codes. Read codes later with `GET /v1/promotion-codes?promotion_id=`.
codes_summaryobjectRead-only rollup of this promotion's codes. Present only on code-gated promotions; automatic promotions omit it.
combines_withobjectRequiredWhich promotion discount classes this promotion may share an order with. Both promotions must allow each other's class. Manual discounts are ignored. See Promotion for the evaluation order.
created_atstringWhen the promotion was created, as an RFC3339 timestamp.
descriptionstringOptional description of the promotion for your own records.
discount_classenumRequiredWhether the promotion discounts the order, individual line items, or service charges.
orderline_itemservice_charge
display_namestringRequiredBuyer-facing promotion name shown in checkout and order discount surfaces.
eligibility_rulesone ofConditions an order must satisfy for the promotion to apply. Omitted when the promotion has no eligibility conditions.
exclusivityobjectOptional group and priority used to choose one promotion from competing promotions in the same group. See Promotion for the evaluation order.
external_reference_idstringCaller-owned identifier for this resource in an external system.
max_usesintegerMaximum number of redemptions across all codes and automatic applications. Omitted when there is no redemption limit.
max_uses_per_customerinteger or nullRequiredMaximum reserved and redeemed uses per identified customer across every code and automatic or ID-based application. Checked atomically when payment starts. Failed, canceled, or expired attempts release their reservation; refunds do not restore uses. Counts only within the same merchant and environment; live and test mode are separate. Without an identified customer, returns 409 PROMOTION_DECLINED with reason customer_required. Null when there is no per-customer limit.
merchant_idstringIdentifier of the merchant that owns the promotion.
metadatamap of stringKey-value data you attach to the promotion.
namestringRequiredInternal promotion name for dashboards, searching, and reporting.
promotion_idstringRequiredUnique identifier for the promotion.
redemption_typeenumRequiredWhether the promotion applies automatically when its rules match or requires a promotion code.
automaticcode
scheduleobjectOptional start and end times that limit when the promotion can apply.
statusenumRequiredLifecycle status. Set active or inactive with PATCH; DELETE sets archived. An active promotion can still be unavailable: read available.
activeinactivearchived
unavailable_reasonenumWhy available is false. Present only when available is false.
inactivearchivednot_yet_startedexpiredexhaustedno_active_codes
updated_atstringWhen the promotion was last updated, as an RFC3339 timestamp.
uses_countintegerRequiredNumber of times the promotion has been redeemed.
versionintegerRequiredPersisted owned-state version. Clock-based availability and expanded resources do not advance this counter.
metaobjectAdditional information about this response.
api_versionstringAPI version used to produce this response.
idempotency_replayedbooleanWhether this response replays a stored result for the supplied Idempotency-Key.
trace_idstringTrace identifier to include when contacting Flint about this request.
warningsarray of objectConditions that need attention even though the request succeeded.
request_idstringRequiredIdentifier of this API request, useful when contacting support.
curl -X POST https://api.withflintpay.com/v1/promotions \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: a-unique-key" \
-d '{
"application_method": {
"allocation": "across",
"calculation_basis": "subtotal_pre_tax",
"discounted_item_rules": {
"all": [
{
"attribute": "line_item.categories",
"operator": "eq",
"values": [
"tickets"
]
}
]
},
"percent_off": 20,
"type": "percent_off"
},
"codes": [
{
"code": "SPRING20",
"max_uses": 500
}
],
"combines_with": {
"line_item": false,
"order": true,
"service_charge": true
},
"discount_class": "line_item",
"display_name": "20% off spring tickets",
"max_uses": 500,
"metadata": {
"campaign": "spring_launch"
},
"name": "Spring ticket launch Q2",
"redemption_type": "code",
"schedule": {
"ends_at": "2026-04-01T00:00:00Z"
}
}'Get promotion#
/v1/promotions/{promotion_id}Requires scope commerce.promotions.read or commerce.promotions.write
Rate limit: read
Returns a single promotion by ID.
Path parameters
promotion_idstringRequiredFlint promotion ID. Must be a valid ID with prefix promo_. Malformed IDs return 400 INVALID_REQUEST with detail INVALID_VALUE; well-formed IDs that do not exist return 404 RESOURCE_NOT_FOUND.
curl https://api.withflintpay.com/v1/promotions/promo_01KEZF7C00QQ8EZ74BDYSZ315V \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"The requested promotion.
{
"data": {
"application_method": {
"allocation": "across",
"calculation_basis": "subtotal_pre_tax",
"discounted_item_rules": {
"all": [
{
"attribute": "line_item.categories",
"operator": "eq",
"values": [
"tickets"
]
}
]
},
"percent_off": 20,
"type": "percent_off"
},
"available": true,
"codes_summary": {
"active_count": 2,
"newest_active_code": "SPRING20",
"total_count": 3
},
"combines_with": {
"line_item": false,
"order": true,
"service_charge": true
},
"created_at": "2026-03-17T14:30:00Z",
"discount_class": "line_item",
"display_name": "20% off spring tickets",
"max_uses": 500,
"max_uses_per_customer": null,
"merchant_id": "mer_01KEZF7C00MPP0T9S0KH5BB4CC",
"metadata": {
"campaign": "spring_launch"
},
"name": "Spring ticket launch Q2",
"promotion_id": "promo_01HZYV7Q9Y0Y4H8Q3H9F6R7T8J",
"redemption_type": "code",
"schedule": {
"ends_at": "2026-04-01T00:00:00Z"
},
"status": "active",
"updated_at": "2026-03-17T14:30:00Z",
"uses_count": 24,
"version": 1
},
"meta": {
"api_version": "2026-09-07"
},
"request_id": "req_01KWM6NXV5SSY4HQKPVD2RRPAF"
}Update promotion#
/v1/promotions/{promotion_id}IdempotentRequires scope commerce.promotions.write
Rate limit: write
Applies a sparse update to promotion fields. application_method, schedule, exclusivity, and combines_with patch by subfield presence. Omitted fields retain stored values; null clears only nullable fields. Sending a different application_method.type replaces the effect while preserving omitted shared settings, including discounted_item_rules. A redeemed promotion can't change its `discount_class` or `application_method` type; the update fails with `ACTION_NOT_ALLOWED` and reason `field_locked`. Archived promotions cannot be changed. Fails with `ACTION_NOT_ALLOWED` and reason `archived` when the resource, or the parent it belongs to, is archived. The error names the archived resource and its `current_status`.
Path parameters
promotion_idstringRequiredFlint promotion ID. Must be a valid ID with prefix promo_. Malformed IDs return 400 INVALID_REQUEST with detail INVALID_VALUE; well-formed IDs that do not exist return 404 RESOURCE_NOT_FOUND.
Request body
application_methodobjectFields of the discount effect to change. Omitted fields keep their stored values.
allocationenumHow the effect is allocated. Omitted allocation keeps its stored value; it defaults by discount_class only when no allocation is stored. Changing discount_class does not reset allocation.
eachacross
amount_off_moneyobjectPositive fixed discount in the primary currency. allocation determines whether it applies to each matched item or once across the matched set.
buy_min_quantityintegerNumber of qualifying units needed for one application of a buy_x_get_y promotion. Whole-number quantity; fractional quantities are not supported.
calculation_basisenum or nullWhat a merchandise discount is calculated from. Omitted means `subtotal_pre_tax`. Not used by service_charge promotions; sending it there returns `400 INVALID_REQUEST`. Send null to clear it.
subtotal_pre_taxsubtotal_post_taxnull
currency_optionsmap of object or nullAlternative positive fixed discounts, keyed by currency code. Each Money currency must match its key.
discounted_item_rulesone of or nullWhich line items receive the discount. Required for service_charge promotions, and for line_item promotions whose eligibility_rules include any non-line-item condition (for example order.subtotal or a customer condition). It is optional only when eligibility_rules consist entirely of line_item.* conditions (plus matched_items.subtotal), in which case the matched items are used as the target. Omitting it otherwise returns `400 INVALID_REQUEST` with `param` naming this field.
get_percent_offnumberPercentage to discount from reward items, from 1 to 100. Use 100 to make the reward items free.
get_quantityintegerMaximum number of reward units discounted per application of a buy_x_get_y promotion. Whole-number quantity; fractional quantities are not supported.
max_applications_per_orderinteger or nullMaximum number of times the buy_x_get_y promotion can apply to one order. Omit for no limit beyond the qualifying and reward quantities.
max_discounted_quantityinteger or nullMaximum matched units discounted, valid only for percent_off with allocation each. null clears the limit. Fields belonging to another effect return INVALID_REQUEST; send type to change effects.
percent_offnumberPercentage to discount, from 1 to 100.
qualifying_item_rulesone ofRules that identify the items counted toward buy_min_quantity for a buy_x_get_y promotion.
recurrenceone of or nullOptional recurrence for subscription payments: once applies to the first charged payment, repeating applies for period_count charged payments, and forever applies to every payment. One-time orders apply the promotion once.
reward_selectionenumWhich matching reward items receive the discount: the cheapest, the highest priced, or those added first to the order. Defaults to cheapest.
cheapesthighest_pricefirst_added
typeenumDiscount effect: a percentage, a fixed amount, or a discount on reward items after qualifying purchases.
percent_offamount_offbuy_x_get_y
combines_withobjectSend only the classes to change. Omitted classes keep their current value. null, an empty object, and null classes are invalid.
line_itembooleanAllow line item promotions, subject to the evaluation order on Promotion.
orderbooleanAllow order promotions, subject to the evaluation order on Promotion.
service_chargebooleanAllow service charge promotions, subject to the evaluation order on Promotion.
descriptionstring or nullDescription of the promotion for your own records. Send null to clear it.
discount_classenumPromotion discount class.
orderline_itemservice_charge
display_namestringBuyer-facing promotion name shown in checkout and order discount surfaces.
eligibility_rulesone of or nullReplaces the promotion's eligibility conditions. Send null to remove all eligibility conditions.
Send exactly one of these
allarray of one ofRequiredRules and nested groups that must all match.
exclusivityobject or nullFields of the exclusivity group and priority to change. Send null to remove the promotion from its exclusivity group.
groupstringExact, case-sensitive group name, 1 to 100 characters after trimming.
priorityintegerHigher priority wins. Equal priorities favor the larger standalone discount, then the earlier created_at, then the lower promotion_id.
expected_versionintegerResource version last read by the caller. Required when application_method or eligibility_rules is present, including an empty collection or a supported null clear. Optional for scalar updates.
external_reference_idstring or nullCaller-owned identifier for this resource in an external system. Send null to clear it.
max_usesinteger or nullMaximum number of redemptions across all codes and automatic applications. Send null to remove the redemption limit.
max_uses_per_customerinteger or nullMaximum reserved and redeemed uses per identified customer across every code and automatic or ID-based application. Checked atomically when payment starts. Failed, canceled, or expired attempts release their reservation; refunds do not restore uses. Counts only within the same merchant and environment; live and test mode are separate. Without an identified customer, returns 409 PROMOTION_DECLINED with reason customer_required. Omit to keep the current limit; send null to remove it.
metadatamap of string or nullCaller-owned metadata. Omit this field to leave metadata unchanged. Send an object to merge by key, set a key to null to remove it, or set metadata to null to clear all caller-owned metadata. An empty object makes no change. Values can't be empty strings. Keys starting with flint_ are reserved for Flint, are not returned, and cannot be written through the public API.
namestringInternal promotion name for dashboards, searching, and reporting. Surrounding whitespace is trimmed before length validation. A supplied value cannot be blank; use null where clearing is supported.
scheduleobject or nullFields of the promotion schedule to change. Send null to remove the schedule.
ends_atstring or nullTime after which the promotion can no longer apply, as an absolute RFC3339 timestamp. Omission keeps the stored value; null clears it.
starts_atstring or nullEarliest time the promotion can apply, as an absolute RFC3339 timestamp. Omission keeps the stored value; null clears it.
timezonestring or nullIANA zone the schedule was entered in, used for display. starts_at and ends_at are absolute timestamps, so this does not change when the promotion starts or ends. Send null to clear it.
statusenumLifecycle status to set: active or inactive. Archived promotions cannot be updated.
activeinactive
curl -X PATCH https://api.withflintpay.com/v1/promotions/promo_01KEZF7C00QQ8EZ74BDYSZ315V \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: a-unique-key" \
-d '{
"description": "20% off selected spring tickets",
"expected_version": 1,
"status": "inactive"
}'Delete promotion#
/v1/promotions/{promotion_id}IdempotentRequires scope commerce.promotions.write
Rate limit: write
Archives a promotion and returns it as a read does. Deleting an already archived promotion returns it again without changing its version or `updated_at`, sending a webhook, or checking references.
Path parameters
promotion_idstringRequiredFlint promotion ID. Must be a valid ID with prefix promo_. Malformed IDs return 400 INVALID_REQUEST with detail INVALID_VALUE; well-formed IDs that do not exist return 404 RESOURCE_NOT_FOUND.
Query parameters
expected_versionintegerOptional resource version last read by the caller.
curl -X DELETE https://api.withflintpay.com/v1/promotions/promo_01KEZF7C00QQ8EZ74BDYSZ315V \
-H "Flint-Version: 2026-09-07" \
-H "Authorization: Bearer YOUR_API_KEY"Was this helpful?