{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/affiliaterail-com/json-schema/affiliaterail-com-coupon-list-schema.json",
  "title": "CouponList",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/affiliaterail-com-coupons-api-openapi.yml#/components/schemas/CouponList",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Coupon"
      }
    },
    "has_more": {
      "type": "boolean",
      "description": "Pass the last object's id as `starting_after` to fetch the next page"
    },
    "total_count": {
      "type": "integer",
      "description": "Count of every object matching the filters, ignoring the cursor"
    }
  },
  "required": [
    "data",
    "has_more",
    "total_count"
  ],
  "$defs": {
    "Coupon": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^(sample_)?cpn_",
          "description": "Prefixed id (`cpn_…`)"
        },
        "object": {
          "type": "string",
          "enum": [
            "coupon"
          ]
        },
        "program_id": {
          "type": "string",
          "pattern": "^(sample_)?prg_",
          "description": "Prefixed id (`prg_…`)"
        },
        "partner_id": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^(sample_)?part_",
          "description": "Prefixed id (`part_…`)"
        },
        "group_id": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^(sample_)?grp_",
          "description": "Prefixed id (`grp_…`)"
        },
        "code": {
          "type": "string"
        },
        "external_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "The processor's own promotion id, and the only thing a sale is matched on"
        },
        "stats": {
          "type": "object",
          "properties": {
            "customers": {
              "type": "integer"
            }
          },
          "required": [
            "customers"
          ]
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "description": "ISO-8601, UTC"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "description": "ISO-8601, UTC"
        }
      },
      "required": [
        "id",
        "object",
        "program_id",
        "partner_id",
        "group_id",
        "code",
        "external_id",
        "created_at",
        "updated_at"
      ]
    }
  }
}