{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ranla-ai/json-schema/ranla-ai-create-affiliate-campaign-request-schema.json",
  "title": "CreateAffiliateCampaignRequest",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ranla-ai-openapi.yml#/components/schemas/CreateAffiliateCampaignRequest",
  "type": "object",
  "required": [
    "name"
  ],
  "additionalProperties": false,
  "properties": {
    "name": {
      "type": "string",
      "maxLength": 80
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "visibility": {
      "type": "string",
      "enum": [
        "public",
        "private"
      ]
    },
    "auto_approve": {
      "type": "boolean"
    },
    "commission_type": {
      "type": "string",
      "enum": [
        "percent",
        "flat"
      ]
    },
    "commission_bps": {
      "type": "integer",
      "minimum": 0,
      "maximum": 10000
    },
    "commission_flat_cents": {
      "type": "integer",
      "minimum": 0
    },
    "commission_duration": {
      "type": "string",
      "enum": [
        "once",
        "recurring"
      ]
    },
    "recurring_months": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1,
      "maximum": 120
    },
    "max_commission_cents": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1
    },
    "tiers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AffiliateCommissionTier"
      }
    },
    "product_rates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AffiliateProductRate"
      }
    },
    "second_tier_bps": {
      "type": "integer",
      "minimum": 0,
      "maximum": 5000
    },
    "lead_bounty_cents": {
      "type": "integer",
      "minimum": 0
    },
    "cookie_days": {
      "type": "integer",
      "minimum": 1,
      "maximum": 365
    },
    "hold_days": {
      "type": "integer",
      "minimum": 0,
      "maximum": 180
    },
    "landing_url": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "referee_discount_label": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 120
    },
    "make_default": {
      "type": "boolean",
      "description": "Make this the default campaign for new partners"
    }
  },
  "$defs": {
    "AffiliateCommissionTier": {
      "type": "object",
      "required": [
        "min_paid_customers"
      ],
      "properties": {
        "min_paid_customers": {
          "type": "integer",
          "minimum": 1
        },
        "commission_bps": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "maximum": 10000
        },
        "commission_flat_cents": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        }
      }
    },
    "AffiliateProductRate": {
      "type": "object",
      "required": [
        "stripe_product_id",
        "commission_bps"
      ],
      "properties": {
        "stripe_product_id": {
          "type": "string"
        },
        "commission_bps": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10000
        }
      }
    }
  }
}