{
  "openapi": "3.1.1",
  "info": {
    "title": "Bridge-Day Leave Optimizer API",
    "version": "1.0.0",
    "summary": "Place your leave days around public holidays for the most days off in a row.",
    "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://hearthleaveoptimizer.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Place your leave days around public holidays for the most days off in a row.",
        "description": "Takes your number of leave days, the public holidays of your country and region and your weekend, and finds the leave days that give the most days off in breaks — computed exactly, not by trial and error — plus a list of the best bridge days around each holiday.\n\nMethodology:\n- Days off are weekends (your weekend days), public holidays of the country (Nager.Date entries of type “Public”, nationwide plus your region) and extra closing days. Every other day is a working day that costs one leave day.\n- A break is a run of days off that contains at least one leave day; it counts with its full length, weekends and holidays included, and only when it is at least the shortest break you want.\n- The optimiser is an exact dynamic programme over the working days: taking working days k…e always opens the run from the day after the previous working day to the day before the next one, so the best plan is a set of non-adjacent ranges of working days. It maximises the days off in breaks; on a tie it uses fewer leave days, then the earlier plan. A test compares it with a brute-force search over every subset of working days.\n- Bridge-day ideas list short breaks (1–4 leave days) that contain a public holiday, ranked by days off per leave day, without overlaps.\n\nCheck your contract, collective agreement and employer rules: some regions have extra local holidays, half days or company closures that are not in the data.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "hearth_leave_optimizer",
        "x-owner-app": "hearth",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HearthLeaveOptimizerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Bavaria 2027, 10 leave days",
                  "value": {
                    "country": "DE",
                    "subdivision": "DE-BY",
                    "from": "2027-01-01",
                    "to": "2027-12-31",
                    "leaveDays": 10,
                    "minBreak": 4
                  }
                },
                "example2": {
                  "summary": "Netherlands, spring 2027, 5 days in at most two breaks",
                  "value": {
                    "country": "NL",
                    "from": "2027-03-01",
                    "to": "2027-06-30",
                    "leaveDays": 5,
                    "minBreak": 3,
                    "maxBreaks": 2
                  }
                },
                "example3": {
                  "summary": "United States 2027, 8 days",
                  "value": {
                    "country": "US",
                    "from": "2027-01-01",
                    "to": "2027-12-31",
                    "leaveDays": 8,
                    "minBreak": 4
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HearthLeaveOptimizerResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "HearthLeaveOptimizerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "country": {
            "title": "Country",
            "type": "string",
            "enum": [
              "DE",
              "AT",
              "CH",
              "US",
              "GB",
              "FR",
              "NL",
              "BE",
              "ES",
              "IT",
              "PL",
              "SE",
              "DK",
              "IE",
              "CA",
              "AU"
            ],
            "default": "DE"
          },
          "subdivision": {
            "title": "State or region (optional)",
            "description": "ISO 3166-2 code such as DE-BY (Bavaria) or CH-ZH. Without it only nationwide holidays count.",
            "type": "string",
            "maxLength": 10,
            "default": ""
          },
          "from": {
            "title": "Period from",
            "type": "string",
            "format": "date",
            "default": "2027-01-01"
          },
          "to": {
            "title": "Period to",
            "type": "string",
            "format": "date",
            "default": "2027-12-31"
          },
          "leaveDays": {
            "title": "Leave days to plan",
            "type": "integer",
            "minimum": 1,
            "maximum": 40,
            "default": 10
          },
          "minBreak": {
            "title": "Shortest break worth taking (days off in a row)",
            "type": "integer",
            "minimum": 1,
            "maximum": 30,
            "default": 4
          },
          "maxBreaks": {
            "title": "Most separate breaks (0 = any number)",
            "type": "integer",
            "minimum": 0,
            "maximum": 20,
            "default": 0
          },
          "weekendDays": {
            "title": "Weekend days",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "sun",
                "mon",
                "tue",
                "wed",
                "thu",
                "fri",
                "sat"
              ]
            },
            "default": [
              "sat",
              "sun"
            ]
          },
          "closures": {
            "title": "Extra days off without leave (optional)",
            "description": "One YYYY-MM-DD per line, for example company closing days.",
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 60
          }
        },
        "required": [
          "from",
          "to"
        ]
      },
      "HearthLeaveOptimizerResult": {
        "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": [
              "country",
              "subdivision",
              "period",
              "breaks",
              "totalDaysOff",
              "leaveUsed",
              "leaveLeft",
              "efficiency",
              "ideas"
            ],
            "properties": {
              "country": {
                "type": "string"
              },
              "subdivision": {
                "type": "string"
              },
              "period": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "from",
                  "to",
                  "days",
                  "workdays",
                  "weekendDays",
                  "holidays",
                  "closures"
                ],
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  },
                  "days": {
                    "type": "integer"
                  },
                  "workdays": {
                    "type": "integer"
                  },
                  "weekendDays": {
                    "type": "integer"
                  },
                  "holidays": {
                    "type": "integer"
                  },
                  "closures": {
                    "type": "integer"
                  }
                }
              },
              "breaks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "start",
                    "end",
                    "days",
                    "leaveDays",
                    "leaveDates",
                    "holidays",
                    "touchesPeriodEdge"
                  ],
                  "properties": {
                    "start": {
                      "type": "string"
                    },
                    "end": {
                      "type": "string"
                    },
                    "days": {
                      "type": "integer"
                    },
                    "leaveDays": {
                      "type": "integer"
                    },
                    "leaveDates": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "holidays": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "date",
                          "name"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "touchesPeriodEdge": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "totalDaysOff": {
                "type": "integer"
              },
              "leaveUsed": {
                "type": "integer"
              },
              "leaveLeft": {
                "type": "integer"
              },
              "efficiency": {
                "type": "number"
              },
              "ideas": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "start",
                    "end",
                    "days",
                    "leaveDays",
                    "leaveDates",
                    "ratio",
                    "holidays"
                  ],
                  "properties": {
                    "start": {
                      "type": "string"
                    },
                    "end": {
                      "type": "string"
                    },
                    "days": {
                      "type": "integer"
                    },
                    "leaveDays": {
                      "type": "integer"
                    },
                    "leaveDates": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "ratio": {
                      "type": "number"
                    },
                    "holidays": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}