{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api-evangelist.com/schemas/cloudbeds/cloudbeds-rate-plan-schema.json",
  "title": "Cloudbeds Rate Plan",
  "description": "JSON Schema for a Cloudbeds rate plan as returned by the Cloudbeds REST API v1.3 rate plan endpoints.",
  "type": "object",
  "required": ["ratePlanID", "propertyID"],
  "properties": {
    "ratePlanID": {
      "type": "string",
      "description": "Cloudbeds-assigned identifier for the rate plan."
    },
    "propertyID": {
      "type": "string",
      "description": "Identifier for the Cloudbeds property the rate plan belongs to."
    },
    "name": {
      "type": "string",
      "description": "Human-readable name for the rate plan."
    },
    "description": {
      "type": "string",
      "description": "Public-facing description of the rate plan."
    },
    "roomTypeID": {
      "type": "string",
      "description": "Identifier for the room type the rate plan applies to."
    },
    "currency": {
      "type": "string",
      "description": "ISO 4217 currency code for the rate plan."
    },
    "rates": {
      "type": "array",
      "description": "Per-day rates that make up the rate plan.",
      "items": {
        "type": "object",
        "properties": {
          "date": { "type": "string", "format": "date" },
          "rate": { "type": "number", "minimum": 0 },
          "minStay": { "type": "integer", "minimum": 0 },
          "maxStay": { "type": "integer", "minimum": 0 },
          "closedToArrival": { "type": "boolean" },
          "closedToDeparture": { "type": "boolean" }
        }
      }
    },
    "isActive": {
      "type": "boolean",
      "description": "Whether the rate plan is currently active."
    },
    "isBaseRate": {
      "type": "boolean",
      "description": "Whether the rate plan is the property's base rate."
    },
    "isDerived": {
      "type": "boolean",
      "description": "Whether the rate plan is derived from another rate plan."
    },
    "derivedFromRatePlanID": {
      "type": "string",
      "description": "Identifier of the parent rate plan when isDerived is true."
    },
    "channelDistribution": {
      "type": "array",
      "description": "Distribution channels mapped to this rate plan.",
      "items": {
        "type": "object",
        "properties": {
          "channel": { "type": "string" },
          "channelRoomTypeCode": { "type": "string" },
          "channelRatePlanCode": { "type": "string" }
        }
      }
    }
  }
}
