REST API
POST /v1/convert — requests, responses, errors and limits.
Convert
POST /v1/convert takes Markdown and returns the file directly.
BASH
curl -X POST https://md2-edge.abdalganih1.workers.dev/v1/convert \
-H "Content-Type: application/json" \
-d '{"markdown":"# Hello\n\nfrom md2","format":"pdf","options":{"theme":"blue"}}' \
-o hello.pdfRequest body (JSON)
| Field | Type | Notes |
|---|---|---|
markdown |
string | required |
format |
pdf, png, html, md, json, txt |
default html |
options |
object | see themes and options |
filename |
string | file name without extension |
envelope |
boolean | true returns JSON (Base64 for PDF/PNG) instead of the raw file |
Raw Markdown
Send Content-Type: text/markdown with options in the query: ?format=pdf&theme=red&direction=rtl.
Response
The file itself with Content-Disposition, plus useful headers:
| Header | Meaning |
|---|---|
X-Md2-Cache |
HIT or MISS |
X-Md2-Warnings |
number of engine warnings |
X-RateLimit-Remaining |
requests left this minute |
Errors
Every error has the same shape:
JSON
{ "ok": false, "error": { "code": "RATE_LIMITED", "message": "…" } }| Code | HTTP | What to do |
|---|---|---|
INVALID_INPUT |
400 | Fix the request; see details |
TOO_LARGE |
413 | Split the document |
RATE_LIMITED |
429 | Wait for Retry-After |
BROWSER_UNAVAILABLE |
503 | The print service is busy; retry in a few seconds |
TIMEOUT |
504 | Very heavy document; retry or shorten it |
Health
GET /v1/health returns the engine and themes versions and whether the database, storage and print bindings are present.
Authentication
Unauthenticated requests work with guest limits. API keys (Authorization: Bearer md2_…) are supported by the server; the account screen to create them comes in a later phase.