API & Agentic

Convert and clean Markdown from your own scripts or any AI agent. Pick the path that fits your workflow.

Call mdtidy directly

One endpoint, JSON in and JSON out. Authenticate with the X-API-KEY header.

Endpoint
The customer-facing surface of the API.
Method & path
POST /api/v1/convert
Auth
X-API-KEY: mt_live_…
Rate limit
60 requests / minute, per key
Max payload
200 KB of Markdown per call
Credit cost
1 credit per successful call (4xx/5xx is free)
Quickstart
Render a Markdown document as a PDF. Replace $MARKDOWN_TIDY_KEY / MARKDOWN_TIDY_KEY with a key from your account page.
curl -X POST https://markdowntidy.com/api/v1/convert \
  -H "X-API-KEY: $MARKDOWN_TIDY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "markdown": "# Hello\n\nWorld.",
    "format": "pdf",
    "actions": ["clean", "repair"]
  }' \
  | jq -r .outputBase64 | base64 -d > out.pdf
Response
What you get back — status codes, headers, and the body shape for both successes and errors.

Status codes

200
Successful conversion. 1 credit charged.
400
invalid_request — missing or malformed body, unknown format, etc.
401
missing_api_key / invalid_api_key — bad or absent X-API-KEY.
402
out_of_credits — your wallet has no credits left this period.
413
payload_too_large — Markdown body exceeds 200 KB.
429
rate_limited — more than 60 requests / minute on this key.
500
internal_error — pipeline failure. Credit is refunded automatically.

Headers

X-Request-ID
Unique ID for the call. Returned on every response — quote it when you contact support.
X-Credits-Remaining
Wallet balance after this call. Sent on 200 and 402.
RateLimit-Limit
Per-key ceiling (60 / min). Sent on 429.
RateLimit-Remaining
Calls left in the current window. Sent on 429.
RateLimit-Reset
Unix epoch when the window resets. Sent on 429.
Retry-After
Seconds to wait before retrying. Sent on 429.

Body — success (200)

For html / text, output is a string. For pdf / docx / png, the body is base64-encoded in outputBase64.

{
  "format": "pdf",
  "contentType": "application/pdf",
  "byteSize": 12345,
  "designSystem": "minimal-clean",
  "outputBase64": "JVBERi0xLjQK…",
  "warnings": [
    { "rule": "table_pipe_balance", "fixes": 2 }
  ],
  "creditsCharged": 1,
  "creditsRemaining": 1999,
  "requestId": "f0c7…"
}

Body — error

Every 4xx/5xx shares the same envelope. The requestId matches the X-Request-ID header.

{
  "error": {
    "code": "invalid_request",
    "message": "format: required",
    "requestId": "f0c7…"
  }
}