Markdown to PDF

Learn

Automate PDF Generation with the API

Generate branded PDFs from your own applications, scripts, and workflows using the Markdown-to-PDF API.

Published May 3, 2026·Updated May 3, 2026

The Markdown-to-PDF API lets you generate PDFs programmatically from any application that can make HTTP requests. Use it to automate report generation, invoice creation, document pipelines, and more.

Getting an API Key

  1. Sign in to your account.
  2. Go to Dashboard → API Keys.
  3. Click New Key, give it a name, and copy the generated key.
  4. Store it securely — it’s shown only once.

Each API key has its own usage tracking, so you can create separate keys for development, staging, and production.

Your First API Call

The endpoint is a single POST request:

curl -X POST https://markdowntopdfconverter.com/api/v1/convert \
  -H "Authorization: Bearer mp_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "markdown": "# Quarterly Report\n\nRevenue grew **15%** this quarter.",
    "templateId": "clean",
    "options": { "pageNumbers": true }
  }' \
  -o report.pdf

The response is a PDF file. That’s it — one request, one PDF.

Request Parameters

Parameter Required Description
markdown Yes The Markdown content. Max 200,000 characters.
templateId No Template to use: clean, executive, resume, academic, legal, creative. Default: clean. Only clean works on the free tier — executive, resume, academic, legal, and creative are premium templates that require a paid plan (free-tier keys using them get a 402).
filename No Name for the downloaded file. Default: document.pdf.
locale No Locale for rendering. Supports all 12 languages including ar, ja, zh-CN. Default: en.
customTemplateId No UUID of a saved custom template. Must be owned by the API key’s user.
options No pageNumbers (boolean), bodyTextColor (hex), headingTextColor (hex), creativeAccent (slate/purple/blue/emerald/rose/amber).

Code Examples

Python

import requests

api_key = "mp_live_YOUR_API_KEY"
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

payload = {
    "markdown": "# Invoice\n\n**Amount:** $1,200\n\n| Item | Qty | Price |\n| --- | --- | --- |\n| Widget | 5 | $240 |",
    "templateId": "clean",
    "options": {"pageNumbers": True}
}

response = requests.post(
    "https://markdowntopdfconverter.com/api/v1/convert",
    json=payload,
    headers=headers
)

with open("invoice.pdf", "wb") as f:
    f.write(response.content)

JavaScript (Node.js)

import { writeFile } from "node:fs/promises";

const apiKey = "mp_live_YOUR_API_KEY";

const response = await fetch(
  "https://markdowntopdfconverter.com/api/v1/convert",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      markdown: "# Meeting Notes\n\n- Action item 1\n- Action item 2",
      templateId: "clean",
      filename: "meeting-notes",
    }),
  }
);

const buffer = await response.arrayBuffer();
await writeFile("meeting-notes.pdf", Buffer.from(buffer));

Using Custom Templates via API

If you have saved custom templates, reference them by ID:

{
  "markdown": "# Branded Report",
  "templateId": "clean",
  "customTemplateId": "11111111-1111-4111-a111-111111111111"
}

The API verifies that the custom template belongs to your account. Other users’ templates return a 404.

Error Handling

Status Meaning Action
200 Success PDF in response body
400 Invalid request Check JSON format and parameters
401 Invalid API key Verify key is active and correctly formatted
402 Credits exhausted Purchase more credits from dashboard
404 Template not found Check customTemplateId
415 Wrong Content-Type Use application/json
429 Rate limited Wait and retry with exponential backoff

Pricing

On a subscription tier (Free, Starter, Pro), each successful conversion counts toward that tier’s monthly call limit, which resets at the start of each month. The Pro tier is billed yearly; Starter is billed monthly.

Tier Calls Price Billing
Free 25 / month $0
Starter 500 / month $9 per month
Pro 1,000 / month $59 per year

You can also buy a one-time credit pack ($5 for 250 API calls) that never expires — handy for occasional or bursty usage instead of a subscription. Credits are a decrementing balance, not a monthly quota: each call draws one credit until the balance runs out.

Upgrade from your dashboard. Unused free-tier calls reset monthly. Need higher volume? Contact us for custom enterprise pricing.

Common Automation Patterns

Generate Reports on a Schedule

Use a cron job or scheduled task to generate daily/weekly reports:

#!/bin/bash
# Daily report generator
MARKDOWN=$(generate_daily_report)
curl -X POST https://markdowntopdfconverter.com/api/v1/convert \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"markdown\":$(echo "$MARKDOWN" | jq -Rs .),\"templateId\":\"clean\",\"options\":{\"pageNumbers\":true}}" \
  -o "report-$(date +%Y-%m-%d).pdf"

Batch Document Generation

Process multiple documents by iterating over a list:

documents = [
    {"markdown": "# Doc 1", "templateId": "clean"},
    {"markdown": "# Doc 2", "templateId": "clean"},
]

for doc in documents:
    response = requests.post(API_URL, json=doc, headers=headers)
    response.raise_for_status()
    # Save each PDF

Next Steps

  • Learn how to build custom templates that match your brand.
  • Check the full API documentation for complete endpoint reference.
  • Set up usage monitoring from your dashboard to track API call volume.