{
  "openapi": "3.1.1",
  "info": {
    "title": "Crewdesk Overtime to Time Off Calculator API",
    "version": "1.0.0",
    "summary": "Turn worked hours into overtime per week or month and into time off in lieu — night shifts and public holidays included.",
    "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://crewdeskovertimetoil.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Turn worked hours into overtime per week or month and into time off in lieu — night shifts and public holidays included.",
        "description": "Paste the hours someone worked (start and end times, night shifts over midnight, or day totals) and their planned hours per weekday. The calculator compares both per week or per month: public holidays and approved leave count as worked with their planned hours, overtime can be capped per period and can lapse a number of months later. The result is the overtime you can turn into time off in lieu, period by period and day by day. Optionally counts the real elapsed time in a time zone, so a night over the end of daylight saving time is one hour longer.\n\nMethodology:\n- Planned hours belong to the weekday they are planned for. A night shift from 21:00 to 07:00 counts all 10 hours on the day it starts (default, like the planned shift) — or, if you choose so, 3 hours on the first and 7 on the next calendar day, which can move hours into the next week or month. Day totals always count on their day.\n- Per week (or calendar month): difference = worked hours + credited hours − planned hours. Public holidays on a planned day and approved leave are credited with that day’s planned hours, so they never create or cost overtime.\n- Overtime is the positive difference of a period. Undertime in one period is shown but does not cancel overtime of another period (agree on that separately if your rules say so). A cap limits the hours that count per period.\n- Durations are taken on the wall clock by default (like Timeslice): a night over the end of daylight saving time counts as it reads on the clock. With “real elapsed time” and a time zone that night is one hour longer (and the spring night one hour shorter).\n- Time off from a period lapses the given number of months after the period ends; overtime that has already lapsed by the last day is not available. When you turn overtime into one block of time off, it lapses with the earliest period in it.\n\nNot payroll and not legal advice: contracts, collective agreements and local law decide the real entitlement.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "crewdesk_overtime_toil",
        "x-owner-app": "crewdesk",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CrewdeskOvertimeToilInput"
              },
              "examples": {
                "example1": {
                  "summary": "Two weeks of night shifts (Sun–Wed, 10 h each)",
                  "value": {
                    "entries": "2026-11-02 21:00-07:00\n2026-11-03 21:00-07:30\n2026-11-04 21:00-08:00\n2026-11-08 21:00-07:00\n2026-11-09 21:00-07:00\n2026-11-10 21:00-09:00\n2026-11-11 21:00-07:00\n2026-11-15 21:00-07:00",
                    "plannedHours": "Sun-Wed 10",
                    "from": "2026-11-02",
                    "to": "2026-11-15",
                    "country": "DE",
                    "subdivision": "DE-HH"
                  }
                },
                "example2": {
                  "summary": "Night over the end of daylight saving time, elapsed time",
                  "value": {
                    "entries": "2026-10-24 22:00-06:00\n2026-10-25 22:00-06:00",
                    "plannedHours": "Sat-Sun 8",
                    "from": "2026-10-19",
                    "to": "2026-10-25",
                    "clock": "elapsed",
                    "timeZone": "Europe/Berlin",
                    "country": "",
                    "subdivision": ""
                  }
                },
                "example3": {
                  "summary": "Office week with a public holiday in Bavaria, cap 4 h a week",
                  "value": {
                    "entries": "2027-01-04 9.5h\n2027-01-05 9h\n2027-01-07 10h\n2027-01-08 8.5h",
                    "plannedHours": "Mon-Fri 8",
                    "from": "2027-01-04",
                    "to": "2027-01-10",
                    "capHours": 4,
                    "expiryMonths": 6,
                    "country": "DE",
                    "subdivision": "DE-BY"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrewdeskOvertimeToilResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "CrewdeskOvertimeToilInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "entries": {
            "title": "Worked time (one per line)",
            "description": "“2026-11-02 21:00-07:00” (an end at or before the start is the next morning), “2026-11-02T21:00..2026-11-03T07:00”, or a day total “2026-11-02 9.5h”.",
            "type": "string",
            "maxLength": 200000,
            "default": "2026-11-02 21:00-07:00\n2026-11-03 21:00-07:30\n2026-11-04 21:00-08:00\n2026-11-08 21:00-07:00\n2026-11-09 21:00-07:00\n2026-11-10 21:00-09:00\n2026-11-11 21:00-07:00\n2026-11-15 21:00-07:00"
          },
          "plannedHours": {
            "title": "Planned hours per weekday",
            "description": "For example “Mon-Fri 8”, “Mon-Fri 7.7” or “Sun-Wed 10, Sat 6”. Days not named are days off. A shift counts on the day it starts.",
            "type": "string",
            "maxLength": 200,
            "default": "Sun-Wed 10"
          },
          "from": {
            "title": "First day (YYYY-MM-DD)",
            "type": "string",
            "maxLength": 10,
            "default": "2026-11-02"
          },
          "to": {
            "title": "Last day (YYYY-MM-DD, at most 400 days)",
            "type": "string",
            "maxLength": 10,
            "default": "2026-11-15"
          },
          "period": {
            "title": "Compare per",
            "type": "string",
            "enum": [
              "week",
              "month"
            ],
            "default": "week"
          },
          "weekStart": {
            "title": "Weeks start on",
            "type": "string",
            "enum": [
              "1",
              "0",
              "6"
            ],
            "default": "1"
          },
          "capHours": {
            "title": "At most … overtime hours per period count (0 = no cap)",
            "type": "number",
            "minimum": 0,
            "maximum": 1000,
            "default": 0
          },
          "expiryMonths": {
            "title": "Time off lapses … months after the period (0 = never)",
            "type": "number",
            "minimum": 0,
            "maximum": 120,
            "default": 3
          },
          "absences": {
            "title": "Approved leave (one range per line, or “YYYY-MM-DD 4h”)",
            "description": "Counted as worked with the planned hours of each day, so leave never creates or costs overtime.",
            "type": "string",
            "maxLength": 20000,
            "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-HH"
          },
          "extraHolidays": {
            "title": "Extra holidays (YYYY-MM-DD, name per line)",
            "type": "string",
            "maxLength": 6000,
            "default": ""
          },
          "attribute": {
            "title": "A night shift counts on",
            "type": "string",
            "enum": [
              "start",
              "midnight"
            ],
            "default": "start"
          },
          "clock": {
            "title": "Count durations",
            "type": "string",
            "enum": [
              "wall",
              "elapsed"
            ],
            "default": "wall"
          },
          "timeZone": {
            "title": "Time zone (for elapsed time)",
            "type": "string",
            "maxLength": 64,
            "default": "Europe/Berlin"
          },
          "convertHours": {
            "title": "Hours to turn into time off (0 = all available)",
            "type": "number",
            "minimum": 0,
            "maximum": 1000,
            "default": 0
          }
        },
        "required": []
      },
      "CrewdeskOvertimeToilResult": {
        "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": [
              "periods",
              "days",
              "totals",
              "eligible",
              "credit"
            ],
            "properties": {
              "periods": {
                "type": "array"
              },
              "days": {
                "type": "array"
              },
              "totals": {
                "type": "object"
              },
              "eligible": {
                "type": "number"
              },
              "credit": {
                "type": "object",
                "properties": {
                  "hours": {
                    "type": "number"
                  },
                  "expires": {
                    "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"
              }
            }
          }
        }
      }
    }
  }
}