{
  "openapi": "3.1.0",
  "info": {
    "title": "Storyboard Mixer API",
    "version": "1.0.0",
    "summary": "Storyboards (SMX v1), shares, server-side exports, prompt-target registry and media.",
    "description": "The HTTP API behind https://stories.neenhouse.com. Every document is an **SMX v1** storyboard\n(JSON Schema: https://stories.neenhouse.com/schema/storyboard/v1.json); field names are camelCase and enum ids lower_snake_case.\n\n## Authentication\n\n- **Browser session**: the `__Host-session` cookie set by `/api/auth/login`. Every state-changing request\n  (POST, PUT, PATCH, DELETE under `/api/`) must also echo the `__csrf` cookie in an `X-CSRF-Token` header.\n  Stateless exports (`POST /api/v1/export/{exporterId}`) sent without a session cookie need no `X-CSRF-Token`\n  (there are no ambient credentials to forge), and `/mcp` never does (it ignores cookies); a cross-origin\n  `Origin` is refused either way.\n- **Personal access token** (scripts and agents): `Authorization: Bearer smx_…`, created in\n  Account → Developer tokens. Bearer requests skip the CSRF check. Tokens carry scopes (read, write, export, generate);\n  over `/mcp`, private-board tools need `read` and `create_storyboard` needs `generate`.\n- Public endpoints (shares, share exports, registries, media) need no credentials.\n\n## Errors\n\nEvery non-2xx JSON response is an `ApiError` `{ error, code, requestId, retryAfterSec?, issues? }`:\n`error` is safe to show to people, `code` is stable for programs, and `issues` lists validation\nproblems as JSON pointers into the request body. `requestId` matches the `X-Request-ID` header.\n\n| code | status |\n| --- | --- |\n| invalid_request | 400 (415 for an unsupported upload type) |\n| unauthorized | 401 |\n| forbidden, cross_origin, csrf_invalid | 403 |\n| not_found | 404 |\n| method_not_allowed | 405 |\n| conflict | 409 |\n| gone | 410 |\n| precondition_failed | 412 |\n| payload_too_large | 413 |\n| content_blocked | 422 |\n| rate_limited, daily_quota | 429 (with Retry-After) |\n| internal | 500 |\n| not_implemented | 501 (an exporter that is not available yet) |\n| upstream | 502 |\n| capacity | 503 |\n\n## Rate limits\n\nPer client IP, fixed one-minute windows: all of `/api/*` 60/min; creating shares 10/min; review actions\n30/min; stateless exports 30/min; asset uploads 20/min; `/mcp` 120 JSON-RPC messages/min (a batch counts\nevery message; `create_storyboard` 5/min).\nDaily cost quotas apply to generation, rendering and exports, per account (its sessions and all of its\npersonal access tokens share one allowance) or per anonymous client: 429 `daily_quota` with `bucket` and Retry-After until midnight UTC, or 503 `capacity`\nwhen the service-wide daily cap is reached. `/media/*` is never limited.\n\n## Caching\n\nSaved boards carry `ETag: \"<sha256 of the doc>\"`: send it back as `If-Match` on PUT for optimistic\nconcurrency (412 on conflict) and as `If-None-Match` on GET for 304s. Share reads and exports are\ndeterministic for a given doc and options (`ctx.now` is the doc’s `project.updatedAt`), so their ETags\nare stable too. Media under `/media/` is immutable and cached for a year by clients; the edge keeps a copy for\nat most 10 minutes, so deleted or revoked media stops being served within that time.\n\n## Exports\n\nServer exports run the same exporter functions as the web app’s Export menu, so a file exported here is\nbyte-identical to the one the UI produces for the same doc and context. The server context is\n`{ now: doc.project.updatedAt, baseUrl: <origin>, assetRef: \"absolute\" | \"package\", fps?, startTimecode?, target?,\ngenerator: { name: \"Storyboard Mixer\", version: \"api-v1+renderer.<RENDERER_VERSION>\" } }`. Exporters that are\nnot implemented yet (`available: false` in /api/v1/exporters) answer 501. `package-zip` reads media from\nstorage (never from URLs) and falls back to **manifest mode** (a JSON file list with absolute URLs) when a\nboard has more than 40 assets or more than 32 MB of them, building takes longer than 5 s, or `?mode=manifest` is\nasked for. A fallback manifest is sent with `Cache-Control: no-store` and no ETag (the ETag names the ZIP); a\nrequested manifest is cacheable. `startTimecode` must exist at the export rate (`fps`, else `delivery.fps`, with\n`delivery.dropFrame`); otherwise the export is a 400. Public share exports, share reads and the registries send\n`Access-Control-Allow-Origin: *` on every response (errors included) and answer CORS preflights.\n\n## Agents (MCP)\n\n`POST /mcp` is a stateless MCP server (Streamable HTTP, JSON responses) exposing the same operations as tools.\nAdd it to an MCP client as `https://stories.neenhouse.com/mcp`; send a personal access token for private boards.",
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://stories.neenhouse.com"
    }
  ],
  "tags": [
    {
      "name": "Storyboards",
      "description": "Saved boards (owner-scoped)."
    },
    {
      "name": "Shares",
      "description": "Immutable published snapshots and review links."
    },
    {
      "name": "Export",
      "description": "Server-side exports through the same exporters the UI uses."
    },
    {
      "name": "Registries",
      "description": "Prompt targets, exporters and the schema identity."
    },
    {
      "name": "Media",
      "description": "Uploads and immutable media."
    },
    {
      "name": "Generation",
      "description": "Workers AI generation (Workers AI only, no third-party keys)."
    },
    {
      "name": "Platform",
      "description": "Health and agents."
    },
    {
      "name": "Legacy",
      "description": "Pre-SMX routes kept as shims for one release."
    }
  ],
  "paths": {
    "/api/v1/storyboards": {
      "get": {
        "tags": ["Storyboards"],
        "operationId": "listStoryboards",
        "summary": "List your storyboards",
        "description": "Newest first, keyset-paginated. Pass `nextCursor` back as `cursor`.",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Cursor"
          },
          {
            "$ref": "#/components/parameters/Limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoryboardList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/storyboards/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/StoryboardId"
        }
      ],
      "get": {
        "tags": ["Storyboards"],
        "operationId": "getStoryboard",
        "summary": "Get a storyboard",
        "description": "The canonical doc. Another account’s board is a 404.",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The SMX v1 doc",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoryboardDoc"
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/NotModified"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "put": {
        "tags": ["Storyboards"],
        "operationId": "putStoryboard",
        "summary": "Create or replace a storyboard",
        "description": "The body is the SMX v1 doc; `project.id` must equal `{id}` (a client-generated `sb_…` id becomes the primary key). Validation is strict (unknown fields and vocabulary aliases are rejected), then the doc is normalized (numbering, defaults). Referenced `tmp/` media is copied to the board’s permanent `boards/{id}/assets/` prefix and the returned doc carries the rewritten URLs. Reviewer decisions are stored separately and are never overwritten by a save. Limits: 1.5 MB per doc, no `data:` URIs, 200 boards per account.",
        "security": [
          {
            "cookieSession": [],
            "csrfToken": []
          },
          {
            "bearerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfMatch"
          },
          {
            "$ref": "#/components/parameters/IfNoneMatchCreate"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoryboardDoc"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replaced",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaveStoryboardResponse"
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SaveStoryboardResponse"
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Location": {
                "$ref": "#/components/headers/Location"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "412": {
            "$ref": "#/components/responses/PreconditionFailed"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "tags": ["Storyboards"],
        "operationId": "deleteStoryboard",
        "summary": "Delete a storyboard",
        "description": "Purges the board’s media, revokes and deletes its shares and their reviews.",
        "security": [
          {
            "cookieSession": [],
            "csrfToken": []
          },
          {
            "bearerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteStoryboardResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/storyboards/{id}/export/{exporterId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/StoryboardId"
        },
        {
          "$ref": "#/components/parameters/ExporterId"
        }
      ],
      "get": {
        "tags": ["Export"],
        "operationId": "exportStoryboard",
        "summary": "Export a saved storyboard",
        "description": "Owner only. Reviewer decisions are merged into `shots[].review` before exporting.",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/ExportTarget"
          },
          {
            "$ref": "#/components/parameters/ExportFps"
          },
          {
            "$ref": "#/components/parameters/ExportAssetRef"
          },
          {
            "$ref": "#/components/parameters/ExportStartTimecode"
          },
          {
            "$ref": "#/components/parameters/ExportMode"
          },
          {
            "$ref": "#/components/parameters/IfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The exported file (Content-Disposition attachment). For package-zip the server may answer in manifest mode instead (JSON, `X-SMX-Package-Mode: manifest`).",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Content-Disposition": {
                "$ref": "#/components/headers/ContentDisposition"
              },
              "X-SMX-Warnings": {
                "$ref": "#/components/headers/ExportWarnings"
              },
              "X-SMX-Package-Mode": {
                "$ref": "#/components/headers/PackageMode"
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PackageManifest"
                    },
                    {
                      "type": "object"
                    }
                  ]
                }
              },
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/NotModified"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "501": {
            "$ref": "#/components/responses/NotImplemented"
          }
        }
      }
    },
    "/api/v1/storyboards/{id}/reviews": {
      "parameters": [
        {
          "$ref": "#/components/parameters/StoryboardId"
        }
      ],
      "get": {
        "tags": ["Shares"],
        "operationId": "listStoryboardReviews",
        "summary": "Latest review per shot",
        "description": "The newest reviewer action per shot across every review link of the board. Owner only.",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BoardReviews"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/shares": {
      "post": {
        "tags": ["Shares"],
        "operationId": "createShare",
        "summary": "Publish a share",
        "description": "Publishes an immutable snapshot under a 128-bit id. `{storyboardId}` (owner, signed in) shares a saved board; republishing the same board and mode returns 200 with the same `shareId` and a new `revision`. `{doc}` works for anyone: its media is copied under `anon/{shareId}/`, the share expires after 90 days, and a `creatorToken` is returned once (send it as `X-Creator-Token` to revoke). `mode: \"review\"` creates a review link (`url` ends in `&review=1`).",
        "security": [
          {},
          {
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ShareCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Republished (owner, same share id, new revision)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShareResponse"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShareResponse"
                }
              }
            },
            "headers": {
              "Location": {
                "$ref": "#/components/headers/Location"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/shares/{shareId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ShareId"
        }
      ],
      "get": {
        "tags": ["Shares"],
        "operationId": "getShare",
        "summary": "Read a share",
        "description": "The shared SMX v1 doc. Share metadata is in the response headers. Legacy 8-hex share ids are upgraded on read.",
        "security": [{}],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The shared doc",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoryboardDoc"
                }
              }
            },
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Last-Modified": {
                "$ref": "#/components/headers/LastModified"
              },
              "X-Share-Revision": {
                "$ref": "#/components/headers/ShareRevision"
              },
              "X-Share-Mode": {
                "$ref": "#/components/headers/ShareMode"
              },
              "X-Share-Published-At": {
                "$ref": "#/components/headers/SharePublishedAt"
              },
              "X-Share-Expires-At": {
                "$ref": "#/components/headers/ShareExpiresAt"
              },
              "X-Share-Legacy": {
                "$ref": "#/components/headers/ShareLegacy"
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/NotModified"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          }
        }
      },
      "delete": {
        "tags": ["Shares"],
        "operationId": "revokeShare",
        "summary": "Revoke a share",
        "description": "The owner (session or token) or the anonymous creator (`X-Creator-Token`). Later reads get 410.",
        "security": [
          {
            "cookieSession": [],
            "csrfToken": []
          },
          {
            "bearerToken": []
          },
          {
            "creatorToken": [],
            "csrfToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RevokeShareResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/shares/{shareId}/export/{exporterId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ShareId"
        },
        {
          "$ref": "#/components/parameters/ExporterId"
        }
      ],
      "get": {
        "tags": ["Export"],
        "operationId": "exportShare",
        "summary": "Export a share",
        "description": "Public, CORS-enabled. Exports the immutable snapshot (reviewer actions are not included).",
        "security": [{}],
        "parameters": [
          {
            "$ref": "#/components/parameters/ExportTarget"
          },
          {
            "$ref": "#/components/parameters/ExportFps"
          },
          {
            "$ref": "#/components/parameters/ExportAssetRef"
          },
          {
            "$ref": "#/components/parameters/ExportStartTimecode"
          },
          {
            "$ref": "#/components/parameters/ExportMode"
          },
          {
            "$ref": "#/components/parameters/IfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "The exported file (Content-Disposition attachment). For package-zip the server may answer in manifest mode instead (JSON, `X-SMX-Package-Mode: manifest`).",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Content-Disposition": {
                "$ref": "#/components/headers/ContentDisposition"
              },
              "X-SMX-Warnings": {
                "$ref": "#/components/headers/ExportWarnings"
              },
              "X-SMX-Package-Mode": {
                "$ref": "#/components/headers/PackageMode"
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PackageManifest"
                    },
                    {
                      "type": "object"
                    }
                  ]
                }
              },
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/NotModified"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "501": {
            "$ref": "#/components/responses/NotImplemented"
          }
        }
      }
    },
    "/api/v1/shares/{shareId}/reviews": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ShareId"
        }
      ],
      "post": {
        "tags": ["Shares"],
        "operationId": "createReview",
        "summary": "Review a shot",
        "description": "Anonymous reviewers act on review links only (`mode: \"review\"`); view links answer 403.",
        "security": [
          {},
          {
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReviewCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Recorded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReviewCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "get": {
        "tags": ["Shares"],
        "operationId": "listShareReviews",
        "summary": "Latest review per shot of a share",
        "description": "For the share’s owner (session or token) or its anonymous creator (`X-Creator-Token`).",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerToken": []
          },
          {
            "creatorToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShareReviews"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/v1/export/{exporterId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ExporterId"
        }
      ],
      "post": {
        "tags": ["Export"],
        "operationId": "exportDoc",
        "summary": "Convert a posted doc",
        "description": "Stateless conversion for unsaved docs: nothing is stored. At most 1 MB, no `data:` URIs; legacy shapes are upgraded. Media for package-zip is read from storage by URL key, never fetched.",
        "security": [{}],
        "parameters": [
          {
            "$ref": "#/components/parameters/ExportTarget"
          },
          {
            "$ref": "#/components/parameters/ExportFps"
          },
          {
            "$ref": "#/components/parameters/ExportAssetRef"
          },
          {
            "$ref": "#/components/parameters/ExportStartTimecode"
          },
          {
            "$ref": "#/components/parameters/ExportMode"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoryboardDoc"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The exported file (Content-Disposition attachment). For package-zip the server may answer in manifest mode instead (JSON, `X-SMX-Package-Mode: manifest`).",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              },
              "Content-Disposition": {
                "$ref": "#/components/headers/ContentDisposition"
              },
              "X-SMX-Warnings": {
                "$ref": "#/components/headers/ExportWarnings"
              },
              "X-SMX-Package-Mode": {
                "$ref": "#/components/headers/PackageMode"
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PackageManifest"
                    },
                    {
                      "type": "object"
                    }
                  ]
                }
              },
              "application/xml": {
                "schema": {
                  "type": "string"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "501": {
            "$ref": "#/components/responses/NotImplemented"
          }
        }
      }
    },
    "/api/v1/targets": {
      "get": {
        "tags": ["Registries"],
        "operationId": "listTargets",
        "summary": "Prompt-target registry",
        "description": "Dated registry of video and image model targets (public, cacheable, CORS).",
        "security": [{}],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TargetsResponse"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/NotModified"
          }
        }
      }
    },
    "/api/v1/exporters": {
      "get": {
        "tags": ["Registries"],
        "operationId": "listExporters",
        "summary": "Exporter registry",
        "description": "`available: false` marks formats whose export routes still answer 501.",
        "security": [{}],
        "parameters": [
          {
            "name": "available",
            "in": "query",
            "description": "`1` lists only implemented exporters.",
            "schema": {
              "type": "string",
              "enum": ["1", "true"]
            }
          },
          {
            "$ref": "#/components/parameters/IfNoneMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExportersResponse"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/NotModified"
          }
        }
      }
    },
    "/api/v1/schema": {
      "get": {
        "tags": ["Registries"],
        "operationId": "getSchemaInfo",
        "summary": "Schema identity",
        "security": [{}],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SchemaInfo"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/assets": {
      "post": {
        "tags": ["Media"],
        "operationId": "uploadAsset",
        "summary": "Upload a reference image",
        "description": "JPEG, PNG or WebP up to 4 MB, checked by magic bytes and container structure (SVG, GIF and polyglots are rejected with 415). Stored under `tmp/{docId}/` and copied to the board on save.",
        "security": [
          {},
          {
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/AssetUpload"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssetUploadResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "415": {
            "$ref": "#/components/responses/UnsupportedMediaType"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/shots/render": {
      "post": {
        "tags": ["Generation"],
        "operationId": "renderShot",
        "summary": "Re-render one shot’s keyframe",
        "description": "Renders the prompt server-side from canonical fields (client prompt text is never trusted) and returns a new panel asset under `tmp/{docId}/`.",
        "security": [
          {},
          {
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderShotRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RenderShotResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "422": {
            "$ref": "#/components/responses/ContentBlocked"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/Upstream"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/characters/portrait": {
      "post": {
        "tags": ["Generation"],
        "operationId": "renderPortrait",
        "summary": "Generate a character reference portrait",
        "security": [
          {},
          {
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PortraitRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PortraitResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "422": {
            "$ref": "#/components/responses/ContentBlocked"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/Upstream"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/generate": {
      "post": {
        "tags": ["Generation"],
        "operationId": "generate",
        "summary": "Generate a storyboard (single response)",
        "security": [
          {},
          {
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "422": {
            "$ref": "#/components/responses/ContentBlocked"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "$ref": "#/components/responses/Upstream"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/generate-stream": {
      "post": {
        "tags": ["Generation"],
        "operationId": "generateStream",
        "summary": "Generate a storyboard (server-sent events)",
        "description": "Streams `GenerateEvent`s as SSE (`event: <type>` + JSON `data:`): status/plan first, then character, asset, shot and panel events as work completes, then exactly one terminal `complete` or `error`. `plan` can arrive more than once: first with the title, logline and cast (scenes may be empty), then again as each scene closes, always before any `shot` of that scene. Each `plan` is a snapshot of the bible without shots, assets or character reference ids, so keep what earlier `character`, `asset` and `shot` events delivered.",
        "security": [
          {},
          {
            "csrfToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "An SSE stream of GenerateEvent",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "x-sse-event-schema": {
                  "$ref": "#/components/schemas/GenerateEvent"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/health": {
      "get": {
        "tags": ["Platform"],
        "operationId": "health",
        "summary": "Health check",
        "security": [{}],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "503": {
            "description": "Degraded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    },
    "/media/{key}": {
      "parameters": [
        {
          "name": "key",
          "in": "path",
          "required": true,
          "description": "An allow-listed media key: `tmp/{docId}/{assetId}.{ext}`, `boards/{docId}/assets/{assetId}.{ext}`, `anon/{shareId}/{assetId}.{ext}` or legacy `storyboards/{requestId}/scene-{n}.{png|jpg}` (slashes included).",
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "tags": ["Media"],
        "operationId": "getMedia",
        "summary": "Immutable media",
        "description": "Bytes from storage with the sniffed content type, `Cache-Control: public, max-age=31536000, immutable`, ETag (304) and byte ranges (206). Anything that is not an allow-listed key is a 404.",
        "security": [{}],
        "parameters": [
          {
            "$ref": "#/components/parameters/IfNoneMatch"
          },
          {
            "name": "Range",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The media bytes",
            "headers": {
              "ETag": {
                "$ref": "#/components/headers/ETag"
              }
            },
            "content": {
              "image/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "206": {
            "description": "A byte range",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/NotModified"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "tags": ["Platform"],
        "operationId": "mcp",
        "summary": "Remote MCP server (stateless Streamable HTTP)",
        "description": "JSON-RPC 2.0: `initialize`, `ping`, `tools/list`, `tools/call`; notifications get 202. No sessions and no server stream (GET/DELETE are 405). Tools: `list_targets`, `list_exporters`, `get_storyboard` (`{id}` or `{shareId}`), `get_share`, `export_storyboard`, `render_prompts`, `plan_generation`, `validate_storyboard`, `create_storyboard` (generates and saves to the token owner's account; `generate_storyboard` is accepted as an alias). Cookies are ignored; private boards and `create_storyboard` need `Authorization: Bearer smx_…`. Rate limits count every JSON-RPC message (a batch of 20 costs 20). Cross-origin browser requests are refused.",
        "security": [
          {},
          {
            "bearerToken": []
          }
        ],
        "parameters": [
          {
            "name": "MCP-Protocol-Version",
            "in": "header",
            "schema": {
              "type": "string",
              "enum": ["2025-11-25", "2025-06-18", "2025-03-26"]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/JsonRpcRequest"
                  },
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/JsonRpcRequest"
                    },
                    "maxItems": 20
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/JsonRpcResponse"
                    },
                    {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/JsonRpcResponse"
                      }
                    }
                  ]
                }
              }
            }
          },
          "202": {
            "description": "Accepted (notifications only)"
          },
          "400": {
            "description": "Parse error or unsupported protocol version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "403": {
            "description": "Cross-origin request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "415": {
            "description": "Not application/json",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/storyboards/{shareId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ShareId"
        }
      ],
      "get": {
        "tags": ["Legacy"],
        "operationId": "legacyGetShare",
        "summary": "Read a share in the pre-SMX shape",
        "deprecated": true,
        "description": "Use GET /api/v1/shares/{shareId}. Removed in the next release.",
        "security": [{}],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyShare"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          }
        }
      }
    },
    "/api/user/storyboards": {
      "get": {
        "tags": ["Legacy"],
        "operationId": "legacyListStoryboards",
        "summary": "List storyboards (page/limit)",
        "deprecated": true,
        "description": "Use GET /api/v1/storyboards.",
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerToken": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": ["Legacy"],
        "operationId": "legacySaveStoryboard",
        "summary": "Save a storyboard (pre-SMX fields)",
        "deprecated": true,
        "description": "Use PUT /api/v1/storyboards/{id}. A body `id` you own is replaced instead of duplicated.",
        "security": [
          {
            "cookieSession": [],
            "csrfToken": []
          },
          {
            "bearerToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replaced",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          }
        }
      }
    },
    "/api/user/storyboards/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/StoryboardId"
        }
      ],
      "get": {
        "tags": ["Legacy"],
        "operationId": "legacyGetStoryboard",
        "summary": "Get a storyboard (pre-SMX shape)",
        "deprecated": true,
        "security": [
          {
            "cookieSession": []
          },
          {
            "bearerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "put": {
        "tags": ["Legacy"],
        "operationId": "legacyUpdateStoryboard",
        "summary": "Update a storyboard (pre-SMX fields)",
        "deprecated": true,
        "security": [
          {
            "cookieSession": [],
            "csrfToken": []
          },
          {
            "bearerToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "delete": {
        "tags": ["Legacy"],
        "operationId": "legacyDeleteStoryboard",
        "summary": "Delete a storyboard",
        "deprecated": true,
        "security": [
          {
            "cookieSession": [],
            "csrfToken": []
          },
          {
            "bearerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/api/images/{requestId}/{sceneNumber}": {
      "parameters": [
        {
          "name": "requestId",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "sceneNumber",
          "in": "path",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "get": {
        "tags": ["Legacy"],
        "operationId": "legacyGetImage",
        "summary": "Legacy scene image",
        "deprecated": true,
        "description": "Images referenced by pre-SMX shares. New docs use /media/{key}.",
        "security": [{}],
        "responses": {
          "200": {
            "description": "Image bytes",
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "304": {
            "$ref": "#/components/responses/NotModified"
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    }
  },
  "x-removed-endpoints": [
    {
      "endpoint": "/api/collab/*",
      "removed": "2026-11",
      "reason": "The KV collaboration backend was unauthenticated, trusted client-asserted identities, raced on KV read-modify-write and polled every 2 seconds; nothing used it.",
      "note": "If real-time collaboration is wanted later, rebuild it on Durable Objects with WebSocket hibernation (Workers platform), not on KV."
    },
    {
      "endpoint": "POST /api/storyboards",
      "removed": "2026-11",
      "reason": "Anonymous arbitrary R2 upload with guessable 32-bit share ids.",
      "note": "Publish with POST /api/v1/shares instead."
    }
  ],
  "components": {
    "securitySchemes": {
      "cookieSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "__Host-session",
        "description": "Browser session from /api/auth/login."
      },
      "csrfToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-CSRF-Token",
        "description": "Echo of the `__csrf` cookie; required with cookie auth on state-changing /api requests."
      },
      "bearerToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "smx_… personal access token",
        "description": "Scopes: read, write, export, generate. Skips the CSRF check."
      },
      "creatorToken": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Creator-Token",
        "description": "Returned once when an anonymous share is created."
      }
    },
    "parameters": {
      "StoryboardId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Board id (`sb_…`, or a legacy UUID).",
        "schema": {
          "type": "string",
          "maxLength": 64
        }
      },
      "ShareId": {
        "name": "shareId",
        "in": "path",
        "required": true,
        "description": "22-char base64url (128-bit) id, or a legacy 8-hex id.",
        "schema": {
          "type": "string",
          "pattern": "^([A-Za-z0-9_-]{22}|[0-9a-fA-F]{8})$"
        }
      },
      "ExporterId": {
        "name": "exporterId",
        "in": "path",
        "required": true,
        "description": "An id from GET /api/v1/exporters, e.g. shot-list-csv, fcpxml, package-zip.",
        "schema": {
          "type": "string"
        }
      },
      "ExportTarget": {
        "name": "target",
        "in": "query",
        "description": "Prompt target (or legacy alias) for generate-group exporters.",
        "schema": {
          "type": "string"
        }
      },
      "ExportFps": {
        "name": "fps",
        "in": "query",
        "description": "Override delivery.fps for timeline exports.",
        "schema": {
          "type": "number",
          "enum": [12, 15, 23.976, 24, 25, 29.97, 30, 50, 59.94, 60]
        }
      },
      "ExportAssetRef": {
        "name": "assetRef",
        "in": "query",
        "description": "`absolute` (default): asset URLs; `package`: ./images/… package paths.",
        "schema": {
          "type": "string",
          "enum": ["absolute", "package"],
          "default": "absolute"
        }
      },
      "ExportStartTimecode": {
        "name": "startTimecode",
        "in": "query",
        "description": "Override delivery.startTimecode, e.g. 01:00:00:00.",
        "schema": {
          "type": "string",
          "pattern": "^\\d{2}:\\d{2}:\\d{2}[:;]\\d{2}$"
        }
      },
      "ExportMode": {
        "name": "mode",
        "in": "query",
        "description": "package-zip only: `manifest` returns the file list instead of a ZIP.",
        "schema": {
          "type": "string",
          "enum": ["zip", "manifest"]
        }
      },
      "IfMatch": {
        "name": "If-Match",
        "in": "header",
        "description": "The ETag you loaded; a mismatch is 412.",
        "schema": {
          "type": "string"
        }
      },
      "IfNoneMatch": {
        "name": "If-None-Match",
        "in": "header",
        "description": "A cached ETag; a match is 304.",
        "schema": {
          "type": "string"
        }
      },
      "IfNoneMatchCreate": {
        "name": "If-None-Match",
        "in": "header",
        "description": "`*` = create only (412 if the board exists).",
        "schema": {
          "type": "string",
          "enum": ["*"]
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "description": "`nextCursor` from the previous page.",
        "schema": {
          "type": "string"
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 24
        }
      }
    },
    "headers": {
      "ETag": {
        "description": "Strong entity tag.",
        "schema": {
          "type": "string"
        }
      },
      "Location": {
        "schema": {
          "type": "string"
        }
      },
      "LastModified": {
        "schema": {
          "type": "string"
        }
      },
      "ContentDisposition": {
        "description": "attachment; filename=\"…\"; filename*=UTF-8''…",
        "schema": {
          "type": "string"
        }
      },
      "ExportWarnings": {
        "description": "Number of exporter warnings.",
        "schema": {
          "type": "integer"
        }
      },
      "PackageMode": {
        "description": "package-zip only: `zip` or `manifest`.",
        "schema": {
          "type": "string",
          "enum": ["zip", "manifest"]
        }
      },
      "ShareRevision": {
        "schema": {
          "type": "integer"
        }
      },
      "ShareMode": {
        "schema": {
          "type": "string",
          "enum": ["view", "review"]
        }
      },
      "SharePublishedAt": {
        "schema": {
          "type": "string",
          "format": "date-time"
        }
      },
      "ShareExpiresAt": {
        "schema": {
          "type": "string",
          "format": "date-time"
        }
      },
      "ShareLegacy": {
        "description": "`1` for a legacy 8-hex share upgraded on read.",
        "schema": {
          "type": "string"
        }
      },
      "RetryAfter": {
        "description": "Seconds to wait.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "NotModified": {
        "description": "Not modified (If-None-Match matched)."
      },
      "BadRequest": {
        "description": "invalid_request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "unauthorized: sign in or send a Bearer token",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "Forbidden": {
        "description": "forbidden / cross_origin / csrf_invalid",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "NotFound": {
        "description": "not_found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "Conflict": {
        "description": "conflict",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "Gone": {
        "description": "gone: the share was revoked or has expired",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "PreconditionFailed": {
        "description": "precondition_failed: the ETag no longer matches",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "PayloadTooLarge": {
        "description": "payload_too_large",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "UnsupportedMediaType": {
        "description": "invalid_request (unsupported type)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "ContentBlocked": {
        "description": "content_blocked",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "RateLimited": {
        "description": "rate_limited / daily_quota",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        }
      },
      "Internal": {
        "description": "internal",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "NotImplemented": {
        "description": "not_implemented: this exporter is not available yet",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "Upstream": {
        "description": "upstream",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        }
      },
      "Unavailable": {
        "description": "capacity",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ApiError"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        }
      }
    },
    "schemas": {
      "StoryboardDoc": {
        "$ref": "https://stories.neenhouse.com/schema/storyboard/v1.json",
        "description": "An SMX v1 storyboard document."
      },
      "Asset": {
        "$ref": "https://stories.neenhouse.com/schema/storyboard/v1.json#/$defs/Asset"
      },
      "Shot": {
        "$ref": "https://stories.neenhouse.com/schema/storyboard/v1.json#/$defs/Shot"
      },
      "Panel": {
        "$ref": "https://stories.neenhouse.com/schema/storyboard/v1.json#/$defs/Panel"
      },
      "Character": {
        "$ref": "https://stories.neenhouse.com/schema/storyboard/v1.json#/$defs/Character"
      },
      "Location": {
        "$ref": "https://stories.neenhouse.com/schema/storyboard/v1.json#/$defs/Location"
      },
      "Style": {
        "$ref": "https://stories.neenhouse.com/schema/storyboard/v1.json#/$defs/Style"
      },
      "Delivery": {
        "$ref": "https://stories.neenhouse.com/schema/storyboard/v1.json#/$defs/Delivery"
      },
      "ApiError": {
        "type": "object",
        "required": ["error", "code", "requestId"],
        "properties": {
          "error": {
            "type": "string",
            "description": "Safe, user-facing message."
          },
          "code": {
            "type": "string",
            "enum": [
              "invalid_request",
              "unauthorized",
              "forbidden",
              "cross_origin",
              "csrf_invalid",
              "not_found",
              "method_not_allowed",
              "conflict",
              "precondition_failed",
              "gone",
              "payload_too_large",
              "content_blocked",
              "rate_limited",
              "daily_quota",
              "capacity",
              "upstream",
              "not_implemented",
              "internal"
            ]
          },
          "requestId": {
            "type": "string"
          },
          "retryAfterSec": {
            "type": "integer"
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["path", "message"],
              "properties": {
                "path": {
                  "type": "string",
                  "description": "JSON pointer into the request body."
                },
                "message": {
                  "type": "string"
                }
              }
            }
          },
          "bucket": {
            "type": "string",
            "description": "`daily_quota` only: the quota bucket (generate, render or export)."
          },
          "limit": {
            "type": "integer",
            "description": "`daily_quota` only: the bucket's daily limit for this subject."
          }
        }
      },
      "StoryboardSummary": {
        "type": "object",
        "required": [
          "id",
          "title",
          "concept",
          "storyboardType",
          "shotCount",
          "thumbnailUrl",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "concept": {
            "type": "string"
          },
          "storyboardType": {
            "type": "string",
            "enum": [
              "film_storyboard",
              "shot_list",
              "animatic",
              "av_script",
              "commercial_board",
              "social_vertical",
              "music_video",
              "explainer",
              "product_demo",
              "trailer",
              "beat_sheet",
              "comic_4panel"
            ]
          },
          "shotCount": {
            "type": "integer"
          },
          "thumbnailUrl": {
            "type": ["string", "null"]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "StoryboardList": {
        "type": "object",
        "required": ["storyboards", "total", "nextCursor"],
        "properties": {
          "storyboards": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoryboardSummary"
            }
          },
          "total": {
            "type": "integer"
          },
          "nextCursor": {
            "type": ["string", "null"]
          }
        }
      },
      "SaveStoryboardResponse": {
        "type": "object",
        "required": ["id", "etag", "doc", "warnings"],
        "properties": {
          "id": {
            "type": "string"
          },
          "etag": {
            "type": "string"
          },
          "doc": {
            "$ref": "#/components/schemas/StoryboardDoc"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "e.g. a tmp/ image that had already expired."
          }
        }
      },
      "DeleteStoryboardResponse": {
        "type": "object",
        "required": ["id", "deleted"],
        "properties": {
          "id": {
            "type": "string"
          },
          "deleted": {
            "const": true
          },
          "purgedObjects": {
            "type": "integer"
          },
          "deletedShares": {
            "type": "integer"
          }
        }
      },
      "ShareCreate": {
        "oneOf": [
          {
            "type": "object",
            "required": ["doc"],
            "additionalProperties": false,
            "properties": {
              "doc": {
                "$ref": "#/components/schemas/StoryboardDoc"
              },
              "mode": {
                "type": "string",
                "enum": ["view", "review"]
              }
            }
          },
          {
            "type": "object",
            "required": ["storyboardId"],
            "additionalProperties": false,
            "properties": {
              "storyboardId": {
                "type": "string"
              },
              "mode": {
                "type": "string",
                "enum": ["view", "review"]
              }
            }
          }
        ]
      },
      "ShareResponse": {
        "type": "object",
        "required": ["shareId", "url", "revision", "mode"],
        "properties": {
          "shareId": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "Relative app URL: /?s=… (review links add &review=1)."
          },
          "creatorToken": {
            "type": "string",
            "description": "Anonymous shares only; returned once."
          },
          "revision": {
            "type": "integer"
          },
          "mode": {
            "type": "string",
            "enum": ["view", "review"]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "RevokeShareResponse": {
        "type": "object",
        "required": ["shareId", "revokedAt"],
        "properties": {
          "shareId": {
            "type": "string"
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ReviewCreate": {
        "type": "object",
        "required": ["shotId", "status"],
        "properties": {
          "shotId": {
            "type": "string",
            "description": "Immutable shot id (sh_…)."
          },
          "status": {
            "type": "string",
            "enum": ["pending", "approved", "changes_requested", "rejected"]
          },
          "comment": {
            "type": "string",
            "maxLength": 2000
          },
          "reviewerName": {
            "type": "string",
            "maxLength": 80
          }
        }
      },
      "ShotReview": {
        "type": "object",
        "required": ["id", "shareId", "shotId", "status", "at"],
        "properties": {
          "id": {
            "type": "string"
          },
          "shareId": {
            "type": "string"
          },
          "shotId": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["pending", "approved", "changes_requested", "rejected"]
          },
          "comment": {
            "type": "string"
          },
          "reviewerName": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ReviewCreated": {
        "type": "object",
        "required": ["review"],
        "properties": {
          "review": {
            "$ref": "#/components/schemas/ShotReview"
          }
        }
      },
      "BoardReviews": {
        "type": "object",
        "required": ["storyboardId", "reviews"],
        "properties": {
          "storyboardId": {
            "type": "string"
          },
          "reviews": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ShotReview"
            }
          }
        }
      },
      "ShareReviews": {
        "type": "object",
        "required": ["shareId", "reviews"],
        "properties": {
          "shareId": {
            "type": "string"
          },
          "reviews": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ShotReview"
            }
          }
        }
      },
      "PackageManifest": {
        "type": "object",
        "required": ["mode", "reason", "filename", "schema", "files", "exports"],
        "description": "package-zip manifest mode: fetch each file and assemble the package script-side.",
        "properties": {
          "mode": {
            "const": "manifest"
          },
          "reason": {
            "type": "string"
          },
          "filename": {
            "type": "string"
          },
          "schema": {
            "type": "string"
          },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["path", "url", "mediaType", "assetId"],
              "properties": {
                "path": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "mediaType": {
                  "type": "string"
                },
                "bytes": {
                  "type": "integer"
                },
                "assetId": {
                  "type": "string"
                }
              }
            }
          },
          "exports": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["exporterId", "label", "url"],
              "properties": {
                "exporterId": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ExporterMeta": {
        "type": "object",
        "required": [
          "id",
          "label",
          "group",
          "ext",
          "mediaType",
          "needsAssetBytes",
          "description",
          "consumers",
          "available"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "group": {
            "type": "string",
            "enum": [
              "data",
              "script",
              "shotlist",
              "edit",
              "captions",
              "generate",
              "pipeline",
              "package"
            ]
          },
          "ext": {
            "type": "string"
          },
          "mediaType": {
            "type": "string"
          },
          "needsAssetBytes": {
            "type": "boolean"
          },
          "description": {
            "type": "string"
          },
          "consumers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "available": {
            "type": "boolean"
          }
        }
      },
      "ExportersResponse": {
        "type": "object",
        "required": ["exporters"],
        "properties": {
          "exporters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExporterMeta"
            }
          }
        }
      },
      "TargetSpec": {
        "type": "object",
        "required": ["id", "label", "family", "kind", "status", "lastVerified", "aliases"],
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "family": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "lastVerified": {
            "type": "string",
            "format": "date"
          },
          "aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "durations": {
            "type": "object"
          },
          "aspect": {
            "type": "object"
          },
          "supports": {
            "type": "object"
          }
        }
      },
      "TargetsResponse": {
        "type": "object",
        "required": [
          "rendererVersion",
          "defaultTarget",
          "defaultKeyframeTarget",
          "aliases",
          "targets"
        ],
        "properties": {
          "rendererVersion": {
            "type": "string"
          },
          "defaultTarget": {
            "type": "string"
          },
          "defaultKeyframeTarget": {
            "type": "string"
          },
          "aliases": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "targets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TargetSpec"
            }
          }
        }
      },
      "SchemaInfo": {
        "type": "object",
        "required": [
          "name",
          "schemaVersion",
          "schemaId",
          "pinnedSchemaUrl",
          "generationTask",
          "rendererVersion"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "schemaVersion": {
            "type": "string"
          },
          "schemaId": {
            "type": "string"
          },
          "pinnedSchemaUrl": {
            "type": "string"
          },
          "generationTask": {
            "type": "object",
            "properties": {
              "schemaVersion": {
                "type": "string"
              },
              "schemaId": {
                "type": "string"
              },
              "pinnedSchemaUrl": {
                "type": "string"
              }
            }
          },
          "rendererVersion": {
            "type": "string"
          }
        }
      },
      "AssetUpload": {
        "type": "object",
        "required": ["file", "docId", "role"],
        "properties": {
          "file": {
            "type": "string",
            "format": "binary",
            "description": "JPEG, PNG or WebP, at most 4 MB."
          },
          "docId": {
            "type": "string",
            "description": "The board the reference belongs to."
          },
          "role": {
            "type": "string",
            "enum": [
              "face_reference",
              "full_body_reference",
              "character_sheet",
              "style_reference",
              "location_plate",
              "prop_reference",
              "other"
            ]
          }
        }
      },
      "AssetUploadResponse": {
        "type": "object",
        "required": ["asset", "requestId"],
        "properties": {
          "asset": {
            "$ref": "#/components/schemas/Asset"
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "GenerateRequest": {
        "type": "object",
        "required": ["aspectRatio", "stylePresetId"],
        "additionalProperties": false,
        "description": "Either `idea` or `script` is required.",
        "properties": {
          "idea": {
            "type": "string",
            "maxLength": 2000
          },
          "script": {
            "type": "object",
            "description": "Screenplay breakdown (Fountain/FDX import): { title?, scenes: [{ heading, number?, action, dialogue[] }] }."
          },
          "storyboardType": {
            "type": "string",
            "enum": [
              "film_storyboard",
              "shot_list",
              "animatic",
              "av_script",
              "commercial_board",
              "social_vertical",
              "music_video",
              "explainer",
              "product_demo",
              "trailer",
              "beat_sheet",
              "comic_4panel"
            ]
          },
          "framework": {
            "type": "string",
            "pattern": "^[a-z0-9_]{2,40}$"
          },
          "aspectRatio": {
            "type": "string",
            "enum": ["16:9", "9:16", "1:1", "4:5", "2.39:1"]
          },
          "targetDurationSec": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 600
          },
          "shotCount": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12
          },
          "stylePresetId": {
            "type": "string"
          },
          "styleOverrides": {
            "type": "object",
            "properties": {
              "styleLine": {
                "type": "string",
                "maxLength": 300
              },
              "palette": {
                "type": "array",
                "maxItems": 8
              },
              "lighting": {
                "type": "string",
                "maxLength": 300
              },
              "exclusions": {
                "type": "array",
                "maxItems": 8,
                "items": {
                  "type": "string",
                  "maxLength": 40
                }
              }
            }
          },
          "targets": {
            "type": "array",
            "maxItems": 16,
            "items": {
              "type": "string"
            }
          },
          "format": {
            "type": "string",
            "deprecated": true,
            "description": "Legacy alias of targets[0]."
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4294967295
          },
          "quality": {
            "type": "string",
            "enum": ["draft", "hq"]
          },
          "docId": {
            "type": "string",
            "description": "Client-generated sb_… id to use as project.id."
          }
        }
      },
      "GenerateResponse": {
        "type": "object",
        "required": ["doc", "degraded", "warnings", "requestId"],
        "properties": {
          "doc": {
            "$ref": "#/components/schemas/StoryboardDoc"
          },
          "degraded": {
            "type": "boolean"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requestId": {
            "type": "string"
          },
          "servedBy": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "image": {
                "type": "string"
              }
            }
          },
          "scenes": {
            "type": "array",
            "deprecated": true,
            "description": "Legacy view; removed next release."
          }
        }
      },
      "GenerateEvent": {
        "type": "object",
        "required": ["type"],
        "description": "One SSE event. `type` is status | plan | character | asset | shot | panel | complete | error; see shared/storyboard/api-types.ts for each payload.",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["status", "plan", "character", "asset", "shot", "panel", "complete", "error"]
          }
        },
        "additionalProperties": true
      },
      "RenderShotRequest": {
        "type": "object",
        "required": ["docId", "shot", "characters", "locations", "delivery"],
        "properties": {
          "docId": {
            "type": "string"
          },
          "shot": {
            "$ref": "#/components/schemas/Shot"
          },
          "characters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Character"
            },
            "maxItems": 50
          },
          "locations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Location"
            },
            "maxItems": 50
          },
          "style": {
            "$ref": "#/components/schemas/Style"
          },
          "delivery": {
            "$ref": "#/components/schemas/Delivery"
          },
          "seed": {
            "type": "integer"
          },
          "editInstruction": {
            "type": "string",
            "maxLength": 500
          },
          "referenceAssetIds": {
            "type": "array",
            "maxItems": 4,
            "items": {
              "type": "string"
            }
          },
          "sourceAsset": {
            "$ref": "#/components/schemas/Asset"
          },
          "quality": {
            "type": "string",
            "enum": ["draft", "hq"]
          }
        }
      },
      "RenderShotResponse": {
        "type": "object",
        "required": ["asset", "panel", "renderedPrompt", "requestId"],
        "properties": {
          "asset": {
            "$ref": "#/components/schemas/Asset"
          },
          "panel": {
            "$ref": "#/components/schemas/Panel"
          },
          "renderedPrompt": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          },
          "degraded": {
            "type": "boolean"
          }
        }
      },
      "PortraitRequest": {
        "type": "object",
        "required": ["docId", "character"],
        "properties": {
          "docId": {
            "type": "string"
          },
          "character": {
            "$ref": "#/components/schemas/Character"
          },
          "style": {
            "$ref": "#/components/schemas/Style"
          },
          "seed": {
            "type": "integer"
          },
          "quality": {
            "type": "string",
            "enum": ["draft", "hq"]
          }
        }
      },
      "PortraitResponse": {
        "type": "object",
        "required": ["asset", "requestId"],
        "properties": {
          "asset": {
            "$ref": "#/components/schemas/Asset"
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "Health": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "status": {
            "type": "string"
          }
        }
      },
      "LegacyShare": {
        "type": "object",
        "description": "The pre-SMX share shape (toLegacyShare).",
        "additionalProperties": true,
        "properties": {
          "shareId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "idea": {
            "type": "string"
          },
          "format": {
            "type": "string"
          },
          "aspectRatio": {
            "type": "string"
          },
          "createdAt": {
            "type": "integer"
          },
          "scenes": {
            "type": "array"
          }
        }
      },
      "JsonRpcRequest": {
        "type": "object",
        "required": ["jsonrpc", "method"],
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {
            "type": ["string", "integer"]
          },
          "method": {
            "type": "string"
          },
          "params": {
            "type": "object"
          }
        }
      },
      "JsonRpcResponse": {
        "type": "object",
        "required": ["jsonrpc", "id"],
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {
            "type": ["string", "integer", "null"]
          },
          "result": {},
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              },
              "data": {}
            }
          }
        }
      }
    }
  }
}
