{
  "openapi": "3.1.1",
  "info": {
    "title": "Exam Study Planner for Flashcards API",
    "version": "1.0.0",
    "summary": "How many new cards and reviews a day so every flashcard is learned before the exam.",
    "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://examstudyplanner.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "How many new cards and reviews a day so every flashcard is learned before the exam.",
        "description": "Plans each day until one or more exams: how many new flashcards to learn and how many reviews are due, with a cram phase before each exam and a warning (and the minutes a day you would need) when your time budget is not enough. Reviews are forecast with the same FSRS-5 or SM-2 scheduler as Deckwright’s Study view and Lessonleaf; your existing cards and review log can be included. Exports a CSV and a calendar file.\n\nMethodology:\n- Every simulated review goes through the shared scheduler (FSRS-5 with its published default parameters, or SM-2) that also runs Deckwright’s Study view and Lessonleaf; existing cards start from the states rebuilt from your review log. Each simulated answer is “Good”; wrong answers only add time (your error share × the time per card).\n- Each day: reviews that are due come first, then cram reviews, then new cards. New cards of an exam are spread evenly over its learning days (today until the day before its cram phase, rest days skipped), earliest exam first; a day only takes more than its share when it is behind, and never more than your time budget or the new-card limit allows.\n- Cram phase (last N days before an exam): no new cards for it; every card whose predicted recall on exam day, R = (1 + 19/81 · t/S)^−0.5, is below the target — with SM-2, every card whose next review would fall after the exam — gets one extra review, weakest first, spread over the cram days.\n- The plan is realistic when all cards are introduced before their cram phase and no day needs more than the budget. Otherwise the smallest daily budget that fits is found by bisection over the same simulation (whole minutes, at most 24 hours).\n- Predicted recall on exam day is the FSRS mean over introduced cards; “all cards” counts cards that were never introduced as 0.\n\nA plan, not a promise: real answers vary, and the times per card are estimates — measure your own pace for a few days and adjust them. Recall figures are model estimates with default parameters.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "exam_study_planner",
        "x-owner-app": "lessonleaf",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExamStudyPlannerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Two exams, 30 minutes a day, Sundays off",
                  "value": {
                    "exams": [
                      {
                        "date": "2026-12-18",
                        "name": "Biology midterm",
                        "cards": 240,
                        "tag": "Cell biology"
                      },
                      {
                        "date": "2027-01-15",
                        "name": "Spanish B1",
                        "cards": 400
                      }
                    ],
                    "today": "2026-12-01",
                    "minutesPerDay": 30,
                    "restDays": [
                      "0"
                    ]
                  }
                },
                "example2": {
                  "summary": "Too little time: 1,200 cards in two weeks with 20 minutes a day",
                  "value": {
                    "exams": [
                      {
                        "date": "2026-12-15",
                        "name": "Anatomy",
                        "cards": 1200
                      }
                    ],
                    "today": "2026-12-01",
                    "minutesPerDay": 20
                  }
                },
                "example3": {
                  "summary": "Existing cards and review log, SM-2, no cram phase",
                  "value": {
                    "exams": [
                      {
                        "date": "2026-12-20",
                        "name": "Biology",
                        "cards": 50,
                        "tag": "Cell biology"
                      },
                      {
                        "date": "2027-01-10",
                        "name": "Spanish",
                        "cards": 0,
                        "tag": "Spanish"
                      }
                    ],
                    "today": "2026-12-01",
                    "minutesPerDay": 15,
                    "cram": false,
                    "scheduler": "sm2",
                    "cards": "# Cell biology\nMitochondria :: make ATP by cellular respiration\nNucleus :: holds the cell's DNA\nRibosome :: builds proteins\nThe {{c1::cell membrane}} controls what enters the cell.\n\n# Spanish\nhola ::: hello\ngracias ::: thank you\n",
                    "log": "date,card,rating\n2026-11-20,Mitochondria,good\n2026-11-20,Nucleus,good\n2026-11-23,Mitochondria,good\n2026-11-24,hola,again\n2026-11-24,hola,good\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExamStudyPlannerResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "ExamStudyPlannerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "exams": {
            "title": "Exams",
            "description": "One row per exam: a date like 2027-01-20 or days from today like +28, the number of cards still to learn, and the tag (heading) of cards you already have for it.",
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "date": {
                  "title": "Date or days from today",
                  "type": "string",
                  "maxLength": 12
                },
                "name": {
                  "title": "Exam",
                  "type": "string",
                  "maxLength": 80
                },
                "cards": {
                  "title": "New cards",
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 20000
                },
                "tag": {
                  "title": "Tag of its existing cards (optional)",
                  "type": "string",
                  "maxLength": 60
                }
              },
              "required": [
                "date"
              ]
            },
            "default": [
              {
                "date": "+21",
                "name": "Biology midterm",
                "cards": 240,
                "tag": "Cell biology"
              },
              {
                "date": "+45",
                "name": "Spanish B1",
                "cards": 400,
                "tag": "Spanish"
              }
            ]
          },
          "minutesPerDay": {
            "title": "Time per study day",
            "type": "integer",
            "minimum": 1,
            "maximum": 1440,
            "default": 30,
            "x-unit": "min"
          },
          "today": {
            "title": "Start date",
            "description": "Empty = today (UTC).",
            "type": "string",
            "format": "date"
          },
          "restDays": {
            "title": "Days without study",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "0",
                "1",
                "2",
                "3",
                "4",
                "5",
                "6"
              ]
            },
            "default": []
          },
          "cram": {
            "title": "Cram phase before each exam (no new cards, extra reviews)",
            "type": "boolean",
            "default": true
          },
          "cramDays": {
            "title": "Cram days",
            "type": "integer",
            "minimum": 1,
            "maximum": 14,
            "default": 3
          },
          "cramRetention": {
            "title": "Recall target on exam day (FSRS)",
            "description": "Cards whose predicted recall on exam day is lower get one more review during the cram days.",
            "type": "number",
            "minimum": 0.7,
            "maximum": 0.99,
            "default": 0.9
          },
          "secondsNew": {
            "title": "Time for a new card",
            "type": "number",
            "minimum": 5,
            "maximum": 600,
            "default": 40,
            "x-unit": "s"
          },
          "secondsReview": {
            "title": "Time for a review",
            "type": "number",
            "minimum": 2,
            "maximum": 300,
            "default": 12,
            "x-unit": "s"
          },
          "againRate": {
            "title": "Share of answers you get wrong",
            "description": "Adds time for repeating missed cards (0.1 = one in ten).",
            "type": "number",
            "minimum": 0,
            "maximum": 0.5,
            "default": 0.1
          },
          "maxNewPerDay": {
            "title": "Most new cards on one day",
            "type": "integer",
            "minimum": 1,
            "maximum": 9999,
            "default": 200
          },
          "scheduler": {
            "title": "Scheduler",
            "type": "string",
            "enum": [
              "fsrs",
              "sm2"
            ],
            "default": "fsrs"
          },
          "retention": {
            "title": "Desired retention (FSRS)",
            "type": "number",
            "minimum": 0.7,
            "maximum": 0.97,
            "default": 0.9
          },
          "cards": {
            "title": "Cards you already have (optional)",
            "description": "Deckwright or Lessonleaf card text, CSV or Anki text. Cards whose heading or tag matches an exam’s tag belong to that exam; the others to the first exam without a tag.",
            "type": "string",
            "maxLength": 200000,
            "default": ""
          },
          "log": {
            "title": "Review log (optional, CSV: date, card, rating)",
            "description": "Deckwright’s “Export review log” format; without a log your cards count as new.",
            "type": "string",
            "maxLength": 2000000,
            "default": ""
          }
        },
        "required": []
      },
      "ExamStudyPlannerResult": {
        "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": [
              "today",
              "realistic",
              "requiredMinutes",
              "minutesPerDay",
              "scheduler",
              "exams",
              "days",
              "totals",
              "warnings",
              "files"
            ],
            "properties": {
              "today": {
                "type": "string"
              },
              "realistic": {
                "type": "boolean"
              },
              "requiredMinutes": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "minutesPerDay": {
                "type": "integer"
              },
              "scheduler": {
                "enum": [
                  "fsrs",
                  "sm2"
                ]
              },
              "exams": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "date",
                    "tag",
                    "cards",
                    "existingCards",
                    "newCards",
                    "introduced",
                    "notIntroduced",
                    "learnBy",
                    "cramFrom",
                    "cramReviews",
                    "recallIntroduced",
                    "recallAll"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string"
                    },
                    "tag": {
                      "type": "string"
                    },
                    "cards": {
                      "type": "integer"
                    },
                    "existingCards": {
                      "type": "integer"
                    },
                    "newCards": {
                      "type": "integer"
                    },
                    "introduced": {
                      "type": "integer"
                    },
                    "notIntroduced": {
                      "type": "integer"
                    },
                    "learnBy": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "cramFrom": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "cramReviews": {
                      "type": "integer"
                    },
                    "recallIntroduced": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "recallAll": {
                      "type": [
                        "number",
                        "null"
                      ]
                    }
                  }
                }
              },
              "days": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "date",
                    "weekday",
                    "phase",
                    "newCards",
                    "newByExam",
                    "reviews",
                    "cramReviews",
                    "minutes",
                    "overBudget",
                    "exams"
                  ],
                  "properties": {
                    "date": {
                      "type": "string"
                    },
                    "weekday": {
                      "enum": [
                        "sun",
                        "mon",
                        "tue",
                        "wed",
                        "thu",
                        "fri",
                        "sat"
                      ]
                    },
                    "phase": {
                      "enum": [
                        "learn",
                        "cram",
                        "rest",
                        "exam"
                      ]
                    },
                    "newCards": {
                      "type": "integer"
                    },
                    "newByExam": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      }
                    },
                    "reviews": {
                      "type": "integer"
                    },
                    "cramReviews": {
                      "type": "integer"
                    },
                    "minutes": {
                      "type": "number"
                    },
                    "overBudget": {
                      "type": "boolean"
                    },
                    "exams": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "totals": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "newCards",
                  "reviews",
                  "cramReviews",
                  "minutes",
                  "studyDays",
                  "peakMinutes",
                  "peakDate",
                  "overBudgetDays"
                ],
                "properties": {
                  "newCards": {
                    "type": "integer"
                  },
                  "reviews": {
                    "type": "integer"
                  },
                  "cramReviews": {
                    "type": "integer"
                  },
                  "minutes": {
                    "type": "integer"
                  },
                  "studyDays": {
                    "type": "integer"
                  },
                  "peakMinutes": {
                    "type": "number"
                  },
                  "peakDate": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "overBudgetDays": {
                    "type": "integer"
                  }
                }
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "files": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "csv",
                  "ics"
                ],
                "properties": {
                  "csv": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  },
                  "ics": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "artifactId",
                      "filename",
                      "mime",
                      "bytes",
                      "sha256",
                      "path"
                    ],
                    "properties": {
                      "artifactId": {
                        "type": "string"
                      },
                      "filename": {
                        "type": "string"
                      },
                      "mime": {
                        "type": "string"
                      },
                      "bytes": {
                        "type": "integer"
                      },
                      "sha256": {
                        "type": "string"
                      },
                      "path": {
                        "type": "string",
                        "description": "Download path on the same site (valid for about 2 hours)."
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}