Generate PDFs with the API

Last updated March 23, 2026

The PDFMonkey REST API lets you generate PDF documents from your templates by sending HTTP requests with JSON data. Use it to create invoices, receipts, reports, certificates, and any PDF from dynamic data – this is the best approach for automated workflows in your own application.

Prerequisites

You’ll need a PDFMonkey account and at least one template. If you haven’t created a template yet, see From Zero to First Document.

Generate a PDF

1. Get your API key

Grab your secret key from the API Key page in your dashboard. See Authentication for details.

2. Create a document

Send a POST request to /api/v1/documents with your template ID and dynamic data. Setting "status": "pending" queues generation immediately.

Examples are available in curl, Ruby, Node.js, Python, and PHP:

curl https://api.pdfmonkey.io/api/v1/documents \
  -X POST \
  -H 'Authorization: Bearer YOUR_SECRET_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "document": {
      "document_template_id": "YOUR-TEMPLATE-ID",
      "status": "pending",
      "payload": {
        "name": "Jane Doe"
      }
    }
  }'

The API returns the document with its current status. Note the id – you’ll need it to check on the generation.

{
  "document": {
    "id": "a5e86d72-f5b7-43d4-a04e-8b7e08e6741c",
    "status": "pending",
    "download_url": null,
    ...
  }
}

3. Check generation status

The PDF isn’t ready yet – poll the document_cards endpoint until the status reaches success, then read the download_url.

curl -H 'Authorization: Bearer YOUR_SECRET_KEY' \
  https://api.pdfmonkey.io/api/v1/document_cards/DOCUMENT_ID
# Once status is "success", the download_url field contains a signed link to the PDF
Instead of polling, you can set up a webhook to be notified when the document is ready. This is recommended for production workloads.

Asynchronous vs synchronous generation

By default, document generation is asynchronous: you create the document, then either poll the API or set up a webhook to know when it is ready. This is the best approach for production workloads, especially at high volume.

If you prefer to wait for the result in a single request, use the synchronous endpoint at /api/v1/documents/sync. This is convenient for prototyping or low-volume, interactive use cases. See Synchronous Generation for details and caveats.

Frequently asked questions

What format should the payload use?

The payload field accepts any valid JSON object. Its structure must match the variables used in your template – see Defining Dynamic Data.

How long does PDF generation take?

Most documents are ready within a few seconds. Complex templates with many pages or large images may take longer. Use a webhook to be notified as soon as the PDF is available.

Is there a rate limit?

There is no hard rate limit on the API, but your plan’s monthly document quota applies. See Our Plans for quota details.

Can I generate multiple PDFs in one request?

Not directly – each API call generates one document. To generate PDFs in bulk, send multiple requests in parallel or use an automation platform like Zapier or Make.