{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/kicksma-sh/json-schema/kicksma-sh-match-schema.json",
  "title": "Match",
  "description": "Exactly what the public match page shows. First names and levels only; never emails, phones, tokens or manage links.",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/kicksma-sh-openapi.json#/components/schemas/Match",
  "type": "object",
  "properties": {
    "code": {
      "type": "string"
    },
    "url": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "enum": [
        "match",
        "tournament"
      ]
    },
    "format": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "americano",
        "mexicano",
        "king",
        null
      ],
      "description": "Tournaments only."
    },
    "fixedPairs": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Tournaments only: two partners play every round together instead of rotating."
    },
    "pairs": {
      "type": [
        "array",
        "null"
      ],
      "description": "A fixed-pairs tournament's list as pairs, in order: two first names each, or one name that needs a partner. Null otherwise.",
      "items": {
        "type": "object",
        "properties": {
          "names": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "partnerNeeded": {
            "type": "boolean"
          }
        }
      }
    },
    "title": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "open",
        "full",
        "cancelled",
        "past"
      ]
    },
    "startsAt": {
      "type": "string",
      "format": "date-time"
    },
    "endsAt": {
      "type": "string",
      "format": "date-time",
      "description": "startsAt plus durationMinutes."
    },
    "durationMinutes": {
      "type": "integer",
      "enum": [
        60,
        90,
        120
      ],
      "description": "How long the organiser booked the court, in minutes. The calendar invitation ends here too."
    },
    "tz": {
      "type": "string"
    },
    "venue": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "slug": {
          "type": [
            "string",
            "null"
          ]
        },
        "mapUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "court": {
          "type": [
            "string",
            "null"
          ]
        },
        "boardUrl": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "capacity": {
      "type": "integer"
    },
    "players": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "level": {
            "type": [
              "number",
              "null"
            ]
          },
          "organizer": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "joined",
              "confirmed",
              "invited"
            ]
          }
        }
      }
    },
    "spotsLeft": {
      "type": "integer"
    },
    "waitlist": {
      "type": "integer"
    },
    "whenFull": {
      "type": "string",
      "enum": [
        "waitlist",
        "closed"
      ]
    },
    "level": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "min": {
          "type": [
            "number",
            "null"
          ]
        },
        "max": {
          "type": [
            "number",
            "null"
          ]
        },
        "preset": {
          "type": [
            "string",
            "null"
          ],
          "description": "bronze, silver, gold, platinum or custom"
        },
        "verifiedOnly": {
          "type": "boolean",
          "description": "Only levels confirmed by an organizer, a coach or the club walk in; declared levels inside the range ask to join."
        }
      }
    },
    "category": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "men",
        "women",
        "mixed",
        null
      ],
      "description": "Who the match is for; null for anyone. Information only: nobody is checked when they join."
    },
    "ageMin": {
      "type": [
        "integer",
        "null"
      ],
      "enum": [
        35,
        45,
        55,
        null
      ],
      "description": "An age tag, read as 35+, 45+ or 55+; null for any age. Information only."
    },
    "group": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "url": {
          "type": "string"
        }
      }
    },
    "listed": {
      "type": "boolean"
    },
    "bookingUrl": {
      "type": [
        "string",
        "null"
      ]
    },
    "courtBooked": {
      "type": [
        "object",
        "null"
      ],
      "description": "A player booked the court in the club's own app and said so. Null while not booked and on a cancelled match. Kicksmash never books or takes a payment.",
      "properties": {
        "at": {
          "type": "string",
          "format": "date-time"
        },
        "by": {
          "type": [
            "string",
            "null"
          ],
          "description": "The booker's first name; null when the booker no longer holds a seat or their account is gone."
        }
      }
    },
    "cost": {
      "type": [
        "string",
        "null"
      ],
      "description": "What each player pays, free text."
    },
    "note": {
      "type": [
        "string",
        "null"
      ]
    },
    "result": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "sets": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "a": {
                "type": "integer"
              },
              "b": {
                "type": "integer"
              }
            }
          }
        },
        "teamA": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "teamB": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "winner": {
          "type": "string",
          "enum": [
            "a",
            "b",
            "draw"
          ],
          "description": "Sets can be empty when only the winner was recorded."
        },
        "confirmed": {
          "type": "boolean"
        }
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "code",
    "url",
    "type",
    "status",
    "startsAt",
    "tz",
    "capacity",
    "players",
    "spotsLeft"
  ]
}