Skip to content

Quickstart

Get started with Papermill and you could generate your first PDF in under five minutes.

What you'll need

  • A Papermill account. If you don't have one, please request a free trial.
  • A terminal with cURL (or else Node or Python)
  • That's it!

Get your API key

Head over to Settings - API keys in the Papermill app and click "Create new API key."

Click "Copy to Clipboard" from the popup to copy the key.

Store the key in an environmental variable in your shell:

shell
export PAPERMILL_API_KEY="your api key"

Make your first request

Copy the cURL command to your shell and hit enter:

This will use the papermill-simple-report template, a built-in template available to all users.

shell
curl -X POST https://api.papermill.io/v2/pdf?template_id=papermill-simple-report \
  -H "Authorization: Bearer $PAPERMILL_API_KEY" \
  -H "Content-Type: text/markdown" \
  -o quickstart.pdf \
  --data-binary @- <<EOF
# Q3 Revenue Summary

Quarterly performance across our core product lines.

| Product       | Revenue      | Growth |
|---------------|--------------|--------|
| Platform      | £482,000     | +18%   |
| Add-ons       | £124,000     | +42%   |
| Services      | £67,000      | -3%    |
| **Total**     | **£673,000** | **+19%** |

Strong quarter overall, driven by add-on adoption.
EOF
python
import os
import requests

API_KEY = os.environ["PAPERMILL_API_KEY"]

markdown = """# Q3 Revenue Summary

Quarterly performance across our core product lines.

| Product       | Revenue      | Growth |
|---------------|--------------|--------|
| Platform      | £482,000     | +18%   |
| Add-ons       | £124,000     | +42%   |
| Services      | £67,000      | -3%    |
| **Total**     | **£673,000** | **+19%** |

Strong quarter overall, driven by add-on adoption.
"""

response = requests.post(
    "https://api.papermill.io/v2/pdf?template_id=papermill-simple-report",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "text/markdown",
    },
    data=markdown.encode("utf-8"),
)
response.raise_for_status()

with open("quickstart.pdf", "wb") as f:
    f.write(response.content)
javascript
import fs from 'node:fs/promises'

const API_KEY = process.env.PAPERMILL_API_KEY

const markdown = `# Q3 Revenue Summary

Quarterly performance across our core product lines.

| Product       | Revenue      | Growth |
|---------------|--------------|--------|
| Platform      | £482,000     | +18%   |
| Add-ons       | £124,000     | +42%   |
| Services      | £67,000      | -3%    |
| **Total**     | **£673,000** | **+19%** |

Strong quarter overall, driven by add-on adoption.
`

const response = await fetch('https://api.papermill.io/v2/pdf?template_id=papermill-simple-report', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    'Content-Type': 'text/markdown',
  },
  body: markdown,
})

if (!response.ok) {
  throw new Error(`${response.status} ${response.statusText}`)
}

const buffer = Buffer.from(await response.arrayBuffer())
await fs.writeFile('quickstart.pdf', buffer)

Open up quickstart.pdf to see the resulting PDF.

What's next

You've created your first PDF - what next?!

You may now want to:

Troubleshooting

401 Unauthorized

Your API key is likely invalid or missing - ensure the variable is set with echo $PAPERMILL_API_KEY. Try generating a new key via Settings - API keys

400 Bad Request

Carefully check the cURL command and, if you've modified the markdown, make sure it's still formatted correctly. Try copying the example above and check it works.

PDF Missing or Corrupt

Make sure you've included the -o option with a filename to cURL, and the --data-binary switch (not -d).