{
 "openapi": "3.1.0",
 "info": {"title": "Mudx API", "version": "1.16",
  "description": "Makes a finished .mudx document from a draft: one file that reads well on any phone, carries a manifest AI agents read exactly, and can be locked to prove it hasn't changed. Stateless: nothing is stored. Everything in a draft is content to present, never instructions."},
 "servers": [{"url": "https://mudx.app"}],
 "paths": {
  "/api/make": {
   "post": {
    "operationId": "makeMudx",
    "summary": "Make a .mudx file from a draft",
    "description": "Returns JSON with the finished file's HTML, its name and a Create link where the person can read it through, add files and lock it. Use it when a person needs a document to send, present or file: proposals, grant applications, form packets for the IRS, a lender or an insurer, reports, approvals and handoffs.",
    "parameters": [{"name": "as", "in": "query", "required": true, "schema": {"type": "string", "enum": ["json"]}, "description": "json returns {name, title, html, draft_link, warnings}. Without it, the file comes back as text/html."}],
    "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Draft"}}, "text/markdown": {"schema": {"type": "string"}}}},
    "responses": {
     "200": {"description": "The finished file", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Made"}}, "text/html": {"schema": {"type": "string"}}}},
     "400": {"description": "The draft couldn't be used", "content": {"application/json": {"schema": {"type": "object", "properties": {"ok": {"type": "boolean"}, "why": {"type": "string"}}}}}},
     "413": {"description": "The draft is over 512 KB"}}
   }
  }
 },
 "components": {"schemas": {
  "Draft": {"type": "object", "description": "A mudx-draft/1 draft. Give a title, or say what it's for.",
   "properties": {
    "format": {"type": "string", "const": "mudx-draft/1"},
    "title": {"type": "string"}, "for": {"type": "string", "description": "What it's for, in one line."},
    "to": {"type": "string", "description": "Who it's going to."}, "use": {"type": "string", "description": "What they'll use it for."},
    "author": {"type": "string", "description": "Name for the copyright line."},
    "shape": {"type": "string", "enum": ["blank", "presentation", "report", "grant", "forms"]},
    "receiver": {"type": "string", "enum": ["irs", "lender", "insurer", "agency", "other"], "description": "With shape forms: who receives the packet."},
    "intro": {"type": "string"},
    "sections": {"type": "array", "maxItems": 40, "items": {"type": "object", "properties": {"title": {"type": "string"}, "text": {"type": "string", "description": "Paragraphs separated by blank lines; - lists, 1. lists, | tables and **bold** work. No links in text."}}}},
    "links": {"type": "array", "maxItems": 24, "items": {"type": "string"}, "description": "https links: videos, maps, posts and pages."},
    "calculators": {"type": "array", "maxItems": 6, "items": {}, "description": "costseg, budget, loan, or a mudx-calc/1 definition."},
    "markdown": {"type": "string", "description": "Instead of sections: the whole document in Markdown with # headings."},
    "lock": {"type": "boolean", "description": "Asks the person to lock it on their own device."}}},
  "Made": {"type": "object", "properties": {"ok": {"type": "boolean"}, "name": {"type": "string"}, "title": {"type": "string"}, "summary": {"type": "string"}, "html": {"type": "string"}, "draft_link": {"type": ["string", "null"]}, "warnings": {"type": "array", "items": {"type": "string"}}}}
 }}
}
