Discounts

Update discount

Changed on

Updates an existing discount. The terms checkouts charge are fixed once the discount exists: changing discount_type, percent_off, amount_off, duration, duration_in_months, or a fixed discount's currency, raising max_redemptions, or moving redeem_by later returns 422 naming the field. Create a new discount for different terms.

patch/discounts/{id}

Request

  • Base URL
    https://api.crevio.co/v1
  • Auth
    API key in header Authorization

Path parameters

id, string required

The resource's ID, as returned in its id field

Request body

DiscountRequest required
code, string

Letters, numbers, dashes and underscores. Unique per business regardless of case.

status, 'active' | 'inactive'

inactive turns the code off at once and checkout rejects it; active turns it back on. Leaves redeem_by and the code's products unchanged.

discount_type, 'percentage' | 'fixed'
amount_off, integer nullable

Amount off in the currency's smallest unit (cents), for a fixed discount.

percent_off, number nullable
currency, string nullable

Three-letter currency code. Required when discount_type is fixed or minimum_amount is set.

duration, 'forever' | 'once' | 'repeating'
duration_in_months, integer nullable
starts_at, string date-time nullable

When the code becomes usable. Checkout rejects it before this time; omit it to make the code usable right away. For a sale that starts later, create the discount now with starts_at set rather than scheduling its creation.

redeem_by, string date-time nullable

When the code stops being usable. Must be after starts_at and in the future whenever it is set. To end a code now, set status to inactive.

max_redemptions, integer nullable

How many live orders can use the code, across all contacts. Test purchases don't count. Can be lowered later, or set later on a code created without one; raising it past the number set at creation answers 422, so create a new code for more uses.

minimum_amount, integer nullable

Smallest order subtotal, in cents before the discount, that can use the code. Requires currency; an order in another currency can't use the code. null removes it.

once_per_customer, boolean

Each contact can use the code on one live order.

first_order_only, boolean

Only contacts with no earlier live paid order from this business can use the code. Free orders and test purchases don't count as earlier orders.

price_variants, string[]

Response

Discount updated

Discount required
id, string required
object, string required
status, 'active' | 'inactive' | 'expired' required

expired once redeem_by has passed on an active code. inactive means it was turned off.

discount_type, 'percentage' | 'fixed' required
code, string required
amount_off, integer nullable required
duration, 'forever' | 'once' | 'repeating' required
duration_in_months, integer nullable required
max_redemptions, integer nullable required
times_redeemed, integer required
starts_at, string date-time nullable required
redeem_by, string date-time nullable required
minimum_amount, integer nullable required
once_per_customer, boolean required
first_order_only, boolean required
created_at, string date-time required
updated_at, string date-time required
percent_off, number double nullable required
currency, string nullable required
price_variants, string[] required

The prices (price_...) the code works on. Empty means every price.

Changes

    • warning

      added the new expired enum value to the status response property for the response status

    • breaking

      added the pattern ^[a-zA-Z0-9_-]+$ to the request property code

    • warning

      the amount_off request property's max was set to 99999999.00

    9 more changes in this revision