{
  "openapi": "3.1.0",
  "info": {
    "title": "Places start",
    "version": "0.1.0",
    "description": "Start a volunteer community theatre ticketing account by naming the first production. Success is first tickets on sale, not a login."
  },
  "servers": [
    {
      "url": "https://joinplaces.app"
    }
  ],
  "paths": {
    "/api/start": {
      "post": {
        "operationId": "startTicketing",
        "summary": "Queue a first-show ticketing start",
        "description": "Requires a production title. organizationId in the body is invalid. Stripe KYC stays in a browser.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StartRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Queued. Next steps are on the payload.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StartResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing productionTitle or another required field."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "StartRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "email",
          "organizationName",
          "productionTitle"
        ],
        "not": {
          "anyOf": [
            {
              "required": [
                "organizationId"
              ]
            },
            {
              "required": [
                "organization_id"
              ]
            },
            {
              "required": [
                "orgId"
              ]
            }
          ]
        },
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "organizationName": {
            "type": "string",
            "maxLength": 200
          },
          "productionTitle": {
            "type": "string",
            "maxLength": 200
          },
          "firstPerformanceStartsAt": {
            "type": "string",
            "description": "Local datetime for the first performance. ISO-like."
          },
          "house": {
            "type": "string",
            "enum": [
              "general_admission",
              "reserved"
            ],
            "default": "general_admission"
          },
          "contactName": {
            "type": "string",
            "maxLength": 120
          }
        }
      },
      "StartResponse": {
        "type": "object",
        "required": [
          "ok",
          "goal",
          "status",
          "next"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "goal": {
            "type": "string",
            "const": "first_tickets_on_sale"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "closed"
            ]
          },
          "organizationName": {
            "type": "string"
          },
          "productionTitle": {
            "type": "string"
          },
          "house": {
            "type": "string"
          },
          "next": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "done",
                "human",
                "instruction"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "enum": [
                    "show",
                    "verify",
                    "stripe",
                    "share"
                  ]
                },
                "done": {
                  "type": "boolean"
                },
                "human": {
                  "type": "boolean"
                },
                "instruction": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}