{
  "openapi": "3.1.0",
  "info": {
    "title": "Silent Groove booking API",
    "version": "1.0.0",
    "description": "Silent disco hire in Perth, Western Australia. Check availability and prices, and start bookings for customers. Starting a booking does not take payment or reserve equipment: it returns a paymentUrl that the customer opens in their own browser to check the details, agree to the booking terms and pay by card. Always confirm the details with the customer before starting a booking. Prices are in AUD and include GST."
  },
  "servers": [ { "url": "https://www.silentgroove.com.au" } ],
  "paths": {
    "/api/v1/info": {
      "get": {
        "operationId": "getBusinessInfo",
        "summary": "Business details, booking rules, pricing, event types and the extras that can be booked online",
        "responses": { "200": { "description": "Business information", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    },
    "/api/v1/dates": {
      "get": {
        "operationId": "getUnavailableDates",
        "summary": "The date range that can be booked online, and the dates in it that are booked out",
        "parameters": [
          { "name": "from", "in": "query", "required": false, "description": "First date to check (YYYY-MM-DD). Defaults to the earliest bookable date.", "schema": { "type": "string", "format": "date" } },
          { "name": "to", "in": "query", "required": false, "description": "Last date to check (YYYY-MM-DD). Defaults to the latest bookable date.", "schema": { "type": "string", "format": "date" } }
        ],
        "responses": {
          "200": {
            "description": "Bookable range and unavailable dates",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "earliestDate": { "type": "string", "format": "date" },
                "latestDate": { "type": "string", "format": "date" },
                "unavailableDates": { "type": "array", "items": { "type": "string", "format": "date" } }
              }
            } } }
          }
        }
      }
    },
    "/api/v1/quote": {
      "get": {
        "operationId": "getQuote",
        "summary": "Live availability and an itemised price for a silent disco hire on a date",
        "parameters": [
          { "name": "date", "in": "query", "required": true, "description": "Event date, YYYY-MM-DD.", "schema": { "type": "string", "format": "date" } },
          { "name": "headphones", "in": "query", "required": true, "description": "Number of headphones - usually one per guest. Minimum 10.", "schema": { "type": "integer", "minimum": 10 } },
          { "name": "extended", "in": "query", "required": false, "description": "Extended hire: two extra days for +50%.", "schema": { "type": "boolean" } },
          { "name": "battery", "in": "query", "required": false, "description": "Battery-powered transmitters + microphone instead of the standard mains-powered ones (for venues without power, walking tours, outdoors).", "schema": { "type": "boolean" } },
          { "name": "extras", "in": "query", "required": false, "description": "Extras as sku:quantity pairs separated by commas, e.g. dome:2,musicdevice:1. SKUs are listed by getBusinessInfo and in extrasAvailable.", "schema": { "type": "string" } },
          { "name": "type", "in": "query", "required": false, "description": "Event type.", "schema": { "type": "string", "enum": ["kids","house","school","vacation","sport","wedding","corporate","nightclub","festival","yoga","other"] } }
        ],
        "responses": {
          "200": { "description": "Quote. If available is false, problems explains why.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Quote" } } } },
          "400": { "description": "Invalid parameters", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/v1/bookings": {
      "post": {
        "operationId": "startBooking",
        "summary": "Start a booking and get the link the customer uses to pay",
        "description": "Only call this after the customer has confirmed the date, number of headphones, extras and their contact details. The booking is not confirmed and the equipment is not reserved until the customer pays at paymentUrl. Starting another booking for the same customer (email) and date replaces the earlier unpaid one, so only the latest paymentUrl works.",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/BookingRequest" } } }
        },
        "responses": {
          "201": { "description": "Booking started", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/BookingStarted" } } } },
          "400": { "description": "Missing or invalid details", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "409": { "description": "Not available as requested (date booked out, not enough headphones, extra unavailable)", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "description": "Too many requests", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LineItem": {
        "type": "object",
        "properties": {
          "sku": { "type": "string" },
          "name": { "type": "string" },
          "quantity": { "type": "integer" },
          "unitPrice": { "type": "number" },
          "amount": { "type": "number" }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "available": { "type": "boolean" },
          "problems": { "type": "array", "items": { "type": "string" } },
          "date": { "type": "string", "format": "date" },
          "headphones": { "type": "integer" },
          "extendedHire": { "type": "boolean" },
          "currency": { "type": "string" },
          "lineItems": { "type": "array", "items": { "$ref": "#/components/schemas/LineItem" } },
          "total": { "type": "number" },
          "minimumHireApplied": { "type": "boolean" },
          "headphonesAvailable": { "type": "integer" },
          "extrasAvailable": { "type": "array", "items": { "type": "object", "properties": { "sku": { "type": "string" }, "name": { "type": "string" }, "price": { "type": "number" }, "maxQuantity": { "type": "integer" } } } },
          "bookingLink": { "type": "string", "description": "Pre-filled booking page link - an alternative to startBooking, where the customer enters their own details." },
          "note": { "type": "string" }
        }
      },
      "BookingRequest": {
        "type": "object",
        "required": [ "date", "headphones", "type", "firstName", "lastName", "email", "phone", "address", "suburb", "postcode" ],
        "properties": {
          "date": { "type": "string", "format": "date", "description": "Event date, YYYY-MM-DD." },
          "headphones": { "type": "integer", "minimum": 10 },
          "type": { "type": "string", "enum": ["kids","house","school","vacation","sport","wedding","corporate","nightclub","festival","yoga","other"], "description": "Event type." },
          "extended": { "type": "boolean", "description": "Extended hire: two extra days for +50%." },
          "battery": { "type": "boolean", "description": "Battery-powered transmitters + microphone instead of mains-powered ones." },
          "extras": {
            "type": "array",
            "items": { "type": "object", "required": [ "sku", "quantity" ], "properties": { "sku": { "type": "string" }, "quantity": { "type": "integer", "minimum": 1 } } },
            "description": "Extras, e.g. [{\"sku\":\"dome\",\"quantity\":2}]. SKUs are listed by getBusinessInfo."
          },
          "firstName": { "type": "string" },
          "lastName": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "phone": { "type": "string", "description": "Australian phone number, 8 or 10 digits (mobile preferred)." },
          "address": { "type": "string", "description": "Customer's street address." },
          "suburb": { "type": "string" },
          "postcode": { "type": "string" },
          "comments": { "type": "string", "description": "Anything the customer wants us to know." },
          "ref": { "type": "string", "description": "Short name of your assistant or app, e.g. chatgpt." }
        }
      },
      "BookingStarted": {
        "type": "object",
        "properties": {
          "bookingReference": { "type": "string" },
          "status": { "type": "string", "description": "awaiting_payment" },
          "paymentUrl": { "type": "string", "description": "Give this to the customer. They review the booking, agree to the terms and pay by card, which confirms it." },
          "date": { "type": "string", "format": "date" },
          "headphones": { "type": "integer" },
          "lineItems": { "type": "array", "items": { "$ref": "#/components/schemas/LineItem" } },
          "total": { "type": "number" },
          "currency": { "type": "string" },
          "message": { "type": "string" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "error": { "type": "string" },
          "message": { "type": "string" }
        }
      }
    }
  }
}
