{
  "openapi": "3.1.1",
  "info": {
    "title": "Writing Rhythm API",
    "version": "1.0.0",
    "summary": "See sentence lengths, paragraph pacing and differences between two drafts.",
    "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://paperwellwritingrhythm.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "See sentence lengths, paragraph pacing and differences between two drafts.",
        "description": "Explore sentence and paragraph pacing with language-aware boundaries, source spans, distributions and a measured comparison with a second draft.\n\nMethodology:\n- Intl.Segmenter uses the selected language for sentence boundaries; line breaks remain explicit boundaries. Unicode word tokens, exact source offsets and paragraph membership are retained.\n- Charts cover the complete draft and use the full word-count scale. Longer drafts group consecutive sentences and show the minimum, maximum and mean; individual ranges remain available in the browser. Modeled reading time uses your chosen words per minute. Lengths and distributions support editing decisions; they are not a writing-quality score. Ambiguous abbreviations can still need human review.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "paperwell_writing_rhythm",
        "x-owner-app": "paperwell",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaperwellWritingRhythmInput"
              },
              "examples": {
                "example1": {
                  "summary": "Try an example",
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaperwellWritingRhythmResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "PaperwellWritingRhythmInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text": {
            "title": "Draft",
            "type": "string",
            "maxLength": 100000,
            "default": "Short sentence. This sentence takes a little longer to reach its end."
          },
          "compare": {
            "title": "Second draft (optional)",
            "type": "string",
            "maxLength": 100000,
            "default": ""
          },
          "locale": {
            "title": "Analysis language",
            "type": "string",
            "enum": [
              "en",
              "de",
              "fr",
              "es",
              "it",
              "pt"
            ],
            "default": "en"
          },
          "wpm": {
            "title": "Modeled reading speed (words/minute)",
            "type": "number",
            "minimum": 80,
            "maximum": 500,
            "default": 220
          }
        },
        "required": []
      },
      "PaperwellWritingRhythmResult": {
        "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": [
              "sentences",
              "words",
              "meanWords",
              "paragraphs",
              "distribution",
              "medianWords",
              "longestWords",
              "variation",
              "readingSeconds",
              "svg",
              "secondDraft",
              "comparison"
            ],
            "properties": {
              "sentences": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "index",
                    "start",
                    "end",
                    "text",
                    "words",
                    "paragraph"
                  ],
                  "properties": {
                    "index": {
                      "type": "number"
                    },
                    "start": {
                      "type": "number"
                    },
                    "end": {
                      "type": "number"
                    },
                    "text": {
                      "type": "string"
                    },
                    "words": {
                      "type": "number"
                    },
                    "paragraph": {
                      "type": "number"
                    }
                  }
                }
              },
              "words": {
                "type": "number"
              },
              "meanWords": {
                "type": "number"
              },
              "paragraphs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "paragraph",
                    "sentences",
                    "words"
                  ],
                  "properties": {
                    "paragraph": {
                      "type": "number"
                    },
                    "sentences": {
                      "type": "number"
                    },
                    "words": {
                      "type": "number"
                    }
                  }
                }
              },
              "distribution": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "range",
                    "sentences"
                  ],
                  "properties": {
                    "range": {
                      "type": "string"
                    },
                    "sentences": {
                      "type": "number"
                    }
                  }
                }
              },
              "medianWords": {
                "type": "number"
              },
              "longestWords": {
                "type": "number"
              },
              "variation": {
                "type": "number"
              },
              "readingSeconds": {
                "type": "number"
              },
              "svg": {
                "type": "string"
              },
              "secondDraft": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "sentences",
                  "words",
                  "meanWords",
                  "paragraphs",
                  "distribution",
                  "medianWords",
                  "longestWords",
                  "variation",
                  "readingSeconds",
                  "svg"
                ],
                "properties": {
                  "sentences": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "index",
                        "start",
                        "end",
                        "text",
                        "words",
                        "paragraph"
                      ],
                      "properties": {
                        "index": {
                          "type": "number"
                        },
                        "start": {
                          "type": "number"
                        },
                        "end": {
                          "type": "number"
                        },
                        "text": {
                          "type": "string"
                        },
                        "words": {
                          "type": "number"
                        },
                        "paragraph": {
                          "type": "number"
                        }
                      }
                    }
                  },
                  "words": {
                    "type": "number"
                  },
                  "meanWords": {
                    "type": "number"
                  },
                  "paragraphs": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "paragraph",
                        "sentences",
                        "words"
                      ],
                      "properties": {
                        "paragraph": {
                          "type": "number"
                        },
                        "sentences": {
                          "type": "number"
                        },
                        "words": {
                          "type": "number"
                        }
                      }
                    }
                  },
                  "distribution": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "range",
                        "sentences"
                      ],
                      "properties": {
                        "range": {
                          "type": "string"
                        },
                        "sentences": {
                          "type": "number"
                        }
                      }
                    }
                  },
                  "medianWords": {
                    "type": "number"
                  },
                  "longestWords": {
                    "type": "number"
                  },
                  "variation": {
                    "type": "number"
                  },
                  "readingSeconds": {
                    "type": "number"
                  },
                  "svg": {
                    "type": "string"
                  }
                }
              },
              "comparison": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "words",
                  "meanWords",
                  "sentences",
                  "wordDelta",
                  "meanDelta"
                ],
                "properties": {
                  "words": {
                    "type": "number"
                  },
                  "meanWords": {
                    "type": "number"
                  },
                  "sentences": {
                    "type": "number"
                  },
                  "wordDelta": {
                    "type": "number"
                  },
                  "meanDelta": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}