{
  "openapi": "3.1.1",
  "info": {
    "title": "Booklet Maker (Saddle-Stitch Imposition) API",
    "version": "1.0.0",
    "summary": "Fold-and-staple booklets: notebook or calendar pages imposed in the right order.",
    "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://printshopbooklet.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Fold-and-staple booklets: notebook or calendar pages imposed in the right order.",
        "description": "Make a saddle-stitched booklet: pages of grid, dot or lined paper (a notebook) or a month-per-page calendar are padded to a multiple of four and printed two per sheet side in booklet order, with optional creep compensation, page numbers and fold marks. Prints double-sided, flip on the short edge.\n\nMethodology:\n- Pages are padded with blanks to a multiple of four. Sheet k (from the outside) carries pages (n − 2k, 2k + 1) on the front and (2k + 2, n − 2k − 1) on the back — Panelcraft’s booklet order; right-edge binding swaps each pair.\n- Each page is scaled uniformly into half of the landscape sheet and centred; with creep compensation the pages of sheet k move k × creep towards the fold, because inner sheets stick out further after folding.\n- The PDF alternates front and back of each sheet: print double-sided, flipping on the short edge, then fold the stack and staple along the fold.\n\nDuplex settings differ between printers: print the first sheet and check the page order before printing all.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "printshop_booklet",
        "x-owner-app": "printshop",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PrintshopBookletInput"
              },
              "examples": {
                "example1": {
                  "summary": "16-page dot-grid pocket notebook",
                  "value": {
                    "source": "ruled",
                    "pages": 16,
                    "kind": "dots"
                  }
                },
                "example2": {
                  "summary": "2027 pocket calendar (12 months, 3 sheets)",
                  "value": {
                    "source": "calendar",
                    "year": 2027
                  }
                },
                "example3": {
                  "summary": "Right-bound 8-page lined booklet with creep",
                  "value": {
                    "source": "ruled",
                    "pages": 8,
                    "kind": "lined",
                    "spacing": 7,
                    "reading": "rtl",
                    "creep": 0.1
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrintshopBookletResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "PrintshopBookletInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "source": {
            "title": "Booklet pages",
            "type": "string",
            "enum": [
              "ruled",
              "calendar"
            ],
            "default": "ruled"
          },
          "pages": {
            "title": "Notebook pages",
            "type": "integer",
            "minimum": 1,
            "maximum": 200,
            "default": 16
          },
          "kind": {
            "title": "Notebook paper type",
            "type": "string",
            "enum": [
              "grid",
              "dots",
              "isometric",
              "hex",
              "music",
              "lined"
            ],
            "default": "dots"
          },
          "spacing": {
            "title": "Notebook spacing (mm)",
            "type": "number",
            "minimum": 1,
            "maximum": 50,
            "default": 5
          },
          "year": {
            "title": "Calendar year",
            "type": "integer",
            "minimum": 1900,
            "maximum": 2200,
            "default": 2027
          },
          "startMonth": {
            "title": "Calendar first month",
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "default": 1
          },
          "lang": {
            "title": "Calendar language",
            "type": "string",
            "enum": [
              "en",
              "de",
              "fr",
              "es",
              "it",
              "pt",
              "nl",
              "pl",
              "tr",
              "ru",
              "uk",
              "ar",
              "hi",
              "zh",
              "ja",
              "ko",
              "id"
            ],
            "default": "en"
          },
          "paper": {
            "title": "Sheet size (folded in half)",
            "type": "string",
            "enum": [
              "a3",
              "a4",
              "a5",
              "a6",
              "b5",
              "letter",
              "legal",
              "tabloid",
              "halfletter"
            ],
            "default": "a4"
          },
          "reading": {
            "title": "Binding",
            "type": "string",
            "enum": [
              "ltr",
              "rtl"
            ],
            "default": "ltr"
          },
          "creep": {
            "title": "Creep compensation (mm per sheet)",
            "description": "About the paper thickness (0.1 mm for 80 g/m²) for thick booklets.",
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 0
          },
          "pageNumbers": {
            "title": "Page numbers",
            "type": "boolean",
            "default": true
          }
        },
        "required": []
      },
      "PrintshopBookletResult": {
        "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": [
              "bookletPages",
              "sheets",
              "blankPages",
              "order",
              "pages",
              "pageWidthMm",
              "pageHeightMm",
              "warnings",
              "files",
              "openInApp"
            ],
            "properties": {
              "bookletPages": {
                "type": "integer"
              },
              "sheets": {
                "type": "integer"
              },
              "blankPages": {
                "type": "integer"
              },
              "order": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "sheet",
                    "front",
                    "back"
                  ],
                  "properties": {
                    "sheet": {
                      "type": "integer"
                    },
                    "front": {
                      "type": "array",
                      "items": {
                        "type": [
                          "integer",
                          "null"
                        ]
                      }
                    },
                    "back": {
                      "type": "array",
                      "items": {
                        "type": [
                          "integer",
                          "null"
                        ]
                      }
                    }
                  }
                }
              },
              "pages": {
                "type": "integer"
              },
              "pageWidthMm": {
                "type": "number"
              },
              "pageHeightMm": {
                "type": "number"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "files": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "pdf",
                  "svg",
                  "png"
                ],
                "properties": {
                  "pdf": {
                    "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)."
                      }
                    }
                  },
                  "svg": {
                    "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)."
                      }
                    }
                  },
                  "png": {
                    "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"
              }
            }
          }
        }
      }
    }
  }
}