{
  "openapi": "3.1.1",
  "info": {
    "title": "Before You Sign API",
    "version": "1.0.0",
    "summary": "Spot risky contract clauses (renewal, notice, liability, non-compete…) before you sign.",
    "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://beforeyousign.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Spot risky contract clauses (renewal, notice, liability, non-compete…) before you sign.",
        "description": "Paste, upload or link a contract, terms of service, lease or employment agreement in English or German. Before You Sign flags 19 kinds of clauses — auto-renewal, notice periods, minimum terms, termination fees, liability limits, indemnities, arbitration, non-competes, IP assignment, price escalation, penalties, guarantees, data sharing and unilateral changes — quotes each clause, extracts durations and amounts, and lists questions to ask.\n\nMethodology:\n- The contract is split into sentences (numbered clauses, bullets and § headings start new units).\n- Each sentence is tested against 19 clause categories, each with English and German regular-expression patterns (e.g. \"automatically renew\", \"verlängert sich stillschweigend\", \"Kündigungsfrist\", \"Vertragsstrafe\", \"hold harmless\").\n- Parameters are extracted from the matched sentence: durations (numbers or number words, incl. \"three months\"/\"drei Monate\"), percentages, money amounts, radius (km/miles), governing law and court venue.\n- Severity comes from a fixed, documented rule per category (e.g. notice period ≥ 3 months = high; non-compete ≥ 12 months or ≥ 50 km = high). It signals how much attention a clause deserves, not whether it is legal or enforceable.\n- Each category has fixed questions to ask before signing. Categories without any match are listed as \"not detected\" — absence of a match is not proof the clause is absent.\n\nNot legal advice. This is an automated, rule-based text analysis that can miss or misread clauses; it never claims completeness. For decisions with legal or financial consequences, ask a qualified professional (e.g. a lawyer, tax adviser or consumer advice centre).",
        "tags": [
          "high-value"
        ],
        "x-mcp-tool": "before_you_sign",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BeforeYouSignInput"
              },
              "examples": {
                "example1": {
                  "summary": "SaaS subscription terms (English)",
                  "value": {
                    "text": "1. Term. The initial term of this Agreement is 24 months. Thereafter, this Agreement shall automatically renew for successive 12-month periods unless either party provides at least 90 days' prior written notice of non-renewal.\n2. Fees. Provider may increase the fees at any time at its sole discretion. Overdue amounts bear interest at 1.5% per month.\n3. Early termination. If Customer terminates before the end of the initial term, all remaining fees for the term become immediately due.\n4. Liability. In no event shall Provider be liable for any indirect or consequential damages; Provider's aggregate liability is limited to the fees paid in the last 3 months.\n5. Customer shall indemnify and hold harmless Provider from any and all claims arising from Customer's use of the service.\n6. Disputes. Any dispute shall be resolved by binding arbitration, and Customer waives any right to participate in a class action. This Agreement is governed by the laws of the State of Delaware.\n7. Provider reserves the right to modify these terms at any time; continued use constitutes acceptance."
                  }
                },
                "example2": {
                  "summary": "Arbeitsvertrag mit Wettbewerbsverbot (Deutsch)",
                  "value": {
                    "text": "§ 2 Vertragsdauer\nDas Arbeitsverhältnis wird auf unbestimmte Zeit geschlossen. Die Kündigungsfrist beträgt drei Monate zum Quartalsende.\n§ 7 Wettbewerbsverbot\nDer Arbeitnehmer verpflichtet sich, für die Dauer von 24 Monaten nach Beendigung des Arbeitsverhältnisses in einem Umkreis von 100 km nicht für ein Konkurrenzunternehmen tätig zu werden. Für jeden Fall der Zuwiderhandlung ist eine Vertragsstrafe in Höhe von 10.000 EUR zu zahlen.\n§ 8 Verschwiegenheit\nDer Arbeitnehmer ist verpflichtet, über alle Betriebsgeheimnisse auch nach Beendigung des Arbeitsverhältnisses zeitlich unbegrenzt Stillschweigen zu bewahren.\n§ 9 Arbeitsergebnisse\nDer Arbeitnehmer überträgt dem Arbeitgeber sämtliche Nutzungsrechte an allen Arbeitsergebnissen zeitlich und räumlich unbeschränkt.\n§ 12 Schlussbestimmungen\nEs gilt deutsches Recht. Gerichtsstand ist München."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BeforeYouSignResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "BeforeYouSignInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text": {
            "title": "Contract text",
            "description": "Paste the text here, or use one of the other options below (exactly one).",
            "type": "string",
            "maxLength": 200000
          },
          "file": {
            "title": "Or upload a file",
            "description": "TXT, PDF, DOCX, HTML or a photo/scan (PNG/JPG, read with OCR). Max 5 MiB. Upload as {filename, contentType?, contentBase64}. Max 5120 KiB. Accepts .txt,.pdf,.docx,.png,.jpg,.jpeg,.html.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "url": {
            "title": "Or fetch public terms from a URL",
            "description": "A public http(s) address. The page text is fetched once and analysed.",
            "type": "string",
            "format": "uri"
          }
        },
        "required": []
      },
      "BeforeYouSignResult": {
        "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": [
              "disclaimer",
              "confidence",
              "counts",
              "findings",
              "categoriesFound",
              "notDetected"
            ],
            "properties": {
              "disclaimer": {
                "type": "string"
              },
              "confidence": {
                "type": "string",
                "const": "pattern-match"
              },
              "counts": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "high",
                  "medium",
                  "low",
                  "total",
                  "sentences"
                ],
                "properties": {
                  "high": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "medium": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "low": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "total": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "sentences": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              },
              "findings": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "category",
                    "label",
                    "severity",
                    "severityRule",
                    "rule",
                    "clause",
                    "parameters",
                    "questions"
                  ],
                  "properties": {
                    "category": {
                      "type": "string",
                      "enum": [
                        "auto-renewal",
                        "notice-period",
                        "minimum-term",
                        "termination-rights",
                        "early-termination-fee",
                        "liability-limitation",
                        "indemnification",
                        "arbitration",
                        "governing-law",
                        "non-compete",
                        "confidentiality",
                        "ip-assignment",
                        "price-changes",
                        "late-payment-interest",
                        "penalties",
                        "personal-guarantee",
                        "exclusivity",
                        "data-sharing",
                        "unilateral-changes"
                      ]
                    },
                    "label": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "high",
                        "medium",
                        "low"
                      ]
                    },
                    "severityRule": {
                      "type": "string",
                      "description": "The fixed rule that determined the severity."
                    },
                    "rule": {
                      "type": "string",
                      "description": "Id of the text pattern that matched."
                    },
                    "clause": {
                      "type": "string",
                      "description": "Exact sentence quoted from the contract."
                    },
                    "parameters": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "name",
                          "value"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "questions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "categoriesFound": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "notDetected": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Clause categories no pattern matched (they may still exist in other wording)."
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}