openapi: 3.1.0
info:
  title: Bloop Scenes API
  description: >
    Create and fetch Bloop skit scenes. Open studioUrl to edit, or
    exportPngUrl / exportVideoUrl to trigger client-side export.
  version: 1.0.0
servers:
  - url: https://usebloop.studio
  - url: http://localhost:3000
paths:
  /api/scenes:
    post:
      operationId: createScene
      summary: Create a skit scene
      tags: [scenes]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "../schemas/bloop-scene.v1.json"
            example:
              version: 1
              template: imessage
              exportMode: device
              imessage:
                contactName: Alex
                bubbles:
                  - type: received
                    text: we need a skit by tonight
                  - type: sent
                    text: already drafting in Bloop
                    status: read
                    color: blue
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SceneCreated"
        "400":
          description: Invalid scene
        "429":
          description: Rate limited
        "503":
          description: KV not configured
  /api/scenes/{id}:
    get:
      operationId: getScene
      summary: Get a scene by id
      tags: [scenes]
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Scene
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/SceneFetched"
        "404":
          description: Not found
components:
  schemas:
    SceneCreated:
      type: object
      required: [ok, id, studioUrl, exportPngUrl, exportVideoUrl]
      properties:
        ok: { type: boolean, const: true }
        id: { type: string }
        studioUrl: { type: string, format: uri }
        exportPngUrl: { type: string, format: uri }
        exportVideoUrl: { type: string, format: uri }
        schema: { type: string }
    SceneFetched:
      allOf:
        - $ref: "#/components/schemas/SceneCreated"
        - type: object
          properties:
            createdAt: { type: string, format: date-time }
            scene:
              $ref: "../schemas/bloop-scene.v1.json"
