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.
- 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)
$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.pdfStatus 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…"
}
}Use mdtidy from any AI agent
Give your assistant or coding agent a simple skill plus your API key, and it can clean, format, and prepare Markdown for you. (MCP server support is on the roadmap.)
How it works
- 01
Ask your agent to clean or prepare Markdown.
- 02
The agent sends the Markdown to mdtidy using your API key.
- 03
The agent returns clean, tidy, LLM-ready Markdown back into your workflow.
“Clean this Markdown with mdtidy and return only the final Markdown.”
“Use mdtidy to normalize this document before summarizing it.”
Ready to wire it up? Sign in and grab your API key →