{
  "openapi": "3.1.1",
  "info": {
    "title": "Outline Notes to Flashcards API",
    "version": "1.0.0",
    "summary": "Turn an indented Markdown outline with term :: definition lines into flashcards, CSV and Anki text.",
    "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://lessonleafoutlinecards.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Turn an indented Markdown outline with term :: definition lines into flashcards, CSV and Anki text.",
        "description": "Reads study notes written as an outline (nested “- ” lists, headings, paragraphs) and finds the flashcards written inside them: “term :: definition” lines, “:::” for cards in both directions, {{c1::cloze}} gaps, and “question ::” lines whose indented sub-points are the answer (list answers). Each card keeps its place in the outline (the parent points become its context) and the tags from #tags and the front matter. Returns the cards, a card CSV, an Anki “Notes in Plain Text” file and a link that opens the notes in Lessonleaf.\n\nMethodology:\n- The outline is read like CommonMark lists: every list item, heading and paragraph becomes one block; deeper indentation makes a sub-point; headings hold the blocks under them; a line indented under a point continues it.\n- Each block is turned into Deckwright card text and read by Deckwright’s card parser: “front :: back” makes one card, “front ::: back” two (both directions), {{cN::answer}} or {{cN::answer::hint}} one cloze card per number. A block that ends with “::” (or “:::”) takes its indented sub-points as the answer, written as a list.\n- Card ids are the block id plus b (front → back), r (back → front) or cN (cloze number), so in Lessonleaf editing a card keeps its review history. Tags are the front-matter tags plus the #tags of the block and of the points above it; [[links]] keep their text and ((references)) are replaced by the referenced point.\n- The CSV has the columns front, back, tag, id (tag = the note’s title; one row per cloze note; two-way cards once). The Anki file is “Notes in Plain Text” with tabs, #html:false and the tags in column 3; two-way cards become two notes there.\n\nPictures and formatting other than plain Markdown text are not carried into the cards. The Anki file is plain text; import it into a Basic note type (cloze lines into a Cloze note type).",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lessonleaf_outline_cards",
        "x-owner-app": "lessonleaf",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LessonleafOutlineCardsInput"
              },
              "examples": {
                "example1": {
                  "summary": "Biology outline with list answers, a two-way card and cloze gaps",
                  "value": {
                    "text": "---\ntitle: Cell biology\ntags: [biology]\n---\n- Organelles\n  - Nucleus :: holds the cell's DNA\n  - Mitochondria :: make ATP by cellular respiration #exam\n- Parts of every cell ::\n  - cell membrane\n  - cytoplasm\n  - ribosomes\n- Aerobic respiration ::: respiration that needs oxygen\n- The {{c1::cell membrane}} controls what enters the cell; plants also have a {{c2::cell wall}}.\n- Chloroplasts are only found in plant cells (a note, not a card).\n"
                  }
                },
                "example2": {
                  "summary": "Vocabulary under headings (two-way cards)",
                  "value": {
                    "text": "# Spanish greetings\n\n- hola ::: hello\n- gracias ::: thank you\n- buenos días ::: good morning #a1\n"
                  }
                },
                "example3": {
                  "summary": "History dates as cloze cards with context",
                  "value": {
                    "text": "- First World War\n  - It began in {{c1::1914}} and ended in {{c2::1918}}.\n  - Causes ::\n    - militarism\n    - alliances\n    - imperialism\n    - nationalism\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LessonleafOutlineCardsResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "LessonleafOutlineCardsInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text": {
            "title": "Notes (Markdown outline)",
            "description": "Nested “- ” lists (two or four spaces per level), # headings and paragraphs. Cards: “term :: definition”, “term ::: definition” (both ways), {{c1::gap}}, or “question ::” followed by indented answer points. Optional front matter with title and tags.",
            "type": "string",
            "maxLength": 500000,
            "default": "---\ntitle: Cell biology\ntags: [biology]\n---\n- Organelles\n  - Nucleus :: holds the cell's DNA\n  - Mitochondria :: make ATP by cellular respiration #exam\n- Parts of every cell ::\n  - cell membrane\n  - cytoplasm\n  - ribosomes\n- Aerobic respiration ::: respiration that needs oxygen\n- The {{c1::cell membrane}} controls what enters the cell; plants also have a {{c2::cell wall}}.\n- Chloroplasts are only found in plant cells (a note, not a card).\n"
          }
        },
        "required": []
      },
      "LessonleafOutlineCardsResult": {
        "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": [
              "title",
              "count",
              "kinds",
              "blocks",
              "tags",
              "cards",
              "csv",
              "anki",
              "warnings",
              "files",
              "openInApp"
            ],
            "properties": {
              "title": {
                "type": "string"
              },
              "count": {
                "type": "integer"
              },
              "blocks": {
                "type": "integer"
              },
              "kinds": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "basic",
                  "reverse",
                  "cloze"
                ],
                "properties": {
                  "basic": {
                    "type": "integer"
                  },
                  "reverse": {
                    "type": "integer"
                  },
                  "cloze": {
                    "type": "integer"
                  }
                }
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "cards": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "n",
                    "id",
                    "kind",
                    "front",
                    "back",
                    "block",
                    "tags",
                    "path"
                  ],
                  "properties": {
                    "n": {
                      "type": "integer"
                    },
                    "id": {
                      "type": "string"
                    },
                    "kind": {
                      "enum": [
                        "basic",
                        "reverse",
                        "cloze"
                      ]
                    },
                    "front": {
                      "type": "string"
                    },
                    "back": {
                      "type": "string"
                    },
                    "block": {
                      "type": "string"
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "path": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "csv": {
                "type": "string"
              },
              "anki": {
                "type": "string"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "files": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "csv",
                  "anki"
                ],
                "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)."
                      }
                    }
                  },
                  "anki": {
                    "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)."
                      }
                    }
                  }
                }
              },
              "openInApp": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}