Inkspan › Guides › How to convert Markdown to PDF in cURL

How to convert Markdown to PDF in cURL

Markdown is the most convenient format to generate programmatically and the least convenient to hand to a customer. The /v1/generate/markdown endpoint closes that gap: send Markdown, get a styled PDF. It is the shortest path from a generated report, a changelog, or LLM output to a document someone can file or print.

Tables and fenced code blocks are enabled, which covers most of what generated reports actually use. Markdown is converted to HTML and then rendered through the same engine as /v1/generate/html.

Also in: Python · Node.js

cURL example

curl -X POST https://api.inkspan.dev/v1/generate/markdown \
  -H "X-API-Key: ink_live_..." \
  -H "Content-Type: application/json" \
  -d '{"markdown": "# Q3 Report\n\n| Metric | Value |\n|---|---|\n| Signups | 1200 |"}' \
  --output document.pdf

Request parameters

NameTypeRequiredDescription
markdownstringyesMarkdown source. GitHub-style tables and fenced code blocks are supported.
filenamestringnoFilename in the response's Content-Disposition.

Response

Returns a PDF as a binary stream with Content-Type: application/pdf and Content-Disposition: attachment; filename=document.pdf. Write the response body straight to disk — do not parse it as JSON.

Things that catch people out

Errors

StatusMeaningFix
401Invalid or missing API keySend your key in the X-API-Key header.
402Monthly quota exceededThe response reports used/quota. Upgrade at inkspan.dev/#pricing.
422Missing or invalid parameterCheck required fields in the table above — the body names the offending field.

Failed requests do not count against your quota; only successful ones are metered.

Frequently asked questions

Can I control fonts and margins?

Not from this endpoint. Convert the Markdown to HTML in your own code, wrap it in a styled document, and POST that to /v1/generate/html instead.

Does it support Mermaid diagrams?

No. Diagrams are not rendered — generate the image separately and reference it with an absolute URL.

Is this good for LLM output?

Yes, this is a common use. Models emit Markdown naturally, so this endpoint is usually the last step in an agent pipeline that produces a report.

Get a free API key →

Related Generate guides: generate a PDF from HTML · generate a PDF from a template