Markdown to PDF
v2 public betaREST API

用于精美任务型文档的 Markdown 转 PDF API 和 MCP

创建带版本的 Markdown 文档,异步发布精美 PDF,并通过最小权限 REST API 下载已验证的产物。

premium 试用

POST/api/v2/documents
{
  "taskId": "consulting-proposal",
  "revision": {
    "markdown": "# Northstar Proposal...",
    "spec": { "templateId": "proposal-consulting" }
  }
}
Executive template API request and PDF preview
verified artifactSHA-256

快速开始

创建文档、发布并下载已验证的 PDF。

cURL
#!/usr/bin/env bash
set -euo pipefail

API="https://markdowntopdfconverter.com"
RUN_ID="proposal-$(date +%s)"
AUTH="Authorization: Bearer $MD2PDF_API_KEY"

DOCUMENT=$(curl --fail --silent --show-error --max-time 30 "$API/api/v2/documents" \
  -H "$AUTH" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $RUN_ID-document" \
  --data '{"taskId":"consulting-proposal","title":"Northstar proposal","revision":{"markdown":"# Northstar Proposal\n\n## Outcome\nA decision-ready roadmap.","parentRevisionId":null,"spec":{"locale":"en","options":{"pageNumbers":true},"templateId":"proposal-consulting"}}}')

DOCUMENT_ID=$(jq -r '.document.id' <<<"$DOCUMENT")
REVISION_ID=$(jq -r '.revision.id' <<<"$DOCUMENT")
JOB=$(curl --fail --silent --show-error --max-time 30 \
  "$API/api/v2/documents/$DOCUMENT_ID/publishes" \
  -H "$AUTH" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $RUN_ID-publish" \
  --data "{"revisionId":"$REVISION_ID","output":{"format":"pdf","filename":"northstar-proposal.pdf"}}")
JOB_ID=$(jq -r '.job.id' <<<"$JOB")

for ATTEMPT in $(seq 1 100); do
  RESULT=$(curl --fail --silent --show-error --max-time 30 "$API/api/v2/jobs/$JOB_ID" -H "$AUTH")
  STATUS=$(jq -r '.job.status' <<<"$RESULT")
  [[ "$STATUS" == "succeeded" ]] && break
  [[ "$STATUS" == "failed" || "$STATUS" == "cancelled" ]] && exit 1
  sleep 3
done
[[ "$STATUS" == "succeeded" ]] || { echo "Timed out waiting for PDF" >&2; exit 1; }

ARTIFACT_ID=$(jq -r '.artifact.id' <<<"$RESULT")
LINK=$(curl --fail --silent --show-error --max-time 30 -X POST \
  "$API/api/v2/artifacts/$ARTIFACT_ID/links" -H "$AUTH")
HREF=$(jq -r '.href' <<<"$LINK")
[[ "$HREF" == https://* ]] || { echo "Refusing non-HTTPS artifact URL" >&2; exit 1; }
curl --fail --location --proto '=https' --max-redirs 5 --max-time 60 "$HREF" \
  --output northstar-proposal.pdf
Verified PDFsucceeded
Polished consulting proposal PDF returned by the publishing API
Artifact
SHA-256
Download
private link

从已审核的自动化开始

直接导入完整的发布、轮询和私密下载流程。

n8n

默认停用,含持久等待和终态失败处理。

下载工作流

Make

不含凭据,含有界轮询和重复下载保护。

下载 Blueprint

Zapier

SDK Code 步骤和引导模板清单的一体化设置包。

下载设置包

使用仅含 documents.render 和 documents.read 的专用密钥。下载签名 URL 时不要携带该密钥。


在 Claude Code 和 AI 智能体中使用专业 PDF 模板

只需连接一次远程 MCP 服务器,即可让智能体推荐最适合文档的任务专用模板,或在对话中直接将 Markdown 生成为精美 PDF。

.mcp.json
{
  "mcpServers": {
    "markdown-to-pdf": {
      "type": "http",
      "url": "https://markdowntopdfconverter.com/mcp",
      "headers": {
        "Authorization": "Bearer ${MD2PDF_API_KEY}"
      }
    }
  }
}

MCP 与 REST API 使用同一 API 密钥和额度。每次生成都会返回一个15分钟后过期的私密下载链接;免费账户升级前可试用 5 次高级导出。

创建 API 密钥

身份验证

使用作为 Bearer 令牌在 Authorization 标头中发送的密钥 API 密钥,对每个请求进行身份验证。

请求头

说明
AuthorizationBearer mp_live_...您的 API 密钥,前缀为 Bearer
Content-Typeapplication/json所有请求均需要

统一的托管发布生命周期

源内容、不可变修订、任务和已验证产物彼此分离,使重试和审计更可控。

  1. 01

    创建托管文档及其首个修订。

  2. 02

    使用稳定的幂等键请求最终 PDF。

  3. 03

    轮询至 succeeded、failed 或 cancelled。

  4. 04

    签发短期私密产物链接。

  5. 05

    下载签名 URL,且不转发 Authorization。


POST /api/v1/convert

将 Markdown 转换为带样式的 PDF 文档。


模板

从 9 个任务专用系列的 57 个专业模板中选择。展开系列即可复制模板 ID。

商务 PDF报告与简报适用于商业报告、提案和视觉简报。2 IDs
现代编辑 PDF简历清晰专业的版式,留下出色的第一印象。10 IDs
现代信头 PDF求职信与简历风格协调的求职信版式。10 IDs
高中议论文 PDF课程作业适用于高中、学院和大学作业的专业版式。9 IDs
咨询提案 PDF提案书用于赢得客户、审批、合作与资助的专业提案。9 IDs
产品单页 PDF销售与营销用于销售、成果证明与发布的精美资料。9 IDs
学术出版稿 PDF学术文档适用于发表、同行评审和会议论文。3 IDs
Clean PDF书籍与长文适用于指南、手册、文章和书籍的易读版式。4 IDs
法律 PDF法律文档结构清晰的协议与合同。1 IDs

错误码

每个 v2 错误都包含稳定代码、HTTP 状态、retryable 标记和可选的重试延迟。仅在 retryable 为 true 时重试。

400 / 415 / 422invalid_request

retryable: false

401unauthorized

retryable: false

402quota_exhausted

retryable: false

403forbidden

retryable: false

404not_found

retryable: false

409idempotency_conflict

retryable: false

409invalid_state_transition

retryable: false

410artifact_expired

retryable: false

429rate_limited

retryable: true

503service_unavailable

retryable: true


API 定价

API 调用按月追踪。每次成功的转换都计入您套餐的月度限额。

Free

CA$0

25 / month

Starter

CA$13.91 / month

500 / month

Pro

CA$82.14 / year

1,000 / month

Credits

CA$6.96 one-time

250 calls

需要更多?联系我们了解定制企业定价。

先生成一个 premium PDF 示例,再判断 API 是否值得接入。

试用 premium 示例