Discounts

Create discount

Changed on

Creates a new discount code. The business must have Stripe connected: without it this answers 422 with code stripe_not_connected, and the body was not at fault.

post/discounts

Request

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

Headers

Idempotency-Key, string

Makes this write safe to retry: a repeat with the same key replays the first response instead of creating a second resource. Scoped to the account, remembered for 24 hours; reusing a key with a different payload is an error.

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 created

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