{
  "openapi": "3.1.0",
  "info": {
    "title": "Mathfold API",
    "version": "1.0.0",
    "summary": "Markdown and AI answers to Word (.docx) and PDF with native equations.",
    "description": "Converts Markdown (LaTeX, AsciiMath and MathML maths in any delimiter style, Mermaid diagrams, GFM tables, footnotes, code) into a Word document with native Office Math equations, a PDF with the same layout, or print-ready HTML. Wide tables and diagrams get landscape pages automatically. An MCP server with the same capability is available at /mcp.",
    "contact": {
      "name": "Mathfold support",
      "email": "info@notrino.com",
      "url": "https://mathfold.com/developers"
    },
    "termsOfService": "https://mathfold.com/terms"
  },
  "servers": [
    {
      "url": "https://mathfold.com"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "externalDocs": {
    "url": "https://mathfold.com/developers",
    "description": "API reference and key management"
  },
  "paths": {
    "/v1/convert": {
      "post": {
        "operationId": "convertMarkdown",
        "summary": "Convert Markdown to .docx, PDF or HTML",
        "description": "Send raw Markdown with options as query parameters, or JSON with options and attached images. Returns the file, or JSON with base64 content when Accept is application/json.",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "docx",
                "pdf",
                "html"
              ],
              "default": "docx"
            },
            "description": "Output format (raw Markdown bodies only)"
          },
          {
            "name": "theme",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "standard",
                "academic",
                "modern",
                "compact"
              ],
              "default": "standard",
              "description": "Document theme; all but standard need Pro"
            },
            "description": "Document theme; all but standard need Pro"
          },
          {
            "name": "pageSize",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "A4",
                "Letter",
                "A5",
                "A3",
                "Legal"
              ],
              "default": "A4"
            },
            "description": "pageSize (raw Markdown bodies only)"
          },
          {
            "name": "orientation",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "portrait",
                "landscape"
              ],
              "default": "portrait"
            },
            "description": "orientation (raw Markdown bodies only)"
          },
          {
            "name": "autoLandscape",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": true,
              "description": "Give wide tables and diagrams landscape pages"
            },
            "description": "Give wide tables and diagrams landscape pages"
          },
          {
            "name": "toc",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false,
              "description": "Start with a table of contents"
            },
            "description": "Start with a table of contents"
          },
          {
            "name": "title",
            "in": "query",
            "schema": {
              "type": "string",
              "description": "Title used when the document has none"
            },
            "description": "Title used when the document has none"
          },
          {
            "name": "mathMode",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "auto",
                "latex",
                "asciimath"
              ],
              "default": "auto"
            },
            "description": "mathMode (raw Markdown bodies only)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "text/markdown": {
              "schema": {
                "type": "string"
              },
              "example": "# Report\n\n$$E = mc^2$$"
            },
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "markdown"
                ],
                "properties": {
                  "markdown": {
                    "type": "string"
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "docx",
                      "pdf",
                      "html"
                    ],
                    "default": "docx"
                  },
                  "options": {
                    "type": "object",
                    "properties": {
                      "theme": {
                        "type": "string",
                        "enum": [
                          "standard",
                          "academic",
                          "modern",
                          "compact"
                        ],
                        "default": "standard",
                        "description": "Document theme; all but standard need Pro"
                      },
                      "pageSize": {
                        "type": "string",
                        "enum": [
                          "A4",
                          "Letter",
                          "A5",
                          "A3",
                          "Legal"
                        ],
                        "default": "A4"
                      },
                      "orientation": {
                        "type": "string",
                        "enum": [
                          "portrait",
                          "landscape"
                        ],
                        "default": "portrait"
                      },
                      "autoLandscape": {
                        "type": "boolean",
                        "default": true,
                        "description": "Give wide tables and diagrams landscape pages"
                      },
                      "toc": {
                        "type": "boolean",
                        "default": false,
                        "description": "Start with a table of contents"
                      },
                      "title": {
                        "type": "string",
                        "description": "Title used when the document has none"
                      },
                      "mathMode": {
                        "type": "string",
                        "enum": [
                          "auto",
                          "latex",
                          "asciimath"
                        ],
                        "default": "auto"
                      }
                    }
                  },
                  "files": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string",
                      "contentEncoding": "base64"
                    },
                    "description": "Images referenced by file name in the Markdown (up to 30)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The converted document",
            "headers": {
              "X-Watermarked": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "0",
                    "1"
                  ]
                }
              },
              "X-Calls-Remaining": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "application/pdf"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "filename": {
                      "type": "string"
                    },
                    "mime": {
                      "type": "string"
                    },
                    "base64": {
                      "type": "string",
                      "contentEncoding": "base64"
                    },
                    "watermarked": {
                      "type": "boolean"
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "remaining": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from /developers, e.g. mf_..."
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retryAfterSeconds": {
            "type": "integer"
          }
        }
      }
    }
  }
}