{
  "openapi": "3.1.1",
  "info": {
    "title": "Dayweave Recurrence Rule (RRULE) Expander API",
    "version": "1.0.0",
    "summary": "List the dates of an iCalendar RRULE in any time zone, with daylight saving and exceptions.",
    "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://dayweaverecurrenceexpander.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "List the dates of an iCalendar RRULE in any time zone, with daylight saving and exceptions.",
        "description": "Expands a recurrence rule from a calendar (RRULE, RFC 5545) — daily, weekly, monthly or yearly with INTERVAL, COUNT, UNTIL, BYDAY (also “last Friday”), BYMONTH, BYMONTHDAY and BYSETPOS — from a local start time in an IANA time zone, skips exception dates and lists every occurrence in local time and UTC with the offset, plus the rule in plain English.\n\nMethodology:\n- The rule is expanded on local calendar days (RFC 5545 §3.3.10): the period of FREQ × INTERVAL is enumerated, then BYMONTH, BYMONTHDAY and BYDAY (ordinals like 1MO or −1FR count within the month, or the year for yearly rules) filter days, BYSETPOS picks positions inside each period, COUNT and UNTIL end the series. The first start always counts as the first occurrence.\n- Every occurrence keeps the same local wall-clock time in the chosen zone, so its UTC time moves when daylight saving starts or ends. A local time that does not exist (spring-forward gap) moves forward by the gap; an ambiguous one (fall-back) takes the first of the two moments.\n- UNTIL with a time ending in Z is a UTC moment; without Z (or date-only, then the whole day) it is read in the series’ time zone. Exception dates remove occurrences with exactly that local start.\n- Not supported: BYHOUR/BYMINUTE/BYSECOND, BYWEEKNO, BYYEARDAY and sub-daily frequencies; at most 20 years after the first start are expanded.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "dayweave_recurrence_expander",
        "x-owner-app": "dayweave",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DayweaveRecurrenceExpanderInput"
              },
              "examples": {
                "example1": {
                  "summary": "Last Friday of each month across the clock change",
                  "value": {
                    "rrule": "FREQ=MONTHLY;BYDAY=-1FR;COUNT=6",
                    "start": "2026-09-25 16:00",
                    "timeZone": "Europe/Berlin"
                  }
                },
                "example2": {
                  "summary": "Every other week Monday and Thursday, with a skipped date",
                  "value": {
                    "rrule": "FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TH;UNTIL=20270228",
                    "start": "2026-12-07 09:30",
                    "duration": "30m",
                    "timeZone": "America/New_York",
                    "exdates": "2026-12-21"
                  }
                },
                "example3": {
                  "summary": "Last working day of the month",
                  "value": {
                    "rrule": "FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1;COUNT=12",
                    "start": "2026-12-31 17:00",
                    "duration": "15m",
                    "timeZone": "Asia/Tokyo"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DayweaveRecurrenceExpanderResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "DayweaveRecurrenceExpanderInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "rrule": {
            "title": "Rule (RRULE)",
            "description": "Example: FREQ=WEEKLY;BYDAY=MO,WE;UNTIL=20270331 or FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 (last working day).",
            "type": "string",
            "maxLength": 300,
            "default": "FREQ=MONTHLY;BYDAY=-1FR;COUNT=6"
          },
          "start": {
            "title": "First start (YYYY-MM-DD HH:MM, local time)",
            "type": "string",
            "maxLength": 16,
            "default": "2026-09-25 16:00"
          },
          "duration": {
            "title": "Duration",
            "type": "string",
            "maxLength": 20,
            "default": "1h"
          },
          "timeZone": {
            "title": "Time zone (IANA)",
            "type": "string",
            "maxLength": 64,
            "default": "Europe/Berlin"
          },
          "exdates": {
            "title": "Skip these starts (one per line, YYYY-MM-DD or YYYY-MM-DD HH:MM)",
            "type": "string",
            "maxLength": 6000,
            "default": ""
          },
          "from": {
            "title": "Show from (YYYY-MM-DD, empty = first start)",
            "type": "string",
            "maxLength": 10,
            "default": ""
          },
          "limit": {
            "title": "Show at most",
            "type": "number",
            "minimum": 1,
            "maximum": 500,
            "default": 20
          }
        },
        "required": []
      },
      "DayweaveRecurrenceExpanderResult": {
        "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"
              }
            }
          }
        }
      }
    }
  }
}