{
  "openapi": "3.1.1",
  "info": {
    "title": "Sizewise Life in Weeks API",
    "version": "1.0.0",
    "summary": "Your life as a grid of weeks: one row per year, with milestones and exact counts.",
    "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://sizewiselifeweeks.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Your life as a grid of weeks: one row per year, with milestones and exact counts.",
        "description": "Draws a life-in-weeks grid from a birth date — one row per year, 52 boxes per row — with the current week, your milestones and exact counts of days, weeks, Sundays and leap days lived. Nothing is stored.\n\nMethodology:\n- Rows start on each birthday (29 February birthdays fall on 28 February in common years); box n of a row covers days 7(n−1) to 7n−1 after the birthday, and the 52nd box also holds the last one or two days of the year.\n- Days, Sundays and leap days are exact counts of UTC calendar days from the birth date to the chosen day, both included for Sundays and leap days. Full Moons are days lived ÷ 29.530589 (mean synodic month, Meeus).\n- The grid length is your choice (90 years by default); it is not a life-expectancy estimate.\n\nNothing you enter is stored on the server beyond the request itself. The grid is a way to picture time, not a prediction.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "sizewise_life_weeks",
        "x-owner-app": "sizewise",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SizewiseLifeWeeksInput"
              },
              "examples": {
                "example1": {
                  "summary": "Born 15 June 1990, on 8 November 2026",
                  "value": {
                    "birthDate": "1990-06-15",
                    "today": "2026-11-08",
                    "years": 90,
                    "milestones": "1996-09-02 First day at school\n2008-07-01 First job"
                  }
                },
                "example2": {
                  "summary": "A leap-day birthday",
                  "value": {
                    "birthDate": "2000-02-29",
                    "today": "2026-11-08",
                    "years": 80
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SizewiseLifeWeeksResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "SizewiseLifeWeeksInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "birthDate": {
            "title": "Birth date",
            "type": "string",
            "format": "date",
            "default": "1990-06-15"
          },
          "today": {
            "title": "Count up to (empty = today)",
            "type": "string",
            "format": "date"
          },
          "years": {
            "title": "Years in the grid",
            "type": "integer",
            "minimum": 1,
            "maximum": 120,
            "default": 90
          },
          "milestones": {
            "title": "Milestones (one per line: date, then a label)",
            "description": "For example “2012-09-01 First job”.",
            "type": "string",
            "maxLength": 4000,
            "default": ""
          }
        },
        "required": []
      },
      "SizewiseLifeWeeksResult": {
        "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"
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}