{
  "openapi": "3.1.1",
  "info": {
    "title": "Cloze Card Maker API",
    "version": "1.0.0",
    "summary": "Sentences plus key terms → fill-in-the-blank cloze cards for Anki, Deckwright, Lessonleaf.",
    "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://clozecardmaker.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Sentences plus key terms → fill-in-the-blank cloze cards for Anki, Deckwright, Lessonleaf.",
        "description": "Hides your key terms in your own sentences: every occurrence of a term becomes a cloze gap, one card per term (or all gaps on one card). Longer terms win over shorter ones, whole words only by default, any language. The result is in the shared cloze syntax that Anki, Deckwright and Lessonleaf read. No AI: only the terms you list are hidden.\n\nMethodology:\n- Terms are matched longest first, so “carbon dioxide” is one gap even when “carbon” is also a term; overlapping matches are skipped. Whole-word matching uses Unicode letters and digits as word characters, so it works for accented and non-Latin scripts.\n- “One card per term” numbers the distinct terms of each sentence c1, c2 …; the same term twice in a sentence shares its number (both gaps are hidden together). “All gaps on one card” uses c1 for every gap.\n- The cards are read back with the shared card parser (cards.ts), so the card count is what Deckwright and Lessonleaf will show; Anki reads the same {{c1::…}} syntax in its Cloze note type.\n\nExact text matching: inflected forms (plural, other cases) are only found when you list them too.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "cloze_card_maker",
        "x-owner-app": "lessonleaf",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClozeCardMakerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Photosynthesis: one card per term",
                  "value": {}
                },
                "example2": {
                  "summary": "German vocabulary, all gaps on one card",
                  "value": {
                    "sentences": "Der Hund schläft unter dem Tisch.\nDie Katze sitzt auf dem Tisch.",
                    "terms": "Hund; Katze; Tisch",
                    "mode": "together",
                    "title": "Deutsch"
                  }
                },
                "example3": {
                  "summary": "Part-word matches (prefixes)",
                  "value": {
                    "sentences": "Hydrolysis splits a bond with water. Dehydration synthesis removes water.",
                    "terms": "hydro, water",
                    "wholeWords": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClozeCardMakerResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "ClozeCardMakerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "sentences": {
            "title": "Sentences",
            "description": "One sentence per line, or a paragraph that is split at sentence ends.",
            "type": "string",
            "maxLength": 200000,
            "default": "Photosynthesis takes place in the chloroplasts of plant cells.\nChlorophyll absorbs mostly red and blue light.\nThe light reactions split water and release oxygen.\nThe Calvin cycle fixes carbon dioxide into sugar."
          },
          "terms": {
            "title": "Key terms",
            "description": "Separated by commas, semicolons or new lines; put a term with a comma in \"quotes\".",
            "type": "string",
            "maxLength": 20000,
            "default": "chloroplasts, chlorophyll, red and blue light, oxygen, Calvin cycle, carbon dioxide"
          },
          "mode": {
            "title": "Cards",
            "type": "string",
            "enum": [
              "separate",
              "together"
            ],
            "default": "separate"
          },
          "caseSensitive": {
            "title": "Match upper and lower case exactly",
            "type": "boolean",
            "default": false
          },
          "wholeWords": {
            "title": "Whole words only",
            "type": "boolean",
            "default": true
          },
          "title": {
            "title": "Tag (heading) for the cards",
            "type": "string",
            "maxLength": 80,
            "default": ""
          }
        },
        "required": []
      },
      "ClozeCardMakerResult": {
        "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": [
              "notes",
              "cards",
              "gaps",
              "cardsMarkdown",
              "unusedTerms",
              "skipped",
              "warnings",
              "file",
              "openInApp"
            ],
            "properties": {
              "notes": {
                "type": "integer"
              },
              "cards": {
                "type": "integer"
              },
              "gaps": {
                "type": "integer"
              },
              "cardsMarkdown": {
                "type": "string"
              },
              "unusedTerms": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "skipped": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "n",
                    "sentence"
                  ],
                  "properties": {
                    "n": {
                      "type": "integer"
                    },
                    "sentence": {
                      "type": "string"
                    }
                  }
                }
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "file": {
                "anyOf": [
                  {
                    "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)."
                      }
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "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"
              }
            }
          }
        }
      }
    }
  }
}