{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/hint-health/main/json-schema/hint-health-membership-create-sanitizer-schema.json",
  "title": "MembershipCreateSanitizer",
  "x-generated": "2026-10-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hint-health-membership-api-openapi.yml#/components/schemas/MembershipCreateSanitizer",
  "type": "object",
  "properties": {
    "membership_patients": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MembershipUpdateSanitizer.MembershipPatient"
      },
      "description": "Members can be used as an alias for membership_patients"
    },
    "plan": {
      "$ref": "#/$defs/Association"
    },
    "owner": {
      "$ref": "#/$defs/Association"
    },
    "sponsorship": {
      "$ref": "#/$defs/Association"
    },
    "start_date": {
      "type": "string",
      "format": "date",
      "description": "Sponsored memberships must start on the 1st of the month. Retail memberships may start any day. Date must be formatted as YYYY-MM-DD."
    },
    "end_date": {
      "type": "string",
      "format": "date",
      "description": "Date must be formatted as YYYY-MM-DD."
    },
    "period_in_months": {
      "type": "integer",
      "format": "int32",
      "description": "Billing period in months. 1 = monthly, 3 = quarterly, 6 = semi-annually, 12 = annually",
      "enum": [
        "1",
        "3",
        "6",
        "12"
      ]
    },
    "fixed_period_rate_in_cents": {
      "type": "integer",
      "format": "int32"
    },
    "fixed_registration_fee_in_cents": {
      "type": "integer",
      "format": "int32"
    }
  },
  "required": [
    "membership_patients",
    "plan",
    "start_date",
    "period_in_months"
  ],
  "$defs": {
    "Association": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        }
      },
      "required": [
        "id"
      ]
    },
    "MembershipUpdateSanitizer.MembershipPatient": {
      "type": "object",
      "properties": {
        "patient": {
          "$ref": "#/$defs/MembershipUpdateSanitizer.Patient"
        },
        "start_date": {
          "type": "string",
          "format": "date",
          "description": "Defaults to Membership start date if not given. Sponsored memberships must start on the 1st of the month. Retail memberships may start any day. Date must be formatted as YYYY-MM-DD."
        },
        "member_type": {
          "type": "string",
          "description": "Choose one below. \"employee\" should only be used on sponsored memberships. Only one employee may be designated per sponsored membership. For non-sponsored memberships, all adults may be sent as \"spouse\" (naming convention may be updated in the future). All child dependents on all memberships may be sent as \"child\"",
          "enum": [
            "child",
            "spouse",
            "employee"
          ]
        },
        "fixed_period_rate_in_cents": {
          "type": "integer",
          "format": "int32",
          "description": "Use this to override the standard rates that the membership plan would generate"
        }
      },
      "required": [
        "patient",
        "member_type"
      ]
    },
    "MembershipUpdateSanitizer.Patient": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "uses_tobacco": {
          "type": "boolean"
        }
      },
      "required": [
        "id"
      ]
    }
  }
}