{"openapi":"3.1.0","info":{"title":"Markfolio API","version":"1.0.0","description":"Markdown in, a beautiful shareable link out. Publish, update, and organize documents an agent produces, then hand back a stable public URL. Inbound Markdown may include a leading YAML frontmatter block (`title`, `slug`). It is parsed and stripped from the rendered body. Markdown is limited to 2 MiB of UTF-8 data and explicit titles to 255 characters. Each account may store 1000 documents and 100 MiB of Markdown. JSON requests must use application/json; document request bodies are capped at 12 MiB plus 64 KiB to allow JSON escaping."},"servers":[{"url":"https://markfolio.round6.co"}],"security":[{"bearerAuth":[]}],"tags":[{"name":"Capabilities"},{"name":"Documents"},{"name":"Folders"},{"name":"Public export","description":"Keyless. No authentication."}],"paths":{"/api/v1/me":{"get":{"tags":["Capabilities"],"summary":"Inspect this API key's capabilities","description":"Returns the account tier, this key's effective scopes, request limit, retention policy, and feature flags.","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Capabilities"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/api/v1/documents":{"post":{"tags":["Documents"],"summary":"Publish a document","description":"Creates a document from Markdown and returns its stable URL, owner_id and effective visibility. Free keys cannot set a custom `slug`. Markdown may include YAML frontmatter.","x-required-scope":"documents:write","parameters":[{"name":"X-Markfolio-Default-Visibility","in":"header","description":"Creation-only visibility default. Does not change existing documents on external_id replay.","schema":{"type":"string","enum":["public","private"],"default":"public"}},{"name":"If-Match","in":"header","description":"ETag from a prior read when external_id may update an existing document.","schema":{"type":"string"}},{"name":"If-None-Match","in":"header","description":"Use * with external_id for create-only semantics.","schema":{"type":"string","enum":["*"]}}],"x-codeSamples":[{"lang":"Shell","label":"curl","source":"curl -X POST \"$MARKFOLIO_BASE_URL/api/v1/documents\" \\\n  -H \"Authorization: Bearer $MARKFOLIO_API_KEY\" \\\n  -H 'Content-Type: application/json' \\\n  -d '{\"markdown\":\"# Hello\",\"title\":\"Hello\",\"slug\":\"hello\",\"folder_id\":\"fld_123\"}'"},{"lang":"Python","label":"Publish a .md file","source":"export MARKFOLIO_BASE_URL=\"https://your-domain.com\"\nexport MARKFOLIO_API_KEY=\"your_api_key\"\n\npython3 - <<'PY' ./proposal.md\nimport json\nimport os\nimport sys\nimport urllib.request\nfrom pathlib import Path\n\nbase_url = os.environ[\"MARKFOLIO_BASE_URL\"].rstrip(\"/\")\napi_key = os.environ[\"MARKFOLIO_API_KEY\"]\nmarkdown = Path(sys.argv[1]).read_text(encoding=\"utf-8\")\n\ndata = json.dumps({\"markdown\": markdown}).encode(\"utf-8\")\nrequest = urllib.request.Request(\n    f\"{base_url}/api/v1/documents\",\n    data=data,\n    headers={\n        \"Authorization\": f\"Bearer {api_key}\",\n        \"Content-Type\": \"application/json\",\n    },\n    method=\"POST\",\n)\n\nwith urllib.request.urlopen(request) as response:\n    payload = json.loads(response.read().decode(\"utf-8\"))\n\nprint(payload['url'])\nPY"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentInput"}}}},"responses":{"200":{"description":"Updated (idempotent re-publish of an external_id)","headers":{"ETag":{"description":"Strong version token for conditional writes.","schema":{"type":"string","example":"\"3q2-7w\""}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"201":{"description":"Created","headers":{"ETag":{"description":"Strong version token for conditional writes.","schema":{"type":"string","example":"\"3q2-7w\""}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/InvalidInput"},"403":{"$ref":"#/components/responses/Forbidden"},"409":{"$ref":"#/components/responses/Conflict"},"412":{"$ref":"#/components/responses/PreconditionFailed"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"415":{"description":"Content-Type must be application/json."},"429":{"$ref":"#/components/responses/RateLimited"}}},"get":{"tags":["Documents"],"summary":"List documents","x-required-scope":"documents:read","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":20}},{"name":"offset","in":"query","schema":{"type":"integer","minimum":0,"default":0}},{"name":"folder_id","in":"query","schema":{"type":"string"}},{"name":"q","in":"query","description":"Search title, slug, and external_id.","schema":{"type":"string","maxLength":100}},{"name":"publish_status","in":"query","schema":{"type":"string","enum":["published","unpublished"]}},{"name":"expiry_status","in":"query","schema":{"type":"string","enum":["permanent","active","expired"]}},{"name":"include_total","in":"query","description":"Run an additional count query and include pagination.total.","schema":{"type":"boolean","default":false}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"documents":{"type":"array","items":{"$ref":"#/components/schemas/Document"}},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"has_more":{"type":"boolean"},"next_offset":{"type":["integer","null"]},"total":{"type":"integer"}}}}}}}}}}},"/api/v1/documents/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"get":{"tags":["Documents"],"summary":"Read a document","x-required-scope":"documents:read","responses":{"200":{"description":"OK","headers":{"ETag":{"description":"Strong version token for conditional writes.","schema":{"type":"string","example":"\"3q2-7w\""}}},"content":{"application/json":{"schema":{"type":"object","properties":{"document":{"$ref":"#/components/schemas/Document"}}}}}},"404":{"$ref":"#/components/responses/NotFound"}}},"patch":{"tags":["Documents"],"summary":"Update a document","description":"Update markdown, title, slug (Pro), folder, or publication state. Free keys may move folders and change publication state; content, title, and slug edits are Pro. If-Match is recommended. Existing unconditional clients remain temporarily supported.","x-required-scope":"documents:write","parameters":[{"name":"If-Match","in":"header","description":"Strong ETag from GET. If stale, the update changes nothing and returns 412.","schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentInput"}}}},"responses":{"200":{"description":"OK","headers":{"ETag":{"description":"Strong version token for conditional writes.","schema":{"type":"string","example":"\"3q2-7w\""}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/InvalidInput"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"412":{"$ref":"#/components/responses/PreconditionFailed"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"415":{"description":"Content-Type must be application/json."},"429":{"$ref":"#/components/responses/RateLimited"}}},"delete":{"tags":["Documents"],"summary":"Delete a document","x-required-scope":"documents:delete","responses":{"200":{"description":"Deleted"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/v1/folders":{"get":{"tags":["Folders"],"summary":"List folders","x-required-scope":"folders:read","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"folders":{"type":"array","items":{"$ref":"#/components/schemas/Folder"}}}}}}}}},"post":{"tags":["Folders"],"summary":"Create a folder","x-required-scope":"folders:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"Use \"Group / Folder\" to file a folder inside a group in the app, for example \"Clients / Honda\". A group appears automatically and is not a separate object."}}}}}},"responses":{"201":{"description":"Created"}}}},"/api/v1/folders/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"patch":{"tags":["Folders"],"summary":"Rename a folder","x-required-scope":"folders:write","responses":{"200":{"description":"OK"}}},"delete":{"tags":["Folders"],"summary":"Delete a folder","x-required-scope":"folders:write","responses":{"200":{"description":"Deleted"}}}},"/api/v1/images":{"get":{"tags":["Images"],"summary":"List uploaded images","description":"Returns the newest 200 images uploaded by this account.","x-required-scope":"documents:read","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"images":{"type":"array","items":{"$ref":"#/components/schemas/Image"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"description":"Image storage unavailable"}}},"post":{"tags":["Images"],"summary":"Upload an image (Pro)","description":"Send raw PNG, JPEG, GIF, or WebP bytes as `application/octet-stream` (max 10 MiB; 1 GiB per account). The type is detected from the bytes. Location, camera, and other metadata are stripped. Embed the returned `markdown` or `url` in a document.","x-required-scope":"documents:write","x-codeSamples":[{"lang":"Shell","label":"curl","source":"curl -X POST \"$MARKFOLIO_BASE_URL/api/v1/images\" \\\n  -H \"Authorization: Bearer $MARKFOLIO_API_KEY\" \\\n  -H 'Content-Type: application/octet-stream' \\\n  --data-binary @chart.png\n# Returns {\"image\":{\"id\":\"img_…\",\"url\":\"…\",\"markdown\":\"![](…)\",…}}. Put the markdown in a document."}],"requestBody":{"required":true,"content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"image":{"$ref":"#/components/schemas/Image"}}}}}},"400":{"description":"Not a supported image"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Pro required (`pro_required`) or the key lacks documents:write (`insufficient_scope`)"},"413":{"description":"File or account storage limit exceeded"},"429":{"$ref":"#/components/responses/RateLimited"},"502":{"description":"Image storage could not be reached"},"503":{"description":"Image storage unavailable"}}}},"/api/v1/images/{id}":{"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"delete":{"tags":["Images"],"summary":"Delete an image","description":"Removes the stored file. Documents that reference it will show a broken image.","x-required-scope":"documents:delete","responses":{"200":{"description":"Deleted"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"502":{"description":"Image storage could not be reached"},"503":{"description":"Image storage unavailable"}}}},"/raw/{slug}.md":{"get":{"tags":["Public export"],"summary":"Fetch raw Markdown for a public document","security":[],"parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Raw Markdown","content":{"text/markdown":{"schema":{"type":"string"}}}},"404":{"description":"No such public document"}}}},"/raw/{slug}.json":{"get":{"tags":["Public export"],"summary":"Fetch reader-safe JSON for a public document","security":[],"parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Public document","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicDocument"}}}},"404":{"description":"No such public document"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"An API key, e.g. `Authorization: Bearer mk_live_…`"}},"schemas":{"DocumentInput":{"type":"object","properties":{"markdown":{"type":"string","description":"May include leading YAML frontmatter. Maximum 2 MiB (2097152 bytes) encoded as UTF-8, including frontmatter."},"title":{"type":"string","maxLength":255},"slug":{"type":"string","minLength":3,"maxLength":40,"description":"Pro only. Unavailable slugs return 409; retired slugs are never reused."},"folder_id":{"type":["string","null"],"maxLength":32},"visibility":{"type":"string","enum":["public","private"],"description":"Explicit access change. Omission preserves visibility on PATCH/replay; legacy API creates default public. X-Markfolio-Default-Visibility: private changes only the creation default. New MCP workflow uses private. Ownership comes only from the API principal."},"published":{"type":"boolean","description":"Take the unlisted link online or offline. New documents default to online; false creates offline atomically. Omission on external_id replay preserves the existing publication state. Public online links are anonymous; private online links require the owner session. Unlisted is not access control."},"external_id":{"type":"string","maxLength":128,"description":"Stable per-owner id for idempotent publish. Re-posting the same external_id updates the existing document (200) and keeps its URL, instead of creating a duplicate (201). Creating with external_id is available on Free; replay updates require Pro."}}},"Document":{"type":"object","properties":{"owner_id":{"type":"string","description":"Authenticated account that owns the document."},"visibility":{"type":"string","enum":["public","private"],"description":"Effective access. Private is owner-only, including legacy shared_link rows."},"id":{"type":"string","example":"doc_123"},"slug":{"type":"string","example":"q3-report"},"title":{"type":"string","example":"Q3 Report"},"markdown":{"type":"string","example":"# Q3 Report\n\n..."},"folder_id":{"type":["string","null"],"example":"fld_123"},"external_id":{"type":["string","null"],"example":"report-2026-q3"},"revision":{"type":"integer","minimum":1,"description":"Monotonic document revision. The HTTP ETag is authoritative."},"url":{"type":"string","example":"https://markfolio.round6.co/q3-report"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"expires_at":{"type":["string","null"],"format":"date-time"},"expiry_status":{"type":"string","enum":["permanent","active","expired"]},"expiry_label":{"type":"string","example":"Permanent link"},"published":{"type":"boolean"},"publish_status":{"type":"string","enum":["published","unpublished"]},"unpublished_at":{"type":["string","null"],"format":"date-time"}}},"Image":{"type":"object","properties":{"id":{"type":"string","example":"img_V1StGXR8Z5jdHi6B"},"url":{"type":"string","format":"uri"},"markdown":{"type":"string","example":"![](https://…)"},"content_type":{"type":"string","enum":["image/png","image/jpeg","image/gif","image/webp"]},"bytes":{"type":"integer"},"created_at":{"type":"string","format":"date-time"}}},"Folder":{"type":"object","properties":{"id":{"type":"string","example":"fld_123"},"name":{"type":"string","example":"Client work"},"created_at":{"type":"string","format":"date-time"},"document_count":{"type":"integer","minimum":0}}},"Capabilities":{"type":"object","properties":{"owner":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"}}},"visibility":{"type":"object","properties":{"supported":{"type":"array","items":{"type":"string","enum":["public","private"]}},"browser_access":{"const":"owner_only"},"api_default":{"const":"public"},"agent_default":{"const":"private"}}},"tier":{"type":"string","enum":["free","pro"]},"scopes":{"type":"array","items":{"type":"string","enum":["documents:read","documents:write","documents:delete","folders:read","folders:write"]}},"limits":{"type":"object","properties":{"requests_per_minute":{"type":"integer","example":30}}},"retention":{"type":"object","properties":{"public_link_days":{"type":["integer","null"]},"recovery_days":{"type":["integer","null"]},"permanent_links":{"type":"boolean"}}},"capabilities":{"type":"object","additionalProperties":{"type":"boolean"}}}},"PublicDocument":{"type":"object","description":"Reader-safe projection (no id / owner / folder).","properties":{"slug":{"type":"string","example":"q3-report"},"title":{"type":"string","example":"Q3 Report"},"markdown":{"type":"string","example":"# Q3 Report\n\n..."},"url":{"type":"string","example":"https://markfolio.round6.co/q3-report"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"expires_at":{"type":["string","null"],"format":"date-time"},"expiry_status":{"type":"string","enum":["permanent","active","expired"]},"expiry_label":{"type":"string","example":"Permanent link"}}},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":true},"request_id":{"type":"string","format":"uuid"}}}}}},"responses":{"InvalidInput":{"description":"Malformed JSON, invalid field type, invalid slug, or title longer than 255 characters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"PayloadTooLarge":{"description":"Request body exceeds its byte limit, Markdown exceeds 2 MiB, or account Markdown storage would exceed 100 MiB. Reducing existing account storage remains allowed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Unauthorized":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Forbidden":{"description":"Tier or API-key scope does not allow this action","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Conflict":{"description":"Slug or document identifier already taken, or account document count reached 1000.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"PreconditionFailed":{"description":"The conditional token is stale. Re-read, reconcile, and retry with the current ETag.","headers":{"ETag":{"description":"Strong version token for conditional writes.","schema":{"type":"string","example":"\"3q2-7w\""}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"RateLimited":{"description":"Tier request limit exceeded (30/minute Free, 120/minute Pro)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}