Skip to content

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_method is percent_off, amount_off, or buy_x_get_y. It's required, including its type.
  • The layer. discount_class is order (the default), line_item, or service_charge.
  • Who qualifies. eligibility_rules are the conditions an order must meet. Leave them out and every order qualifies.
  • What gets discounted. application_method.discounted_item_rules choose the items or charges; see targeting.
  • How a buyer gets it. redemption_type is automatic or code. It defaults to code when you send codes, and to automatic otherwise.
  • What it shares an order with. combines_with and exclusivity. By default it combines with every class and belongs to no group.
  • When and how often. schedule, max_uses, and max_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
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}]
  }'
Response
{
  "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.writeReference for POST /v1/orders/{order_id}/discounts

    Applies one promotion by promotion_code or promotion_id, or one manual discount. You can also send codes in discounts when you create the order.

  • POST/v1/discount-previewsRequired API key scopes: commerce.orders.read or commerce.orders.writeReference for POST /v1/discount-previews

    Shows 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.writeReference for POST /v1/orders/{order_id}/discounts/remove

    Removes pending code and manual discounts by order_discount_ids, and signup promotions the order accepted for its subscription by deferred_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.writeReference for POST /v1/orders/{order_id}/discounts/reprice

    Recalculates 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_rules is the gate: conditions the order, customer, or items must meet before the promotion applies at all.
  • discounted_item_rules, inside application_method, is the target: the line items or charges that receive the discount.
  • discount_class is the layer: order discounts the whole order, line_item discounts matching items, and service_charge discounts 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.

allocationamount_off of $10 on three matching itemspercent_off
each$10 off each item, $30 in total, each capped at the item's priceTaken from each item
across$10 once, spread over the three itemsTaken 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]}]}.

JSON
{
  "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.

AttributeValueOperatorsMatches
order.subtotalmoneygt, gte, lt, lteThe order's merchandise subtotal
order.merchandise_subtotal_before_discountsmoneygt, gte, lt, lteThe same value as order.subtotal
order.merchandise_subtotal_after_line_item_discountsmoneygt, gte, lt, lteThe subtotal after line-item discounts
matched_items.subtotalmoneygt, gte, lt, lteThe subtotal of the items matched in the same all group
order.currencystringeq, ne, in, contains, is_definedThe order's currency, such as USD
customer.segmentstringeq, in, is_definedThe customer's segment, a label you assign
customer.is_merchant_verifiedbooleaneqThe customer's is_merchant_verified flag, which you set
customer.paid_order_countnumbereq, ne, gt, gte, lt, lte, in, is_definedThe customer's other paid or completed zero-total orders in this merchant and environment
metadata.<key>stringeq, ne, in, contains, is_definedA key in the customer's metadata, such as metadata.channel
line_item.product_idstringeq, ne, in, contains, is_definedCatalog product ID
line_item.variant_idstringeq, ne, in, contains, is_definedCatalog variant ID
line_item.bundle_idstringeq, ne, in, contains, is_definedCatalog bundle ID
line_item.categoriescategory handleeq, ne, in, is_definedThe item's categories; ne matches when none of them match
line_item.quantitynumbereq, ne, gt, gte, lt, lte, in, is_definedThe item's quantity
charge.typestringeq, ne, in, contains, is_definedThe charge type, such as shipping_fee or delivery_fee
delivery_choice.typestringeq, ne, in, contains, is_definedshipment, pickup, or local_delivery
delivery_choice.method_idstringeq, ne, in, contains, is_definedThe selected delivery method ID
delivery_choice.raw_amountmoneygt, gte, lt, lteThe delivery price before delivery discounts and tax
delivery_choice_group.idstringeq, ne, in, contains, is_definedThe choice group of the selected method
choice_group.merchandise_subtotal_before_discountsmoneygt, gte, lt, lteThe value of the items in the selected delivery choice's group
choice_group.merchandise_subtotal_after_line_item_discountsmoneygt, gte, lt, lteThe same value after line-item discounts

How values and operators work:

  • values is always an array. Only in takes more than one value.
  • is_defined takes no values and tests only whether the attribute is present.
  • String comparisons ignore case. contains is a substring match on one value; for "one of these values", use in.
  • 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 codes when you create it, and takes at most 100 per request. The create response returns them in codes, in request order, with each promotion_code_id; no other promotion response includes codes. Add more with POST /v1/promotion-codes, with promotion_id in the body.
  • Codes are unique within live mode or a sandbox, ignoring case but distinguishing accents, and keep the spelling you created. CAFÉ and café match the same code; CAFE is a separate code. A code that already exists returns 409 ALREADY_EXISTS, and leading or trailing spaces are rejected.
  • Only code promotions take codes. Sending codes with redemption_type: automatic, or creating a code under an automatic promotion, returns 400 INVALID_REQUEST.
  • A code's expires_at must be in the future when you set it.
  • GET /v1/promotion-codes?code= finds a code by the same matching rule, and GET /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_DECLINED with reason customer_mismatch. With no identified customer, it returns customer_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_id aren't bound.
  • PATCH keeps the binding when you omit customer_id, binds the code to another customer when you send that customer's ID, and removes the binding when you send null.
  • 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 as promotion_id.
  • Catalog and environment copies skip customer-bound codes. Promotions and unbound codes copy with their max_uses_per_customer and 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:

Promotion statusFinal
  • 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 promotion
Final values do not change again
  • active
    Switched on. It applies whenever it's also available.
  • inactive
    Switched off. It stays editable, and setting status back to active resumes it.
  • archivedFinal
    Archived with DELETE, 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:

JSON
{"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 promotion
  • inactive
    You set status to inactive. Set it back to active to resume.
  • archived
    The promotion was archived with DELETE. It can't be changed or applied again.
  • not_yet_started
    schedule.starts_at is in the future.
  • expired
    schedule.ends_at has passed.
  • exhausted
    uses_count has reached max_uses.
  • no_active_codes
    A 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 code
  • archived
    The code was archived with DELETE, on its own or with its promotion.
  • inactive
    You set the code's status to inactive.
  • expired
    The code's expires_at has passed.
  • exhausted
    The code's uses_count has reached its max_uses.
  • promotion_unavailable
    The code is usable, but its promotion isn't. Read the promotion's unavailable_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, and DELETE returns it exactly as a following GET does;
  • 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, returns 409 ACTION_NOT_ALLOWED with reason: 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_customer or a customer.paid_order_count rule, or a code bound to a customer, returns 409 PROMOTION_DECLINED with reason customer_required. An identified customer other than a bound code's customer gets customer_mismatch.
  • When it's reached. The customer gets 409 PROMOTION_DECLINED with reason customer_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:

  1. Manual discounts stay. Promotion rules never remove them, and they don't count toward the promotion limit or combines_with.
  2. Promotions from a subscription's frozen terms come next, outside exclusivity, combines_with, and the limit.
  3. 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.
  4. Within each exclusivity.group, only one candidate continues.
  5. The rest are ranked by the discount each would give alone, largest first, with ties to the earlier created_at and then the lower promotion_id. Each is admitted unless the order has reached max_promotions_per_order, or it and a discount already admitted don't both allow each other's discount_class.
  6. 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:

OutcomeWhere to read the reason
The code or promotion can't be appliederror.details[0].reason, with error.code: PROMOTION_DECLINED
The code is valid but lost to other offersmeta.warnings[].reason on a promotion_declined warning
Applying it removed promotions already on the ordermeta.warnings[].reason on each promotion_removed warning
A discount previewpromotion_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 candidate
  • not_eligible
    The order doesn't meet the eligibility rules. A reason your integration doesn't recognize also means this.
  • minimum_not_met
    A spend minimum isn't reached. Errors add required_money, current_money, and gap_money; preview candidates add threshold_money, current_money, and gap_money.
  • expired
    The promotion's schedule.ends_at or the code's expires_at has passed.
  • not_yet_started
    The promotion's schedule.starts_at is in the future.
  • exhausted
    The promotion or code has reached its max_uses.
  • customer_limit_reached
    The customer has used the promotion max_uses_per_customer times.
  • customer_required
    The order has no identified customer, and the promotion has a max_uses_per_customer limit or a customer.paid_order_count rule, or the code is bound to a customer.
  • customer_mismatch
    The order's identified customer isn't the customer the code is bound to.
  • code_required
    The promotion needs a code, and none was given.
  • code_invalid
    No code matches the string entered.
  • inactive
    The promotion or code is inactive or archived.
  • automatic_disabled
    Automatic promotions are turned off in your settings or for this checkout.
  • codes_disabled
    Promotion codes are turned off in your settings or for this checkout.
  • already_applied
    The promotion is already on the order.
  • recurrence_completed
    The removed promotion has no discounted cycles remaining on this subscription. Reattaching it does not reset its allowance.
  • not_combinable
    Its combines_with and another discount's don't allow each other's class.
  • superseded_by_better_offer
    A promotion in the same exclusivity group with equal priority and a larger discount won.
  • superseded_by_higher_priority
    A promotion in the same exclusivity group with a higher exclusivity.priority won.
  • superseded
    Another promotion replaced this one. Prefer the two more specific reasons above when you get them.
  • max_promotions_reached
    The order already has max_promotions_per_order promotions.
  • no_discountable_balance
    Nothing is left on the order to discount.
  • buy_item_missing
    The cart lacks enough qualifying units or separate reward units for a buy-X-get-Y promotion. A unit cannot count toward both quantities.
  • currency_mismatch
    The order's currency has no discount amount or threshold.
  • unknown_type
    Flint 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, and currency_options are replaced whole when you send them.
  • To change the effect, send application_method.type with the new effect's fields, as on create. allocation, calculation_basis, recurrence, and discounted_item_rules keep their values unless you send them. Sending another effect's field without type, such as amount_off_money on a percent_off promotion, returns 400 INVALID_REQUEST.
  • null clears an optional field, such as max_uses, max_uses_per_customer, eligibility_rules, schedule or one of its fields, exclusivity, or application_method.discounted_item_rules. null on a required field returns 400 INVALID_REQUEST. exclusivity.priority can't be null; send 0 to reset it.
  • While the promotion's uses_count, or any of its codes' uses_count, is above 0, its discount_class and effect type are fixed. Changing them returns 409 ACTION_NOT_ALLOWED with reason field_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 version increases when you update or archive it.
  • A promotion's version increases when you update or archive it, and when creating, updating, or archiving one of its codes changes its codes_summary. That change also sends promotion.updated.
  • Redemptions, released uses, and time passing don't change either one: uses_count, available, unavailable_reason, codes_summary.active_count, and codes_summary.newest_active_code change without a new version.

Send the version you read as expected_version to refuse a write if the resource changed since:

Requestexpected_version
PATCH a promotion with application_method or eligibility_rules, including nullRequired
PATCH a promotion with other fieldsOptional
PATCH a codeOptional, checked against the code
DELETE a promotion or codeOptional, 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#

  • HTTP 400
    A rule, effect, or field is invalid, and param names it. A non-positive or non-integer max_uses_per_customer, an empty customer_id filter, 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, missing discounted_item_rules, a code promotion without codes, codes on an automatic promotion, more than 100 codes, or a missing expected_version (detail REQUIRED).
  • HTTP 404
    The promotion or code doesn't exist in this mode, or a category rule names a category handle that doesn't exist.
  • HTTP 409
    Another code in this mode has the same string, ignoring case but distinguishing accents. Choose another, or archive the old code first.
  • HTTP 409
    reason: archived when the promotion or code is archived. reason: field_locked when an update changes discount_class or the effect type after a use has counted; create a new promotion instead.
  • HTTP 409
    An update changes application_method.recurrence.type while active subscription offers use the promotion; those offers require forever recurrence. Remove the promotion from them or make them inactive first.
  • HTTP 409
    VERSION_CONFLICTRefresh, then retry
    expected_version doesn't match. Read the resource again and reapply your change.

Webhooks#

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.

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 ofRequired

Discount effect and how it applies to eligible items or charges.

availablebooleanRequired

Whether 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 object

The 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_summaryobject

Read-only rollup of this promotion's codes. Present only on code-gated promotions; automatic promotions omit it.

combines_withobjectRequired

Which 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_atstring

When the promotion was created, as an RFC3339 timestamp.

descriptionstring

Optional description of the promotion for your own records.

discount_classenumRequired

Whether the promotion discounts the order, individual line items, or service charges.

  • order
  • line_item
  • service_charge
display_namestringRequired

Buyer-facing promotion name shown in checkout and order discount surfaces.

eligibility_rulesone of

Conditions an order must satisfy for the promotion to apply. Omitted when the promotion has no eligibility conditions.

exclusivityobject

Optional group and priority used to choose one promotion from competing promotions in the same group. See Promotion for the evaluation order.

external_reference_idstring

Caller-owned identifier for this resource in an external system.

max_usesinteger

Maximum number of redemptions across all codes and automatic applications. Omitted when there is no redemption limit.

max_uses_per_customerinteger or nullRequired

Maximum 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_idstring

Identifier of the merchant that owns the promotion.

metadatamap of string

Key-value data you attach to the promotion.

namestringRequired

Internal promotion name for dashboards, searching, and reporting.

promotion_idstringRequired

Unique identifier for the promotion.

redemption_typeenumRequired

Whether the promotion applies automatically when its rules match or requires a promotion code.

  • automatic
  • code
scheduleobject

Optional start and end times that limit when the promotion can apply.

statusenumRequired

Lifecycle status. Set active or inactive with PATCH; DELETE sets archived. An active promotion can still be unavailable: read available.

  • active
  • inactive
  • archived
unavailable_reasonenum

Why available is false. Present only when available is false.

  • inactive
  • archived
  • not_yet_started
  • expired
  • exhausted
  • no_active_codes
updated_atstring

When the promotion was last updated, as an RFC3339 timestamp.

uses_countintegerRequired

Number of times the promotion has been redeemed.

versionintegerRequired

Persisted owned-state version. Clock-based availability and expanded resources do not advance this counter.

JSON
{
  "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

availablebooleanRequired

Whether a buyer can redeem the code right now: the code is active, not expired, and under its max_uses, and its promotion is available.

codestringRequired

Code a buyer enters to redeem the promotion.

created_atstringRequired

When the promotion code was created, as an RFC3339 timestamp.

customer_idstring or nullRequired

Only 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_atstring

When the code stops being redeemable, as an absolute RFC3339 timestamp. Omitted when the code does not expire.

max_usesinteger

Maximum number of times this code can be redeemed. Omitted when the code has no redemption limit.

merchant_idstringRequired

Identifier of the merchant that owns the promotion code.

metadatamap of string

Key-value data you attach to the promotion code.

promotionobject

The promotion this code belongs to. Present only when the list request asked for expand=promotion.

promotion_code_idstringRequired

Unique identifier for the promotion code.

promotion_idstringRequired

Identifier of the promotion this code redeems.

statusenumRequired

Lifecycle status: active, inactive, or archived. Set active or inactive with PATCH; DELETE sets archived. An active code can still be unavailable: read available.

  • active
  • inactive
  • archived
timezonestring

IANA 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_reasonenum

Why 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.

  • archived
  • inactive
  • expired
  • exhausted
  • promotion_unavailable
updated_atstringRequired

When the promotion code was last updated, as an RFC3339 timestamp.

uses_countintegerRequired

Number of times this code has been redeemed.

versionintegerRequired

Persisted owned-state version. Clock-based availability and expanded resources do not advance this counter.

JSON
{
  "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#

GET/v1/promotion-codes

Requires 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_idstring

Exact match on the parent promotion ID.

customer_idstring

Exact match on the customer bound to the code. Unbound codes are excluded.

codestring

Exact 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 enum

Filter 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.

  • active
  • inactive
  • archived
availabilityarray of enum

Filter 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.

  • available
  • inactive
  • expired
  • exhausted
  • promotion_unavailable
page_sizeinteger

Maximum number of results to return, from 1 to 100. Defaults to 20.

page_tokenstring

Opaque, 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_byenum

Field to sort by. Defaults to created_at; ties are broken by promotion_code_id.

  • created_at
  • updated_at
sort_directionenum

Sort direction. Defaults to desc.

  • asc
  • desc
created_afterstring

Inclusive lower bound on created_at.

created_beforestring

Exclusive upper bound on created_at.

updated_afterstring

Inclusive lower bound on updated_at.

updated_beforestring

Exclusive upper bound on updated_at.

expandarray of enum

Include 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 objectRequired

Promotion codes returned in the requested sort order.

metaobject

Additional information about this response.

next_page_tokenstring

Token for the next page. Omitted when there are no more results.

request_idstringRequired

Identifier 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.

JSON
{
  "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#

POST/v1/promotion-codesIdempotent

Requires 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

codestringRequired

Code a buyer enters to redeem the promotion.

customer_idstring or null

Only 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_atstring

When the code stops being redeemable, as an absolute RFC3339 timestamp. Omit for no expiry.

max_usesinteger

Maximum number of times this code can be redeemed. Omit for no redemption limit.

metadatamap of string

Key-value data you attach to the promotion code.

promotion_idstringRequired

Flint promotion ID that owns this code.

statusenum

Lifecycle status. Defaults to active; send inactive to create a code that cannot be redeemed.

  • active
  • inactive
timezonestring

IANA 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.

dataobjectRequired

The requested promotion code.

metaobject

Additional information about this response.

request_idstringRequired

Identifier 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#

GET/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_idstringRequired

Flint 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.

Response · 200

The requested promotion code.

Same response as Create promotion code.

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.

JSON
{
  "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#

PATCH/v1/promotion-codes/{promotion_code_id}Idempotent

Requires 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_idstringRequired

Flint 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 null

Only 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_versioninteger

Promotion code version last read by the caller. Optional for updates.

expires_atstring or null

Absolute RFC3339 expiry timestamp. Omission keeps the stored value; null clears it.

max_usesinteger or null

Maximum number of times this code can be redeemed. Send null to remove the redemption limit.

metadatamap of string or null

Caller-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.

statusenum

Lifecycle status: active or inactive.

  • active
  • inactive
timezonestring or null

IANA 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.

Response · 200

The updated promotion code.

Same response as Create promotion code.

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#

DELETE/v1/promotion-codes/{promotion_code_id}Idempotent

Requires 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_idstringRequired

Flint 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_versioninteger

Optional resource version last read by the caller.

Response · 200

The archived promotion code.

Same response as Create promotion code.

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#

GET/v1/promotions

Requires 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_sizeinteger

Maximum number of results to return, from 1 to 100. Defaults to 20.

page_tokenstring

Opaque, 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 enum

Filter 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.

  • active
  • inactive
  • archived
availabilityarray of enum

Filter 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.

  • available
  • inactive
  • archived
  • not_yet_started
  • expired
  • exhausted
  • no_active_codes
external_reference_idstring

Exact-match filter on the caller-owned external reference ID.

querystring

Search 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_idstring

Filter to promotions with an explicit product target rule. Universal promotions are not included by catalog target filters.

variant_idstring

Filter to promotions with an explicit variant target rule. Universal promotions are not included by catalog target filters.

bundle_idstring

Filter to promotions with an explicit bundle target rule. Universal promotions are not included by catalog target filters.

category_handlestring

Filter to promotions with an explicit category target rule. Universal promotions are not included by catalog target filters.

redemption_typearray of enum

Filter 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.

  • automatic
  • code
discount_classarray of enum

Filter 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.

  • order
  • line_item
  • service_charge
sort_byenum

Field to sort by. Defaults to created_at; ties are broken by promotion_id.

  • name
  • created_at
  • updated_at
sort_directionenum

Sort direction. Defaults to desc.

  • asc
  • desc
created_afterstring

Inclusive lower bound on created_at.

created_beforestring

Exclusive upper bound on created_at.

updated_afterstring

Inclusive lower bound on updated_at.

updated_beforestring

Exclusive upper bound on updated_at.

Response · 200

A page of promotions.

dataarray of objectRequired

Promotions returned in the requested sort order.

metaobject

Additional information about this response.

next_page_tokenstring

Token for the next page. Omitted when there are no more results.

request_idstringRequired

Identifier 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.

JSON
{
  "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#

POST/v1/promotionsIdempotent

Requires 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 ofRequired

Discount effect and how it applies to eligible items or charges.

codesarray of object

Codes 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.

combines_withobject

Which discount classes this promotion can combine with. Omitted classes default to true.

descriptionstring

Optional description of the promotion for your own records.

discount_classenum

Defaults to order when omitted.

  • order
  • line_item
  • service_charge
display_namestring

Buyer-facing promotion name shown in checkout and order discount surfaces. Defaults to name when omitted.

eligibility_rulesone of

Conditions an order must satisfy for the promotion to apply. Omit to create a promotion with no eligibility conditions.

exclusivityobject

Optional group and priority used to choose one promotion from competing promotions in the same group. See Promotion for the evaluation order.

external_reference_idstring

Caller-owned identifier for this resource in an external system.

max_usesinteger

Maximum number of redemptions across all codes and automatic applications. Omit for no redemption limit.

max_uses_per_customerinteger or null

Maximum 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 string

Caller-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.

namestringRequired

Internal 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_typeenum

Whether the promotion applies automatically when its rules match or requires a promotion code.

  • automatic
  • code
scheduleobject

Optional start and end times that limit when the promotion can apply.

statusenum

Lifecycle status. Defaults to active; send inactive to create a promotion that is switched off.

  • active
  • inactive

Response · 201

The created promotion.

dataobjectRequired

The requested promotion.

metaobject

Additional information about this response.

request_idstringRequired

Identifier 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#

GET/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_idstringRequired

Flint 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.

Response · 200

The requested promotion.

Same response as Create promotion.

curl https://api.withflintpay.com/v1/promotions/promo_01KEZF7C00QQ8EZ74BDYSZ315V \
  -H "Flint-Version: 2026-09-07" \
  -H "Authorization: Bearer YOUR_API_KEY"

The requested promotion.

JSON
{
  "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#

PATCH/v1/promotions/{promotion_id}Idempotent

Requires 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_idstringRequired

Flint 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_methodobject

Fields of the discount effect to change. Omitted fields keep their stored values.

combines_withobject

Send only the classes to change. Omitted classes keep their current value. null, an empty object, and null classes are invalid.

descriptionstring or null

Description of the promotion for your own records. Send null to clear it.

discount_classenum

Promotion discount class.

  • order
  • line_item
  • service_charge
display_namestring

Buyer-facing promotion name shown in checkout and order discount surfaces.

eligibility_rulesone of or null

Replaces the promotion's eligibility conditions. Send null to remove all eligibility conditions.

exclusivityobject or null

Fields of the exclusivity group and priority to change. Send null to remove the promotion from its exclusivity group.

expected_versioninteger

Resource 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 null

Caller-owned identifier for this resource in an external system. Send null to clear it.

max_usesinteger or null

Maximum number of redemptions across all codes and automatic applications. Send null to remove the redemption limit.

max_uses_per_customerinteger or null

Maximum 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 null

Caller-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.

namestring

Internal 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 null

Fields of the promotion schedule to change. Send null to remove the schedule.

statusenum

Lifecycle status to set: active or inactive. Archived promotions cannot be updated.

  • active
  • inactive

Response · 200

The updated promotion.

Same response as Create promotion.

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#

DELETE/v1/promotions/{promotion_id}Idempotent

Requires 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_idstringRequired

Flint 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_versioninteger

Optional resource version last read by the caller.

Response · 200

The archived promotion.

Same response as Create promotion.

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?