{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/crevio-co/json-schema/crevio-co-discount-request-schema.json",
  "title": "DiscountRequest",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/crevio-co-discounts-api-openapi.yml#/components/schemas/DiscountRequest",
  "type": "object",
  "properties": {
    "code": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "inactive"
      ],
      "description": "`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": {
      "type": "string",
      "enum": [
        "percentage",
        "fixed"
      ]
    },
    "amount_off": {
      "type": [
        "integer",
        "null"
      ]
    },
    "percent_off": {
      "type": [
        "number",
        "null"
      ]
    },
    "currency": {
      "type": [
        "string",
        "null"
      ]
    },
    "duration": {
      "type": "string",
      "enum": [
        "forever",
        "once",
        "repeating"
      ]
    },
    "duration_in_months": {
      "type": [
        "integer",
        "null"
      ]
    },
    "starts_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "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": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "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": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1,
      "description": "How many live orders can use the code, across all customers. Test purchases don't count. The limit set at creation also stays on the Stripe coupon, so raising it later has no effect past that number."
    },
    "minimum_amount": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1,
      "description": "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": {
      "type": "boolean",
      "description": "Each customer can use the code on one live order."
    },
    "first_order_only": {
      "type": "boolean",
      "description": "Only customers 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": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  }
}