{
  "openapi": "3.1.0",
  "info": {
    "title": "Brunchie Booth API",
    "version": "v1",
    "summary": "Send photo booth and guestbook captures into a Brunchie event's shared album.",
    "description": "A single HTTP endpoint that ingests photos, videos, GIFs, photo strips, and voice memos into the live shared album of a Brunchie event.\n\nThere are two ways to send a capture:\n\n- **Direct file upload (recommended, no third-party host)** — POST the file bytes as `multipart/form-data`. Works with Breeze Booth, Darkroom Booth, Sparkbooth, an Apple Shortcuts folder-watch, a Raspberry Pi bridge, or any tool that can run an HTTP POST.\n- **URL fallback** — send a public URL and Brunchie downloads it. This is how native LumaBooth / dslrBooth webhooks work (they upload to their own cloud and emit a URL).\n\nCaptures land in the public shared album by default. A guest's scanned QR attributes the post to that guest; without a QR the post is authored by the event's booth service user."
  },
  "servers": [
    { "url": "https://brunchie.app", "description": "Production" }
  ],
  "security": [
    { "boothKey": [] }
  ],
  "tags": [
    { "name": "Booth", "description": "Ingest captures into an event's shared album." }
  ],
  "paths": {
    "/api/v1/webhooks/booth": {
      "post": {
        "tags": ["Booth"],
        "summary": "Send a capture to the shared album",
        "operationId": "createBoothCapture",
        "description": "Creates one album post from the uploaded file(s) and/or URL(s). Send the file bytes directly as `media` (recommended), or pass a public URL. Repeat `photos[]` to land a multi-frame strip as one swipeable post.",
        "parameters": [
          {
            "name": "event_id",
            "in": "query",
            "required": true,
            "description": "The event's share slug (from the host's **Connect a booth** screen). A numeric event id also works.",
            "schema": { "type": "string" },
            "example": "summer-wedding-a1b2c3d4"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "media": {
                    "description": "The capture — either an uploaded **file** (recommended) or a public **URL** string. Up to 50 MB for an image, 500 MB for a video.",
                    "oneOf": [
                      { "type": "string", "format": "binary" },
                      { "type": "string", "format": "uri" }
                    ]
                  },
                  "photos[]": {
                    "description": "Extra frames for a multi-shot strip (files or URLs). The whole set becomes one swipeable post.",
                    "type": "array",
                    "items": { "type": "string", "format": "binary" }
                  },
                  "audio": {
                    "description": "A voice memo — an uploaded file or a public URL. Up to 25 MB.",
                    "oneOf": [
                      { "type": "string", "format": "binary" },
                      { "type": "string", "format": "uri" }
                    ]
                  },
                  "qr": {
                    "description": "The guest's QR link or token, if your booth scans one. Attributes the post to that guest. Omit for an anonymous floor booth — the post is authored by the booth service user.",
                    "type": "string",
                    "example": "https://brunchie.app/qr/abc123def456"
                  },
                  "media_type": {
                    "description": "What kind of capture this is. A hint used for layout; Brunchie also infers it from the file.",
                    "type": "string",
                    "enum": ["image", "video", "boomerang", "audio", "strip"]
                  },
                  "message": {
                    "description": "An optional caption shown with the post.",
                    "type": "string"
                  },
                  "visibility": {
                    "description": "Who can see the post. Defaults to the public shared album. A guest who set their booth privacy to private always stays hosts-only regardless of this value.",
                    "type": "string",
                    "enum": ["public", "guests_cannot_edit", "hosts_only"],
                    "default": "public"
                  },
                  "client_id": {
                    "description": "A stable id for this capture. Send the same value on a retry and Brunchie returns the original post instead of creating a duplicate.",
                    "type": "string"
                  }
                }
              },
              "encoding": {
                "media": { "contentType": "image/jpeg, image/png, image/heic, video/mp4, application/octet-stream" }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Capture accepted. `deduped` is present when a `client_id` retry matched an existing post.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": true },
                    "post_id": { "type": "integer", "example": 84217 },
                    "deduped": { "type": "boolean", "example": true }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, wrong, expired, or rotated `X-Api-Token`. Grab the current event key from the host's Connect a booth screen.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "422": {
            "description": "The capture could not be saved (e.g. a file over the size cap).",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "boothKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Token",
        "description": "The event's booth key — a 7-day rotating secret the host copies from **Tools → Connect a booth**. NOT the share link."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean", "example": false },
          "errors": {
            "type": "array",
            "items": { "type": "string" },
            "example": ["File too large (max 50 MB)."]
          }
        }
      }
    }
  }
}
