{
  "openapi": "3.1.1",
  "info": {
    "title": "Comic Page & Lettering Planner API",
    "version": "1.0.0",
    "summary": "Plan comic panels, reading order and dialogue in an editable page.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://fliplinecomicpage.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Plan comic panels, reading order and dialogue in an editable page.",
        "description": "Create a comic page from a grid and one dialogue line per panel. Choose reading direction and print resolution, add optional rough figures, and download an SVG, lettering CSV and editable Flipline Comic Desk project.\n\nMethodology:\n- Comic pages are 400–2400 px wide, 400–4000 px high and at most 6 megapixels. A grid contains 1–12 panels and a page supports 36 balloons. Reading order follows spatial rows, left-to-right or right-to-left.\n- One input line creates one speech balloon in reading order. Wrapping estimates system sans-serif widths and reduces lettering to fit, down to 12 px. Overflow is rejected for tool exports; original text remains in the editable project. Review glyph layout before printing.\n- SVG dimensions use millimetres = pixels / DPI × 25.4. Lettering CSV follows reading order and guards formula-like leading characters. Optional figures are authored geometric staging, not generated illustrations.\n\nIndependent page-layout tool. No MediBang project import, CMYK conversion or exact font-metric guarantee.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "flipline_comic_page",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FliplineComicPageInput"
              },
              "examples": {
                "example1": {
                  "summary": "Four panels and a small discovery",
                  "value": {}
                },
                "example2": {
                  "summary": "A right-to-left conversation",
                  "value": {
                    "reading": "rtl",
                    "rows": 1,
                    "columns": 2,
                    "dialogue": "Did you see it?\nThere, by the window."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FliplineComicPageResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "FliplineComicPageInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "title": "Comic page name",
            "type": "string",
            "maxLength": 120,
            "default": "A small discovery"
          },
          "dialogue": {
            "title": "Dialogue lines in reading order",
            "type": "string",
            "maxLength": 8000,
            "default": "What is that light?\nA little farther…\nWe found a new way.\nLet us draw it."
          },
          "rows": {
            "title": "Panel rows",
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "default": 2
          },
          "columns": {
            "title": "Panel columns",
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "default": 2
          },
          "width": {
            "title": "Page width (px)",
            "type": "integer",
            "minimum": 400,
            "maximum": 2400,
            "default": 1000
          },
          "height": {
            "title": "Page height (px)",
            "type": "integer",
            "minimum": 400,
            "maximum": 4000,
            "default": 1400
          },
          "dpi": {
            "title": "Page resolution (DPI)",
            "type": "integer",
            "minimum": 72,
            "maximum": 600,
            "default": 150
          },
          "reading": {
            "title": "Panel reading direction",
            "type": "string",
            "enum": [
              "ltr",
              "rtl"
            ],
            "default": "ltr"
          },
          "figures": {
            "title": "Include rough staging figures",
            "type": "boolean",
            "default": true
          }
        },
        "required": []
      },
      "FliplineComicPageResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "project",
              "report",
              "pageSvg",
              "projectFile",
              "letteringCsv",
              "openInApp"
            ],
            "properties": {
              "project": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "format",
                  "version",
                  "name",
                  "width",
                  "height",
                  "dpi",
                  "margin",
                  "gutter",
                  "border",
                  "paper",
                  "reading",
                  "panels",
                  "balloons",
                  "artwork"
                ],
                "properties": {
                  "format": {
                    "const": "flipline-comic"
                  },
                  "version": {
                    "const": 1
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "width": {
                    "type": "integer",
                    "minimum": 400,
                    "maximum": 2400
                  },
                  "height": {
                    "type": "integer",
                    "minimum": 400,
                    "maximum": 4000
                  },
                  "dpi": {
                    "type": "integer",
                    "minimum": 72,
                    "maximum": 600
                  },
                  "margin": {
                    "type": "number"
                  },
                  "gutter": {
                    "type": "number"
                  },
                  "border": {
                    "type": "number"
                  },
                  "paper": {
                    "type": "string"
                  },
                  "reading": {
                    "enum": [
                      "ltr",
                      "rtl"
                    ]
                  },
                  "panels": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 12,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "name",
                        "x",
                        "y",
                        "width",
                        "height",
                        "paper",
                        "fit",
                        "zoom",
                        "panX",
                        "panY",
                        "sourceWidth",
                        "sourceHeight",
                        "tone"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "maxLength": 64
                        },
                        "name": {
                          "type": "string",
                          "maxLength": 80
                        },
                        "x": {
                          "type": "number"
                        },
                        "y": {
                          "type": "number"
                        },
                        "width": {
                          "type": "number"
                        },
                        "height": {
                          "type": "number"
                        },
                        "paper": {
                          "type": "string"
                        },
                        "fit": {
                          "enum": [
                            "contain",
                            "cover"
                          ]
                        },
                        "zoom": {
                          "type": "number"
                        },
                        "panX": {
                          "type": "number"
                        },
                        "panY": {
                          "type": "number"
                        },
                        "sourceWidth": {
                          "type": "integer"
                        },
                        "sourceHeight": {
                          "type": "integer"
                        },
                        "tone": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "kind",
                            "pitch",
                            "coverage",
                            "angle",
                            "ink",
                            "over"
                          ],
                          "properties": {
                            "kind": {
                              "enum": [
                                "none",
                                "dots",
                                "lines",
                                "crosshatch"
                              ]
                            },
                            "pitch": {
                              "type": "number",
                              "minimum": 4,
                              "maximum": 80
                            },
                            "coverage": {
                              "type": "number",
                              "minimum": 0.05,
                              "maximum": 0.75
                            },
                            "angle": {
                              "type": "number",
                              "minimum": -90,
                              "maximum": 90
                            },
                            "ink": {
                              "type": "string",
                              "pattern": "^#[a-fA-F0-9]{6}$"
                            },
                            "over": {
                              "type": "boolean"
                            }
                          }
                        }
                      }
                    }
                  },
                  "balloons": {
                    "type": "array",
                    "maxItems": 36,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "panel",
                        "kind",
                        "x",
                        "y",
                        "width",
                        "height",
                        "tailX",
                        "tailY",
                        "text",
                        "fontSize",
                        "ink",
                        "paper"
                      ],
                      "properties": {
                        "id": {
                          "type": "string",
                          "maxLength": 64
                        },
                        "panel": {
                          "type": "string",
                          "maxLength": 64
                        },
                        "kind": {
                          "enum": [
                            "speech",
                            "thought",
                            "caption"
                          ]
                        },
                        "x": {
                          "type": "number"
                        },
                        "y": {
                          "type": "number"
                        },
                        "width": {
                          "type": "number"
                        },
                        "height": {
                          "type": "number"
                        },
                        "tailX": {
                          "type": "number"
                        },
                        "tailY": {
                          "type": "number"
                        },
                        "text": {
                          "type": "string",
                          "maxLength": 600
                        },
                        "fontSize": {
                          "type": "number"
                        },
                        "ink": {
                          "type": "string"
                        },
                        "paper": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "artwork": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "format",
                      "version",
                      "name",
                      "width",
                      "height",
                      "fps",
                      "paper",
                      "boards"
                    ],
                    "properties": {
                      "format": {
                        "const": "flipline-story"
                      },
                      "version": {
                        "const": 1
                      },
                      "name": {
                        "type": "string",
                        "maxLength": 120
                      },
                      "width": {
                        "type": "integer",
                        "minimum": 32,
                        "maximum": 1600
                      },
                      "height": {
                        "type": "integer",
                        "minimum": 32,
                        "maximum": 1600
                      },
                      "fps": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 30
                      },
                      "paper": {
                        "type": "string",
                        "pattern": "^#[a-fA-F0-9]{6}$"
                      },
                      "boards": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 48,
                        "items": {
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "id",
                            "title",
                            "scene",
                            "shot",
                            "camera",
                            "frames",
                            "action",
                            "dialogue",
                            "notes",
                            "locked",
                            "marks",
                            "reference"
                          ],
                          "properties": {
                            "id": {
                              "type": "string",
                              "pattern": "^[-a-zA-Z0-9_]{1,80}$"
                            },
                            "title": {
                              "type": "string",
                              "maxLength": 80
                            },
                            "scene": {
                              "type": "string",
                              "maxLength": 80
                            },
                            "shot": {
                              "enum": [
                                "wide",
                                "medium",
                                "close",
                                "detail",
                                "over-shoulder"
                              ]
                            },
                            "camera": {
                              "enum": [
                                "static",
                                "pan-left",
                                "pan-right",
                                "tilt-up",
                                "tilt-down",
                                "push-in",
                                "pull-out",
                                "handheld"
                              ]
                            },
                            "frames": {
                              "type": "integer",
                              "minimum": 1,
                              "maximum": 3600
                            },
                            "action": {
                              "type": "string",
                              "maxLength": 1200
                            },
                            "dialogue": {
                              "type": "string",
                              "maxLength": 1200
                            },
                            "notes": {
                              "type": "string",
                              "maxLength": 1200
                            },
                            "locked": {
                              "type": "boolean"
                            },
                            "marks": {
                              "type": "array",
                              "maxItems": 500,
                              "items": {
                                "type": "object",
                                "additionalProperties": false,
                                "required": [
                                  "id",
                                  "kind",
                                  "points",
                                  "color",
                                  "size",
                                  "fill"
                                ],
                                "properties": {
                                  "brush": {
                                    "type": "object",
                                    "additionalProperties": false,
                                    "required": [
                                      "kind",
                                      "opacity",
                                      "flow",
                                      "spacing",
                                      "texture",
                                      "pressure",
                                      "seed"
                                    ],
                                    "properties": {
                                      "kind": {
                                        "enum": [
                                          "ink",
                                          "pencil",
                                          "marker",
                                          "wash",
                                          "airbrush"
                                        ]
                                      },
                                      "opacity": {
                                        "type": "number",
                                        "minimum": 0,
                                        "maximum": 1
                                      },
                                      "flow": {
                                        "type": "number",
                                        "minimum": 0,
                                        "maximum": 1
                                      },
                                      "spacing": {
                                        "type": "number",
                                        "minimum": 0.08,
                                        "maximum": 1
                                      },
                                      "texture": {
                                        "type": "number",
                                        "minimum": 0,
                                        "maximum": 1
                                      },
                                      "pressure": {
                                        "type": "boolean"
                                      },
                                      "seed": {
                                        "type": "integer",
                                        "minimum": 0,
                                        "maximum": 4294967295
                                      }
                                    }
                                  },
                                  "pressures": {
                                    "type": "array",
                                    "minItems": 1,
                                    "maxItems": 4096,
                                    "items": {
                                      "type": "number",
                                      "minimum": 0,
                                      "maximum": 1
                                    }
                                  },
                                  "id": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 80
                                  },
                                  "kind": {
                                    "enum": [
                                      "pen",
                                      "eraser",
                                      "line",
                                      "rect",
                                      "ellipse",
                                      "image"
                                    ]
                                  },
                                  "points": {
                                    "type": "array",
                                    "minItems": 1,
                                    "maxItems": 4096,
                                    "items": {
                                      "type": "array",
                                      "minItems": 2,
                                      "maxItems": 2,
                                      "items": {
                                        "type": "number",
                                        "minimum": 0,
                                        "maximum": 1
                                      }
                                    }
                                  },
                                  "color": {
                                    "type": "string",
                                    "pattern": "^#[a-fA-F0-9]{6}$"
                                  },
                                  "size": {
                                    "type": "number",
                                    "minimum": 1,
                                    "maximum": 100
                                  },
                                  "fill": {
                                    "type": "boolean"
                                  },
                                  "source": {
                                    "type": "string",
                                    "pattern": "^data:image/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$"
                                  },
                                  "angle": {
                                    "type": "number",
                                    "minimum": -360,
                                    "maximum": 360,
                                    "description": "Clockwise rotation in degrees around the center of the mark bounds (normalized to -180…180)."
                                  },
                                  "flipX": {
                                    "type": "boolean",
                                    "description": "Mirror horizontally around the mark center."
                                  },
                                  "flipY": {
                                    "type": "boolean",
                                    "description": "Mirror vertically around the mark center."
                                  }
                                }
                              }
                            },
                            "reference": {
                              "type": [
                                "object",
                                "null"
                              ],
                              "additionalProperties": false,
                              "required": [
                                "source",
                                "opacity",
                                "visible"
                              ],
                              "properties": {
                                "source": {
                                  "type": "string",
                                  "pattern": "^data:image/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$"
                                },
                                "opacity": {
                                  "type": "number",
                                  "minimum": 0,
                                  "maximum": 1
                                },
                                "visible": {
                                  "type": "boolean"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "description": "Story Desk. Frame-based board durations, half-open timeline intervals and non-drop-frame timecodes. Up to 600 seconds total and 120 seconds per board at the chosen FPS. Canvas up to 2 MP, 50000 points, 2000 marks and 6 million source-image characters across all boards. Ink erasers affect preceding ink only; the independent reference is preserved. Camera moves are planning labels, not animated camera paths."
                  }
                },
                "description": "Comic Desk page. At most 6 MP, 12 panels and 36 balloons. Panel/artwork board IDs align by index. Shared Story Desk mark budgets apply; image marks are disallowed. PNG references match declared dimensions, at most 2 MP each and 8 MP total. All embedded references together fit 6 million characters. Text overflow is reported, never silently exported by the workspace."
              },
              "report": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "panels",
                  "balloons",
                  "widthMm",
                  "heightMm",
                  "pixels",
                  "readingOrder",
                  "overflow",
                  "toneLpi"
                ],
                "properties": {
                  "panels": {
                    "type": "integer"
                  },
                  "balloons": {
                    "type": "integer"
                  },
                  "widthMm": {
                    "type": "number"
                  },
                  "heightMm": {
                    "type": "number"
                  },
                  "pixels": {
                    "type": "integer"
                  },
                  "readingOrder": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "overflow": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "toneLpi": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "panel",
                        "linesPerInch"
                      ],
                      "properties": {
                        "panel": {
                          "type": "string"
                        },
                        "linesPerInch": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              },
              "pageSvg": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "projectFile": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "letteringCsv": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "openInApp": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}