{
  "openapi": "3.1.1",
  "info": {
    "title": "Crewdesk Leave Entitlement Calculator API",
    "version": "1.0.0",
    "summary": "Annual leave for a year: pro rata for start or end dates, part-time, carry-over with expiry.",
    "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://crewdeskleaveentitlement.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Annual leave for a year: pro rata for start or end dates, part-time, carry-over with expiry.",
        "description": "Works out how many days of annual leave someone has in a year: the full-time allowance scaled to their working days per week (also when the pattern changes during the year), pro rata for a start or end date in that year (full months like the German BUrlG, or calendar days), rounded the way you choose, plus carried-over days that lapse on a deadline unless they are used first. Add the leave taken and requested to see what is left. Shows the German statutory minimum for comparison.\n\nMethodology:\n- Part-time: the allowance is scaled by working days per week ÷ the days the allowance is meant for (30 days at 5 days → 18 days at 3 days). When the pattern changes during the year, each period counts with its own days, weighted by its calendar days.\n- Pro rata (only when the employment starts or ends inside the year): full months of employment counted from the start day ÷ 12 (15 April–31 December = 8 full months), or employed calendar days ÷ days of the year, or not at all.\n- Rounding “§ 5 BUrlG”: a fraction of at least half a day becomes a full day, a smaller fraction stays as it is. Other modes round to half days or not at all.\n- Carry-over: days carried in are used first by leave taken up to the deadline; what is left lapses after it. Unused days at the end of the year move on up to the maximum.\n- Leave is counted in working days of the person’s pattern without public holidays of the chosen region (as in the working days calculator). The German statutory minimum is 4 weeks: 4 × working days per week, scaled the same way — shown for comparison only.\n\nNot payroll and not legal advice: contracts, collective agreements and local law decide the real entitlement.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "crewdesk_leave_entitlement",
        "x-owner-app": "crewdesk",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CrewdeskLeaveEntitlementInput"
              },
              "examples": {
                "example1": {
                  "summary": "Start on 15 April, 30 days, full-time",
                  "value": {
                    "year": 2026,
                    "allowanceDays": 30,
                    "referenceDaysPerWeek": 5,
                    "startDate": "2026-04-15"
                  }
                },
                "example2": {
                  "summary": "Three-day week, whole year, 5 days carried until 31 March",
                  "value": {
                    "year": 2026,
                    "allowanceDays": 30,
                    "referenceDaysPerWeek": 5,
                    "startDate": "2020-01-01",
                    "workingDays": "Mon-Wed",
                    "carriedIn": 5,
                    "carryOverExpires": "03-31",
                    "leaveTaken": "2026-02-02..2026-02-04\n2026-08-03..2026-08-14",
                    "asOf": "2026-12-01"
                  }
                },
                "example3": {
                  "summary": "Switch from five to four days on 1 July",
                  "value": {
                    "year": 2026,
                    "allowanceDays": 30,
                    "referenceDaysPerWeek": 5,
                    "startDate": "2018-01-01",
                    "workingDays": "Mon-Fri\n2026-07-01: Mon-Thu"
                  }
                },
                "example4": {
                  "summary": "Leaving on 30 June, 28 days, per calendar day, half-day rounding",
                  "value": {
                    "year": 2027,
                    "allowanceDays": 28,
                    "referenceDaysPerWeek": 5,
                    "startDate": "2022-05-01",
                    "endDate": "2027-06-30",
                    "proRata": "days",
                    "rounding": "half"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrewdeskLeaveEntitlementResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "CrewdeskLeaveEntitlementInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "year": {
            "title": "Year",
            "type": "number",
            "minimum": 1990,
            "maximum": 2100,
            "default": 2026
          },
          "allowanceDays": {
            "title": "Yearly allowance (full-time days)",
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "default": 30
          },
          "referenceDaysPerWeek": {
            "title": "The allowance is for … working days a week",
            "type": "number",
            "minimum": 1,
            "maximum": 7,
            "default": 5
          },
          "startDate": {
            "title": "Start of employment (optional)",
            "type": "string",
            "maxLength": 10,
            "default": "2026-04-15"
          },
          "endDate": {
            "title": "End of employment (optional)",
            "type": "string",
            "maxLength": 10,
            "default": ""
          },
          "workingDays": {
            "title": "Working days (or lines “YYYY-MM-DD: Mon-Thu” for changes)",
            "description": "One pattern such as Mon-Fri, or a pattern per period: first line the pattern at the start, then “2026-07-01: Mon-Thu”.",
            "type": "string",
            "maxLength": 1000,
            "default": "Mon-Fri"
          },
          "proRata": {
            "title": "Part of a year counts",
            "type": "string",
            "enum": [
              "months",
              "days",
              "none"
            ],
            "default": "months"
          },
          "rounding": {
            "title": "Rounding",
            "type": "string",
            "enum": [
              "burlg",
              "half",
              "up-half",
              "none"
            ],
            "default": "burlg"
          },
          "accrual": {
            "title": "Earned",
            "type": "string",
            "enum": [
              "yearly",
              "monthly"
            ],
            "default": "yearly"
          },
          "carriedIn": {
            "title": "Days carried over from last year",
            "type": "number",
            "minimum": 0,
            "maximum": 200,
            "default": 0
          },
          "carryOverExpires": {
            "title": "Carried days lapse after (MM-DD, empty = never)",
            "type": "string",
            "maxLength": 5,
            "default": "03-31"
          },
          "carryOverMaxDays": {
            "title": "At most … days move on to next year",
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "default": 5
          },
          "leaveTaken": {
            "title": "Leave taken (one range per line)",
            "description": "2026-03-02..2026-03-06 or a single date. Counted in working days with the holidays below.",
            "type": "string",
            "maxLength": 20000,
            "default": ""
          },
          "leavePlanned": {
            "title": "Leave requested, not yet approved (one range per line)",
            "type": "string",
            "maxLength": 20000,
            "default": ""
          },
          "asOf": {
            "title": "As of (YYYY-MM-DD, empty = end of the year)",
            "type": "string",
            "maxLength": 10,
            "default": ""
          },
          "country": {
            "title": "Country for public holidays (optional)",
            "type": "string",
            "maxLength": 4,
            "default": "DE"
          },
          "subdivision": {
            "title": "State or region (optional)",
            "description": "ISO 3166-2 code such as DE-BY (Bavaria), DE-BE (Berlin), AT-9 (Vienna), CH-ZH or US-CA. Without it only nationwide holidays count.",
            "type": "string",
            "maxLength": 6,
            "default": "DE-BE"
          },
          "extraHolidays": {
            "title": "Extra holidays (YYYY-MM-DD, name per line)",
            "type": "string",
            "maxLength": 6000,
            "default": ""
          }
        },
        "required": []
      },
      "CrewdeskLeaveEntitlementResult": {
        "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",
            "required": [
              "entitlement",
              "available",
              "afterPlanned",
              "carryUsed",
              "carryLapsed"
            ],
            "properties": {
              "entitlement": {
                "type": "object"
              },
              "available": {
                "type": "number"
              },
              "afterPlanned": {
                "type": "number"
              },
              "carryUsed": {
                "type": "number"
              },
              "carryLapsed": {
                "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"
              }
            }
          }
        }
      }
    }
  }
}