{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.coworkingview.com/schemas/partner-catalog-v1.schema.json",
  "title": "CoworkingView partner catalogue, version 1",
  "description": "What a partner publishes at a private HTTPS URL so CoworkingView can read products, prices and availability. Read nightly with 'Authorization: Bearer <key>'. Documentation: https://docs.coworkingview.com/en/partners/integrations/own-api/",
  "type": "object",
  "required": [
    "version",
    "products"
  ],
  "additionalProperties": true,
  "properties": {
    "version": {
      "const": 1
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "When this document was produced."
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$",
      "description": "Default ISO 4217 currency for prices that state none."
    },
    "locations": {
      "type": "array",
      "maxItems": 20000,
      "items": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "$ref": "#/$defs/id",
            "description": "The partner's stable centre id."
          },
          "name": {
            "type": "string",
            "maxLength": 300
          },
          "address": {
            "type": "string",
            "maxLength": 500
          },
          "city": {
            "type": "string",
            "maxLength": 120
          },
          "country": {
            "type": "string",
            "pattern": "^[A-Z]{2}$"
          },
          "latitude": {
            "type": "number"
          },
          "longitude": {
            "type": "number"
          }
        }
      }
    },
    "products": {
      "type": "array",
      "maxItems": 5000,
      "items": {
        "type": "object",
        "required": [
          "id",
          "type",
          "name"
        ],
        "properties": {
          "id": {
            "$ref": "#/$defs/id",
            "description": "Stable product/offer id. Never reuse an id for a different product."
          },
          "locationId": {
            "$ref": "#/$defs/id"
          },
          "type": {
            "enum": [
              "private_office",
              "fix_desk",
              "flex_desk",
              "day_pass",
              "meeting_room",
              "virtual_office",
              "event_space",
              "membership",
              "other"
            ]
          },
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "capacity": {
            "type": "number",
            "exclusiveMinimum": 0,
            "description": "People or desks."
          },
          "sizeM2": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "availableFrom": {
            "type": "string",
            "pattern": "^(now|\\d{4}-\\d{2}-\\d{2})$",
            "description": "Offices: 'now' or the first free date."
          },
          "bookable": {
            "type": "boolean",
            "description": "Can be booked online without a sales conversation."
          },
          "prices": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "object",
              "required": [
                "period",
                "amount"
              ],
              "properties": {
                "period": {
                  "enum": [
                    "hour",
                    "halfday",
                    "day",
                    "week",
                    "month",
                    "year",
                    "once"
                  ]
                },
                "amount": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "exclusiveMaximum": 1000000
                },
                "currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "taxIncluded": {
                  "type": "boolean"
                },
                "commitmentMonths": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Term this price assumes (12 = annual contract). Lets one product carry both the online monthly rate and the 12-month rate."
                }
              }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._\\-/]{0,119}$"
    }
  }
}
