{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/affiliatebase-io/json-schema/affiliatebase-io-referral-schema.json",
  "title": "Referral",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/affiliatebase-io-openapi.yml#/components/schemas/Referral",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "conversion_state": {
      "type": "string"
    },
    "attribution_method": {
      "type": "string",
      "enum": [
        "link",
        "promo_code"
      ],
      "description": "How the referral was attributed. `promo_code` when it came through an affiliate's code (a tracked visit with the code or a redemption at Stripe checkout), otherwise `link`."
    },
    "coupon_id": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "string",
          "format": "uuid"
        }
      ],
      "description": "The affiliate coupon the referral came through, when `attribution_method` is `promo_code`."
    },
    "expires_at": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "string",
          "format": "date-time"
        }
      ]
    },
    "deactivated_at": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "string",
          "format": "date-time"
        }
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  }
}