{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/payments-ai/json-schema/payments-ai-public-api-update-discount-code-request-schema.json",
  "title": "PublicApiUpdateDiscountCodeRequest",
  "description": "Send only the fields to change. `code` may be sent only with its current value.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/payments-ai-public-api-api-openapi.yml#/components/schemas/PublicApiUpdateDiscountCodeRequest",
  "type": "object",
  "properties": {
    "code": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "internalName": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "promoType": {
      "$ref": "#/$defs/PublicApiDiscountPromoType"
    },
    "amountOff": {
      "anyOf": [
        {
          "$ref": "#/$defs/PublicApiDiscountAmountOff"
        },
        {
          "$ref": "#/$defs/SharedTypes.MoneyAmountValue"
        }
      ]
    },
    "currency": {
      "$ref": "#/$defs/SharedTypes.CurrencyCode"
    },
    "billingPeriod": {
      "$ref": "#/$defs/PublicApiDiscountBillingPeriod"
    },
    "billingPeriodLength": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int32",
      "minimum": 1,
      "description": "Required with billingPeriod repeating. Cleared when billingPeriod becomes once or forever."
    },
    "billingPeriodUnit": {
      "allOf": [
        {
          "$ref": "#/$defs/PublicApiDiscountBillingPeriodUnit"
        }
      ],
      "nullable": true,
      "description": "Required with billingPeriod repeating. Cleared when billingPeriod becomes once or forever."
    },
    "productId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Send null to make the code store-wide."
    },
    "expiresAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Send null to remove the expiry."
    }
  },
  "$defs": {
    "PublicApiDiscountAmountOff": {
      "type": "string",
      "description": "Decimal string, for example \"20\" or \"10.50\". A JSON number is also accepted."
    },
    "PublicApiDiscountBillingPeriod": {
      "type": "string",
      "enum": [
        "once",
        "repeating",
        "forever"
      ],
      "description": "How long the discount applies to a subscription: the first payment only (once), a number of billing periods (repeating), or every payment (forever)."
    },
    "PublicApiDiscountBillingPeriodUnit": {
      "type": "string",
      "enum": [
        "day",
        "week",
        "month",
        "year"
      ]
    },
    "PublicApiDiscountPromoType": {
      "type": "string",
      "enum": [
        "percentage",
        "flat_amount"
      ]
    },
    "SharedTypes.CurrencyCode": {
      "type": "string",
      "pattern": "^[a-z]{3}$",
      "description": "ISO 4217 currency code. Always lowercase (e.g. 'usd', 'eur')."
    },
    "SharedTypes.MoneyAmountValue": {
      "type": "number",
      "format": "decimal",
      "description": "Decimal money amount for financial values."
    }
  }
}