{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/salesforce-commerce-cloud/json-schema/salesforce-commerce-cloud-coupon-schema.json",
  "title": "Coupon",
  "description": "Document representing a coupon.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/salesforce-commerce-cloud-coupons-api-openapi.yml#/components/schemas/Coupon",
  "type": "object",
  "required": [
    "couponId",
    "enabled",
    "type"
  ],
  "additionalProperties": false,
  "properties": {
    "couponId": {
      "minLength": 1,
      "maxLength": 256,
      "description": "The ID of the coupon.",
      "type": "string"
    },
    "creationDate": {
      "description": "Returns the value of attribute 'creationDate'.",
      "type": "string",
      "format": "date-time"
    },
    "description": {
      "maxLength": 4000,
      "description": "The description of the coupon.",
      "type": "string"
    },
    "enabled": {
      "description": "A flag indicating whether the coupon is enabled.",
      "type": "boolean"
    },
    "exportedCodeCount": {
      "format": "int32",
      "description": "The number of coupon codes attached to the coupon that have been issued (read only).",
      "type": "integer"
    },
    "lastModified": {
      "description": "Returns the value of attribute 'lastModified'.",
      "type": "string",
      "format": "date-time"
    },
    "redemptionCount": {
      "format": "int32",
      "description": "The number of times the coupon has been redeemed (read only). The count is updated once per hour.",
      "type": "integer"
    },
    "redemptionLimits": {
      "description": "The redemption limit per coupon code.",
      "allOf": [
        {
          "$ref": "#/$defs/RedemptionLimits"
        }
      ]
    },
    "singleCode": {
      "minLength": 1,
      "maxLength": 256,
      "description": "Single coupon code, only valid for Single Code type.",
      "type": "string"
    },
    "systemCodesConfig": {
      "description": "The configuration of system coupon codes, including prefix and number of codes.",
      "allOf": [
        {
          "$ref": "#/$defs/CouponSystemCodeConfig"
        }
      ]
    },
    "totalCodesCount": {
      "format": "int32",
      "description": "The total number of coupon codes associated with this coupon (read only). The count is updated once per hour.",
      "type": "integer"
    },
    "type": {
      "description": "The type of coupon code.",
      "enum": [
        "single_code",
        "multiple_codes",
        "system_codes"
      ],
      "type": "string"
    }
  },
  "$defs": {
    "CouponSystemCodeConfig": {
      "type": "object",
      "required": [
        "codePrefix",
        "numberOfCodes"
      ],
      "additionalProperties": false,
      "properties": {
        "codePrefix": {
          "description": "The code prefix for system-generated coupon codes.",
          "type": "string"
        },
        "numberOfCodes": {
          "format": "int32",
          "description": "The number of system coupon codes that can be issued.",
          "type": "integer"
        }
      }
    },
    "RedemptionLimitPerPeriod": {
      "description": "Document representing a coupon redemption limit.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "limit",
        "redemptionTimeFrame"
      ],
      "properties": {
        "limit": {
          "minimum": 0,
          "format": "int32",
          "description": "The limit on the number of times a coupon can be redeemed for a specified redemption time period.",
          "type": "integer"
        },
        "redemptionTimeFrame": {
          "minimum": 0,
          "maximum": 999,
          "format": "int32",
          "description": "The redemption time period.",
          "type": "integer"
        }
      }
    },
    "RedemptionLimits": {
      "description": "Document representing a coupon.",
      "additionalProperties": false,
      "properties": {
        "limitPerCode": {
          "minimum": 0,
          "format": "int32",
          "description": "The redemption limit per code.",
          "type": "integer"
        },
        "limitPerCustomer": {
          "minimum": 0,
          "format": "int32",
          "description": "The redemption limit per customer.",
          "type": "integer"
        },
        "limitPerTimeFrame": {
          "description": "The redemption limit per time frame.",
          "allOf": [
            {
              "$ref": "#/$defs/RedemptionLimitPerPeriod"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "limitPerCode",
        "limitPerCustomer",
        "limitPerTimeFrame"
      ]
    }
  }
}